diff options
Diffstat (limited to 'lib/sqlalchemy/orm/interfaces.py')
| -rw-r--r-- | lib/sqlalchemy/orm/interfaces.py | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py index 367344f5a..8cece65cc 100644 --- a/lib/sqlalchemy/orm/interfaces.py +++ b/lib/sqlalchemy/orm/interfaces.py @@ -65,9 +65,9 @@ class MapperProperty(object): cascade = () """The set of 'cascade' attribute names. - + This collection is checked before the 'cascade_iterator' method is called. - + """ def setup(self, context, entity, path, reduced_path, adapter, **kwargs): @@ -83,7 +83,7 @@ class MapperProperty(object): def create_row_processor(self, selectcontext, path, reduced_path, mapper, row, adapter): """Return a 3-tuple consisting of three row processing functions. - + """ return None, None, None @@ -91,9 +91,9 @@ class MapperProperty(object): halt_on=None): """Iterate through instances related to the given instance for a particular 'cascade', starting with this MapperProperty. - + Return an iterator3-tuples (instance, mapper, state). - + Note that the 'cascade' collection on this MapperProperty is checked first for the given type before cascade_iterator is called. @@ -110,7 +110,7 @@ class MapperProperty(object): _compile_started = False _compile_finished = False - + def init(self): """Called after all mappers are created to assemble relationships between mappers and perform other post-mapper-creation @@ -131,10 +131,10 @@ class MapperProperty(object): def do_init(self): """Perform subclass-specific initialization post-mapper-creation steps. - + This is a template method called by the ``MapperProperty`` object's init() method. - + """ pass @@ -188,7 +188,7 @@ class PropComparator(expression.ColumnOperators): new operator behaivor. The custom :class:`.PropComparator` is passed to the mapper property via the ``comparator_factory`` argument. In each case, the appropriate subclass of :class:`.PropComparator` should be used:: - + from sqlalchemy.orm.properties import \\ ColumnProperty,\\ CompositeProperty,\\ @@ -196,13 +196,13 @@ class PropComparator(expression.ColumnOperators): class MyColumnComparator(ColumnProperty.Comparator): pass - + class MyCompositeComparator(CompositeProperty.Comparator): pass - + class MyRelationshipComparator(RelationshipProperty.Comparator): pass - + """ def __init__(self, prop, mapper, adapter=None): @@ -216,7 +216,7 @@ class PropComparator(expression.ColumnOperators): def adapted(self, adapter): """Return a copy of this PropComparator which will use the given adaption function on the local side of generated expressions. - + """ return self.__class__(self.prop, self.mapper, adapter) @@ -291,9 +291,9 @@ class StrategizedProperty(MapperProperty): There is a single strategy selected by default. Alternate strategies can be selected at Query time through the usage of ``StrategizedOption`` objects via the Query.options() method. - + """ - + def _get_context_strategy(self, context, reduced_path): key = ('loaderstrategy', reduced_path) if key in context.attributes: @@ -334,7 +334,7 @@ class StrategizedProperty(MapperProperty): if self.is_primary() and \ not mapper.class_manager._attr_has_impl(self.key): self.strategy.init_class_attribute(mapper) - + def build_path(entity, key, prev=None): if prev: return prev + (entity, key) @@ -344,7 +344,7 @@ def build_path(entity, key, prev=None): def serialize_path(path): if path is None: return None - + return zip( [m.class_ for m in [path[i] for i in range(0, len(path), 2)]], [path[i] for i in range(1, len(path), 2)] + [None] @@ -366,14 +366,14 @@ class MapperOption(object): """if True, indicate this option should be carried along Query object generated by scalar or object lazy loaders. """ - + def process_query(self, query): pass def process_query_conditionally(self, query): """same as process_query(), except that this option may not apply to the given query. - + Used when secondary loaders resend existing options to a new Query.""" @@ -440,7 +440,7 @@ class PropertyOption(MapperOption): [str(m.path_entity) for m in query._entities])) else: return None - + def _get_paths(self, query, raiseerr): path = None entity = None @@ -451,7 +451,7 @@ class PropertyOption(MapperOption): # existing path current_path = list(query._current_path) - + tokens = deque(self.key) while tokens: token = tokens.popleft() @@ -459,7 +459,7 @@ class PropertyOption(MapperOption): sub_tokens = token.split(".", 1) token = sub_tokens[0] tokens.extendleft(sub_tokens[1:]) - + if not entity: if current_path: if current_path[1] == token: @@ -540,11 +540,11 @@ class StrategizedOption(PropertyOption): def _reduce_path(path): """Convert a (mapper, path) path to use base mappers. - + This is used to allow more open ended selection of loader strategies, i.e. Mapper -> prop1 -> Subclass -> prop2, where Subclass is a sub-mapper of the mapper referened by Mapper.prop1. - + """ return tuple([i % 2 != 0 and element or @@ -595,7 +595,7 @@ class LoaderStrategy(object): row, adapter): """Return row processing functions which fulfill the contract specified by MapperProperty.create_row_processor. - + StrategizedProperty delegates its create_row_processor method directly to this method. """ @@ -617,7 +617,7 @@ class LoaderStrategy(object): class InstrumentationManager(object): """User-defined class instrumentation extension. - + :class:`.InstrumentationManager` can be subclassed in order to change how class instrumentation proceeds. This class exists for @@ -626,13 +626,13 @@ class InstrumentationManager(object): instrumentation methodology of the ORM, and is not intended for regular usage. For interception of class instrumentation events, see :class:`.InstrumentationEvents`. - + For an example of :class:`.InstrumentationManager`, see the example :ref:`examples_instrumentation`. - + The API for this class should be considered as semi-stable, and may change slightly with new releases. - + """ # r4361 added a mandatory (cls) constructor to this interface. @@ -694,4 +694,3 @@ class InstrumentationManager(object): def dict_getter(self, class_): return lambda inst: self.get_instance_dict(class_, inst) -
\ No newline at end of file |
