]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Added EXT_CONTINUE and EXT_STOP for MapperExtensions; EXT_PASS is a synonym for EXT_C...
authorJason Kirtland <jek@discorporate.us>
Wed, 1 Aug 2007 07:18:50 +0000 (07:18 +0000)
committerJason Kirtland <jek@discorporate.us>
Wed, 1 Aug 2007 07:18:50 +0000 (07:18 +0000)
Repointed docs and examples to EXT_CONTINUE

12 files changed:
doc/build/content/adv_datamapping.txt
doc/build/content/plugins.txt
examples/pickle/custom_pickler.py
lib/sqlalchemy/ext/selectresults.py
lib/sqlalchemy/ext/sessioncontext.py
lib/sqlalchemy/orm/__init__.py
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/orm/query.py
lib/sqlalchemy/orm/util.py
test/orm/generative.py
test/orm/mapper.py

index 12141bb80a0002a2c4c1fd30f61d6f27ffa917a2..dd5f2795acd74596deec8f8d763964412174dfa3 100644 (file)
@@ -944,24 +944,39 @@ performing queries.
 
 ### Extending Mapper {@name=extending}
 
-Mappers can have functionality augmented or replaced at many points in its execution via the usage of the MapperExtension class.  This class is just a series of "hooks" where various functionality takes place.  An application can make its own MapperExtension objects, overriding only the methods it needs.  Methods that are not overridden return the special value `sqlalchemy.orm.mapper.EXT_PASS`, which indicates the operation should proceed as normally.
+Mappers can have functionality augmented or replaced at many points in its execution via the usage of the MapperExtension class.  This class is just a series of "hooks" where various functionality takes place.  An application can make its own MapperExtension objects, overriding only the methods it needs.  Methods that are not overridden return the special value `sqlalchemy.orm.EXT_CONTINUE` to allow processing to continue to the next MapperExtension or simply proceed normally if there are no more extensions.
 
     {python}
     class MapperExtension(object):
-        """base implementation for an object that provides overriding behavior to various
-        Mapper functions.  For each method in MapperExtension, a result of EXT_PASS indicates
-        the functionality is not overridden."""
+        """Base implementation for customizing Mapper behavior.
+
+        For each method in MapperExtension, returning a result of
+        EXT_CONTINUE will allow processing to continue to the next
+        MapperExtension in line or use the default functionality if there
+        are no other extensions.
+
+        Returning EXT_STOP will halt processing of further extensions
+        handling that method.  Some methods such as ``load`` have other
+        return requirements, see the individual documentation for details.
+        Other than these exception cases, any return value other than
+        EXT_CONTINUE or EXT_STOP will be interpreted as equivalent to
+        EXT_STOP.
+    
+        EXT_PASS is a synonym for EXT_CONTINUE and is provided for
+        backward compatibility.
+        """
+
         def get_session(self):
             """called to retrieve a contextual Session instance with which to
             register a new object. Note: this is not called if a session is 
             provided with the __init__ params (i.e. _sa_session)"""
-            return EXT_PASS
+            return EXT_CONTINUE
         def select_by(self, query, *args, **kwargs):
             """overrides the select_by method of the Query object"""
-            return EXT_PASS
+            return EXT_CONTINUE
         def select(self, query, *args, **kwargs):
             """overrides the select method of the Query object"""
-            return EXT_PASS
+            return EXT_CONTINUE
         def create_instance(self, mapper, selectcontext, row, class_):
             """called when a new object instance is about to be created from a row.  
             the method can choose to create the instance itself, or it can return 
@@ -975,11 +990,11 @@ Mappers can have functionality augmented or replaced at many points in its execu
 
             class_ - the class we are mapping.
             """
-            return EXT_PASS
+            return EXT_CONTINUE
         def append_result(self, mapper, selectcontext, row, instance, identitykey, result, isnew):
             """called when an object instance is being appended to a result list.
 
-            If this method returns EXT_PASS, it is assumed that the mapper should do the appending, else
+            If this method returns EXT_CONTINUE, it is assumed that the mapper should do the appending, else
             if this method returns any other value or None, it is assumed that the append was handled by this method.
 
             mapper - the mapper doing the operation
@@ -998,11 +1013,11 @@ Mappers can have functionality augmented or replaced at many points in its execu
             set.  if you are selecting from a join, such as an eager load, you might see the same object instance
             many times in the same result set.
             """
-            return EXT_PASS
+            return EXT_CONTINUE
         def populate_instance(self, mapper, selectcontext, row, instance, identitykey, isnew):
             """called right before the mapper, after creating an instance from a row, passes the row
             to its MapperProperty objects which are responsible for populating the object's attributes.
-            If this method returns EXT_PASS, it is assumed that the mapper should do the appending, else
+            If this method returns EXT_CONTINUE, it is assumed that the mapper should do the appending, else
             if this method returns any other value or None, it is assumed that the append was handled by this method.
 
             Essentially, this method is used to have a different mapper populate the object:
@@ -1011,27 +1026,27 @@ Mappers can have functionality augmented or replaced at many points in its execu
                     othermapper.populate_instance(selectcontext, instance, row, identitykey, isnew, frommapper=mapper)
                     return True
             """
-            return EXT_PASS
+            return EXT_CONTINUE
         def before_insert(self, mapper, connection, instance):
             """called before an object instance is INSERTed into its table.
 
             this is a good place to set up primary key values and such that arent handled otherwise."""
-            return EXT_PASS
+            return EXT_CONTINUE
         def before_update(self, mapper, connection, instance):
             """called before an object instance is UPDATED"""
-            return EXT_PASS
+            return EXT_CONTINUE
         def after_update(self, mapper, connection, instance):
             """called after an object instance is UPDATED"""
-            return EXT_PASS
+            return EXT_CONTINUE
         def after_insert(self, mapper, connection, instance):
             """called after an object instance has been INSERTed"""
-            return EXT_PASS
+            return EXT_CONTINUE
         def before_delete(self, mapper, connection, instance):
             """called before an object instance is DELETEed"""
-            return EXT_PASS
+            return EXT_CONTINUE
         def after_delete(self, mapper, connection, instance):
             """called after an object instance is DELETEed"""
-            return EXT_PASS        
+            return EXT_CONTINUE        
 To use MapperExtension, make your own subclass of it and just send it off to a mapper:
 
     {python}
index dbc85a6f99e9a89acb86e631ad8ac4644d69a0a4..81229247e9e268040840b16f3b9d1718db70f738 100644 (file)
@@ -161,7 +161,7 @@ The decoration of mapped instances' `__init__()` method is similar to this examp
         entity_name = kwargs.pop('_sa_entity_name', None)
         if session is None:
             session = ext.get_session() # get Session from this Mapper's MapperExtension
-            if session is EXT_PASS:
+            if session is EXT_CONTINUE:
                 session = None
         if session is not None:
             session.save(self, entity_name=entity_name)  # attach to the current session
index b45e16e7c659c6a001629357604621ffbfd74fc7..0a32bfd03ac30beb2661bce33a458aaa8cdf0283 100644 (file)
@@ -1,6 +1,7 @@
 """illustrates one way to use a custom pickler that is session-aware."""
 
 from sqlalchemy import *
+from sqlalchemy.orm import *
 from sqlalchemy.orm.session import object_session
 from cStringIO import StringIO
 from pickle import Pickler, Unpickler
@@ -12,13 +13,13 @@ meta.bind.echo = True
 class MyExt(MapperExtension):
     def populate_instance(self, mapper, selectcontext, row, instance, identitykey, isnew):
         MyPickler.sessions.current = selectcontext.session
-        return EXT_PASS
+        return EXT_CONTINUE
     def before_insert(self, mapper, connection, instance):
         MyPickler.sessions.current = object_session(instance)
-        return EXT_PASS
+        return EXT_CONTINUE
     def before_update(self, mapper, connection, instance):
         MyPickler.sessions.current = object_session(instance)
-        return EXT_PASS
+        return EXT_CONTINUE
     
 class MyPickler(object):
     sessions = threading.local()
index 1920b6f924a7b0f0d5b054caf9e57c943dd562e5..44622825428b54c4a5b2c149d06f4b86edd3c835 100644 (file)
@@ -15,7 +15,7 @@ class SelectResultsExt(orm.MapperExtension):
         
     def select(self, query, arg=None, **kwargs):
         if isinstance(arg, sql.FromClause) and arg.supports_execution():
-            return orm.EXT_PASS
+            return orm.EXT_CONTINUE
         else:
             if arg is not None:
                 query = query.filter(arg)
index fcbf29c3ff68d91fe34dd2034e2a8ec25cc28d40..91c03d3c3b5e6128def07a2de11e5fadf5b23602 100644 (file)
@@ -1,5 +1,5 @@
 from sqlalchemy.util import ScopedRegistry
-from sqlalchemy.orm import create_session, object_session, MapperExtension, EXT_PASS
+from sqlalchemy.orm import create_session, object_session, MapperExtension, EXT_CONTINUE
 
 __all__ = ['SessionContext', 'SessionContextExt']
 
@@ -66,11 +66,11 @@ class SessionContextExt(MapperExtension):
     def init_instance(self, mapper, class_, instance, args, kwargs):
         session = kwargs.pop('_sa_session', self.context.current)
         session._save_impl(instance, entity_name=kwargs.pop('_sa_entity_name', None))
-        return EXT_PASS
+        return EXT_CONTINUE
 
     def init_failed(self, mapper, class_, instance, args, kwargs):
         object_session(instance).expunge(instance)
-        return EXT_PASS
+        return EXT_CONTINUE
         
     def dispose_class(self, mapper, class_):
         if hasattr(class_, '__init__') and hasattr(class_.__init__, '_oldinit'):
index 66c4d796e695db23ba8756f852e29789e48b1609..3c221bb66bf1cfcccb7683444cf4d471dc0273b7 100644 (file)
@@ -5,14 +5,15 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 """
-The mapper package provides object-relational functionality, building upon the schema and sql
-packages and tying operations to class properties and constructors.
+The mapper package provides object-relational functionality, building upon
+the schema and sql packages and tying operations to class properties and
+constructors.
 """
 
 from sqlalchemy import exceptions
 from sqlalchemy import util as sautil
 from sqlalchemy.orm.mapper import Mapper, object_mapper, class_mapper, mapper_registry
-from sqlalchemy.orm.interfaces import SynonymProperty, MapperExtension, EXT_PASS, ExtensionOption, PropComparator
+from sqlalchemy.orm.interfaces import SynonymProperty, MapperExtension, EXT_CONTINUE, EXT_STOP, EXT_PASS, ExtensionOption, PropComparator
 from sqlalchemy.orm.properties import PropertyLoader, ColumnProperty, CompositeProperty, BackRef
 from sqlalchemy.orm import mapper as mapperlib
 from sqlalchemy.orm import collections, strategies
@@ -21,14 +22,15 @@ from sqlalchemy.orm.util import polymorphic_union
 from sqlalchemy.orm.session import Session as _Session
 from sqlalchemy.orm.session import object_session, attribute_manager
 
-__all__ = ['relation', 'column_property', 'composite', 'backref', 'eagerload',
-           'eagerload_all', 'lazyload', 'noload', 'deferred', 'defer', 'undefer',
-           'undefer_group', 'extension', 'mapper', 'clear_mappers',
-           'compile_mappers', 'class_mapper', 'object_mapper', 'dynamic_loader',
-           'MapperExtension', 'Query', 'polymorphic_union', 'create_session','Session',
-           'synonym', 'contains_alias', 'contains_eager', 'EXT_PASS',
-           'object_session', 'PropComparator'
-           ]
+__all__ = [ 'relation', 'column_property', 'composite', 'backref', 'eagerload',
+            'eagerload_all', 'lazyload', 'noload', 'deferred', 'defer',
+            'undefer', 'undefer_group', 'extension', 'mapper', 'clear_mappers',
+            'compile_mappers', 'class_mapper', 'object_mapper',
+            'dynamic_loader', 'MapperExtension', 'Query', 'polymorphic_union',
+            'create_session', 'Session', 'synonym', 'contains_alias',
+            'contains_eager', 'EXT_CONTINUE', 'EXT_STOP', 'EXT_PASS',
+            'object_session', 'PropComparator' ]
+
 
 def create_session(bind=None, **kwargs):
     """create a new version 0.3-style [sqlalchemy.orm.session#Session].
index eba8384c6b0a09305de02869b682014c983bb75a..271846ca80976bbbb09961f4529d8fbe12ee76d7 100644 (file)
@@ -7,22 +7,39 @@
 
 from sqlalchemy import util, logging, sql
 
-# returned by a MapperExtension method to indicate a "do nothing" response
-EXT_PASS = object()
+__all__ = ['EXT_CONTINUE', 'EXT_STOP', 'EXT_PASS', 'MapperExtension',
+           'MapperProperty', 'PropComparator', 'StrategizedProperty', 
+           'LoaderStack', 'OperationContext', 'MapperOption', 
+           'ExtensionOption', 'SynonymProperty', 'PropertyOption', 
+           'AttributeExtension', 'StrategizedOption', 'LoaderStrategy' ]
+
+EXT_CONTINUE = EXT_PASS = object()
+EXT_STOP = object()
 
 class MapperExtension(object):
-    """Base implementation for an object that provides overriding
-    behavior to various Mapper functions.  For each method in
-    MapperExtension, a result of EXT_PASS indicates the functionality
-    is not overridden.
+    """Base implementation for customizing Mapper behavior.
+
+    For each method in MapperExtension, returning a result of
+    EXT_CONTINUE will allow processing to continue to the next
+    MapperExtension in line or use the default functionality if there
+    are no other extensions.
+
+    Returning EXT_STOP will halt processing of further extensions
+    handling that method.  Some methods such as ``load`` have other
+    return requirements, see the individual documentation for details.
+    Other than these exception cases, any return value other than
+    EXT_CONTINUE or EXT_STOP will be interpreted as equivalent to
+    EXT_STOP.
+    
+    EXT_PASS is a synonym for EXT_CONTINUE and is provided for
+    backward compatibility.
     """
 
-
     def init_instance(self, mapper, class_, instance, args, kwargs):
-        return EXT_PASS
+        return EXT_CONTINUE
 
     def init_failed(self, mapper, class_, instance, args, kwargs):
-        return EXT_PASS
+        return EXT_CONTINUE
 
     def get_session(self):
         """Retrieve a contextual Session instance with which to
@@ -32,61 +49,61 @@ class MapperExtension(object):
         `__init__` params (i.e. `_sa_session`).
         """
 
-        return EXT_PASS
+        return EXT_CONTINUE
 
     def load(self, query, *args, **kwargs):
         """Override the `load` method of the Query object.
 
         The return value of this method is used as the result of
-        ``query.load()`` if the value is anything other than EXT_PASS.
+        ``query.load()`` if the value is anything other than EXT_CONTINUE.
         """
 
-        return EXT_PASS
+        return EXT_CONTINUE
 
     def get(self, query, *args, **kwargs):
         """Override the `get` method of the Query object.
 
         The return value of this method is used as the result of
-        ``query.get()`` if the value is anything other than EXT_PASS.
+        ``query.get()`` if the value is anything other than EXT_CONTINUE.
         """
 
-        return EXT_PASS
+        return EXT_CONTINUE
 
     def get_by(self, query, *args, **kwargs):
         """Override the `get_by` method of the Query object.
 
         The return value of this method is used as the result of
         ``query.get_by()`` if the value is anything other than
-        EXT_PASS.
+        EXT_CONTINUE.
         
         DEPRECATED.
         """
 
-        return EXT_PASS
+        return EXT_CONTINUE
 
     def select_by(self, query, *args, **kwargs):
         """Override the `select_by` method of the Query object.
 
         The return value of this method is used as the result of
         ``query.select_by()`` if the value is anything other than
-        EXT_PASS.
+        EXT_CONTINUE.
         
         DEPRECATED.
         """
 
-        return EXT_PASS
+        return EXT_CONTINUE
 
     def select(self, query, *args, **kwargs):
         """Override the `select` method of the Query object.
 
         The return value of this method is used as the result of
         ``query.select()`` if the value is anything other than
-        EXT_PASS.
+        EXT_CONTINUE.
         
         DEPRECATED.
         """
 
-        return EXT_PASS
+        return EXT_CONTINUE
 
 
     def translate_row(self, mapper, context, row):
@@ -97,7 +114,7 @@ class MapperExtension(object):
         method.
         """
 
-        return EXT_PASS
+        return EXT_CONTINUE
 
     def create_instance(self, mapper, selectcontext, row, class_):
         """Receive a row when a new object instance is about to be
@@ -120,13 +137,13 @@ class MapperExtension(object):
           The class we are mapping.
         """
 
-        return EXT_PASS
+        return EXT_CONTINUE
 
     def append_result(self, mapper, selectcontext, row, instance, result, **flags):
         """Receive an object instance before that instance is appended
         to a result list.
 
-        If this method returns EXT_PASS, result appending will proceed
+        If this method returns EXT_CONTINUE, result appending will proceed
         normally.  if this method returns any other value or None,
         result appending will not proceed for this instance, giving
         this extension an opportunity to do the appending itself, if
@@ -152,7 +169,7 @@ class MapperExtension(object):
           `create_row_processor()` method of [sqlalchemy.orm.interfaces#MapperProperty]
         """
 
-        return EXT_PASS
+        return EXT_CONTINUE
 
     def populate_instance(self, mapper, selectcontext, row, instance, **flags):
         """Receive a newly-created instance before that instance has
@@ -161,14 +178,14 @@ class MapperExtension(object):
         The normal population of attributes is according to each
         attribute's corresponding MapperProperty (which includes
         column-based attributes as well as relationships to other
-        classes).  If this method returns EXT_PASS, instance
+        classes).  If this method returns EXT_CONTINUE, instance
         population will proceed normally.  If any other value or None
         is returned, instance population will not proceed, giving this
         extension an opportunity to populate the instance itself, if
         desired.
         """
 
-        return EXT_PASS
+        return EXT_CONTINUE
 
     def before_insert(self, mapper, connection, instance):
         """Receive an object instance before that instance is INSERTed
@@ -178,32 +195,32 @@ class MapperExtension(object):
         that aren't handled otherwise.
         """
 
-        return EXT_PASS
+        return EXT_CONTINUE
+
+    def after_insert(self, mapper, connection, instance):
+        """Receive an object instance after that instance is INSERTed."""
+
+        return EXT_CONTINUE
 
     def before_update(self, mapper, connection, instance):
         """Receive an object instance before that instance is UPDATEed."""
 
-        return EXT_PASS
+        return EXT_CONTINUE
 
     def after_update(self, mapper, connection, instance):
         """Receive an object instance after that instance is UPDATEed."""
 
-        return EXT_PASS
-
-    def after_insert(self, mapper, connection, instance):
-        """Receive an object instance after that instance is INSERTed."""
-
-        return EXT_PASS
+        return EXT_CONTINUE
 
     def before_delete(self, mapper, connection, instance):
         """Receive an object instance before that instance is DELETEed."""
 
-        return EXT_PASS
+        return EXT_CONTINUE
 
     def after_delete(self, mapper, connection, instance):
         """Receive an object instance after that instance is DELETEed."""
 
-        return EXT_PASS
+        return EXT_CONTINUE
 
 class MapperProperty(object):
     """Manage the relationship of a ``Mapper`` to a single class
index 6706b07e47cd3478b6126af9498da1d2ad523c61..3560a1c59ada6849817f46963d7df18a8d9772c4 100644 (file)
@@ -9,7 +9,7 @@ from sqlalchemy import sql_util as sqlutil
 from sqlalchemy.orm import util as mapperutil
 from sqlalchemy.orm.util import ExtensionCarrier
 from sqlalchemy.orm import sync
-from sqlalchemy.orm.interfaces import MapperProperty, EXT_PASS, MapperExtension, SynonymProperty
+from sqlalchemy.orm.interfaces import MapperProperty, EXT_CONTINUE, MapperExtension, SynonymProperty
 import weakref, warnings, operator
 
 __all__ = ['Mapper', 'class_mapper', 'object_mapper', 'mapper_registry']
@@ -876,7 +876,7 @@ class Mapper(object):
 
         self.compile()
         s = self.extension.get_session()
-        if s is EXT_PASS:
+        if s is EXT_CONTINUE:
             raise exceptions.InvalidRequestError("No contextual Session is established.  Use a MapperExtension that implements get_session or use 'import sqlalchemy.mods.threadlocal' to establish a default thread-local contextual session.")
         return s
 
@@ -1373,7 +1373,7 @@ class Mapper(object):
             extension = self.extension
 
         ret = extension.translate_row(self, context, row)
-        if ret is not EXT_PASS:
+        if ret is not EXT_CONTINUE:
             row = ret
 
         if not skip_polymorphic and self.polymorphic_on is not None:
@@ -1404,9 +1404,9 @@ class Mapper(object):
                 if not context.identity_map.has_key(identitykey):
                     context.identity_map[identitykey] = instance
                     isnew = True
-                if extension.populate_instance(self, context, row, instance, **{'instancekey':identitykey, 'isnew':isnew}) is EXT_PASS:
+                if extension.populate_instance(self, context, row, instance, **{'instancekey':identitykey, 'isnew':isnew}) is EXT_CONTINUE:
                     self.populate_instance(context, instance, row, **{'instancekey':identitykey, 'isnew':isnew})
-            if extension.append_result(self, context, row, instance, result, **{'instancekey':identitykey, 'isnew':isnew}) is EXT_PASS:
+            if extension.append_result(self, context, row, instance, result, **{'instancekey':identitykey, 'isnew':isnew}) is EXT_CONTINUE:
                 if result is not None:
                     result.append(instance)
             return instance
@@ -1432,7 +1432,7 @@ class Mapper(object):
 
             # plugin point
             instance = extension.create_instance(self, context, row, self.class_)
-            if instance is EXT_PASS:
+            if instance is EXT_CONTINUE:
                 instance = self._create_instance(context.session)
             else:
                 instance._entity_name = self.entity_name
@@ -1447,9 +1447,9 @@ class Mapper(object):
         # call further mapper properties on the row, to pull further
         # instances from the row and possibly populate this item.
         flags = {'instancekey':identitykey, 'isnew':isnew}
-        if extension.populate_instance(self, context, row, instance, **flags) is EXT_PASS:
+        if extension.populate_instance(self, context, row, instance, **flags) is EXT_CONTINUE:
             self.populate_instance(context, instance, row, **flags)
-        if extension.append_result(self, context, row, instance, result, **flags) is EXT_PASS:
+        if extension.append_result(self, context, row, instance, result, **flags) is EXT_CONTINUE:
             if result is not None:
                 result.append(instance)
         return instance
index 1b5871858fa3545c49193f57c1dfc5bdc775155c..6d7e55af350d46790d44dd12728a6b5a48af2ab6 100644 (file)
@@ -70,7 +70,7 @@ class Query(object):
         """
 
         ret = self._extension.get(self, ident, **kwargs)
-        if ret is not mapper.EXT_PASS:
+        if ret is not mapper.EXT_CONTINUE:
             return ret
 
         # convert composite types to individual args
@@ -94,7 +94,7 @@ class Query(object):
         """
 
         ret = self._extension.load(self, ident, **kwargs)
-        if ret is not mapper.EXT_PASS:
+        if ret is not mapper.EXT_CONTINUE:
             return ret
         key = self.mapper.identity_key_from_primary_key(ident)
         instance = self._get(key, ident, reload=True, **kwargs)
@@ -993,7 +993,7 @@ class Query(object):
         """DEPRECATED.  use query.filter_by(\**params).first()"""
 
         ret = self._extension.get_by(self, *args, **params)
-        if ret is not mapper.EXT_PASS:
+        if ret is not mapper.EXT_CONTINUE:
             return ret
 
         return self._legacy_filter_by(*args, **params).first()
@@ -1002,7 +1002,7 @@ class Query(object):
         """DEPRECATED. use use query.filter_by(\**params).all()."""
 
         ret = self._extension.select_by(self, *args, **params)
-        if ret is not mapper.EXT_PASS:
+        if ret is not mapper.EXT_CONTINUE:
             return ret
 
         return self._legacy_filter_by(*args, **params).list()
@@ -1032,7 +1032,7 @@ class Query(object):
         """DEPRECATED.  use query.filter(whereclause).all(), or query.from_statement(statement).all()"""
 
         ret = self._extension.select(self, arg=arg, **kwargs)
-        if ret is not mapper.EXT_PASS:
+        if ret is not mapper.EXT_CONTINUE:
             return ret
         return self._build_select(arg, **kwargs).all()
 
index d248c0dd01569027438406effa3a54a4fd7cb24c..6a9c4164fa3d20f4c33d0ded9432631e9d52db7e 100644 (file)
@@ -5,7 +5,7 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 from sqlalchemy import sql, util, exceptions, sql_util
-from sqlalchemy.orm.interfaces import MapperExtension, EXT_PASS
+from sqlalchemy.orm.interfaces import MapperExtension, EXT_CONTINUE
 
 all_cascades = util.Set(["delete", "delete-orphan", "all", "merge",
                          "expunge", "save-update", "refresh-expire", "none"])
@@ -134,10 +134,10 @@ class ExtensionCarrier(MapperExtension):
         def _do(self, *args, **kwargs):
             for elem in self.__elements:
                 ret = getattr(elem, funcname)(*args, **kwargs)
-                if ret is not EXT_PASS:
+                if ret is not EXT_CONTINUE:
                     return ret
             else:
-                return EXT_PASS
+                return EXT_CONTINUE
         return _do
 
     init_instance = _create_do('init_instance')
index 4a90c13cb1e7e8c63250e4e6008e7b8f3793bf16..c850069ab63e5dc61cfb0fbb3345adfb43a66aa2 100644 (file)
@@ -103,7 +103,7 @@ class GenerativeQueryTest(PersistTest):
         class ext1(MapperExtension):
             def populate_instance(self, mapper, selectcontext, row, instance, **flags):
                 instance.TEST = "hello world"
-                return EXT_PASS
+                return EXT_CONTINUE
         assert query.options(extension(ext1()))[0].TEST == "hello world"
         
     def test_order_by(self):
index 5bb33b2415263d8eacf1350e06305bb854c3fc50..58f0f8411d08705ac2c28ec47082c372baffb600 100644 (file)
@@ -451,7 +451,7 @@ class MapperTest(MapperSuperTest):
             def populate_instance(self, mapper, selectcontext, row, instance, **flags):
                 """test options at the Mapper._instance level"""
                 instance.TEST = "hello world"
-                return EXT_PASS
+                return EXT_CONTINUE
         mapper(User, users, extension=ext1(), properties={
             'addresses':relation(mapper(Address, addresses), lazy=False)
         })
@@ -462,7 +462,7 @@ class MapperTest(MapperSuperTest):
             def populate_instance(self, mapper, selectcontext, row, instance, **flags):
                 """test options at the Mapper._instance level"""
                 instance.TEST_2 = "also hello world"
-                return EXT_PASS
+                return EXT_CONTINUE
         l = sess.query(User).options(extension(testext())).select_by(x=5)
         assert l == "HI"
         l = sess.query(User).options(extension(testext())).get(7)