當前位置: 首頁>>代碼示例>>Python>>正文


Python interfaces.MapperExtension方法代碼示例

本文整理匯總了Python中sqlalchemy.orm.interfaces.MapperExtension方法的典型用法代碼示例。如果您正苦於以下問題:Python interfaces.MapperExtension方法的具體用法?Python interfaces.MapperExtension怎麽用?Python interfaces.MapperExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sqlalchemy.orm.interfaces的用法示例。


在下文中一共展示了interfaces.MapperExtension方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: reconstruct_instance

# 需要導入模塊: from sqlalchemy.orm import interfaces [as 別名]
# 或者: from sqlalchemy.orm.interfaces import MapperExtension [as 別名]
def reconstruct_instance(self, mapper, instance):
        """Receive an object instance after it has been created via
        ``__new__``, and after initial attribute population has
        occurred.

        This typically occurs when the instance is created based on
        incoming result rows, and is only called once for that
        instance's lifetime.

        Note that during a result-row load, this method is called upon
        the first row received for this instance.  Note that some
        attributes and collections may or may not be loaded or even
        initialized, depending on what's present in the result rows.

        The return value is only significant within the ``MapperExtension``
        chain; the parent mapper's behavior isn't modified by this method.

        """
        return EXT_CONTINUE 
開發者ID:jpush,項目名稱:jbox,代碼行數:21,代碼來源:deprecated_interfaces.py

示例2: _adapt_listener_methods

# 需要導入模塊: from sqlalchemy.orm import interfaces [as 別名]
# 或者: from sqlalchemy.orm.interfaces import MapperExtension [as 別名]
def _adapt_listener_methods(cls, self, listener, methods):

        for meth in methods:
            me_meth = getattr(MapperExtension, meth)
            ls_meth = getattr(listener, meth)

            if not util.methods_equivalent(me_meth, ls_meth):
                if meth == 'reconstruct_instance':
                    def go(ls_meth):
                        def reconstruct(instance, ctx):
                            ls_meth(self, instance)
                        return reconstruct
                    event.listen(self.class_manager, 'load',
                                 go(ls_meth), raw=False, propagate=True)
                elif meth == 'init_instance':
                    def go(ls_meth):
                        def init_instance(instance, args, kwargs):
                            ls_meth(self, self.class_,
                                    self.class_manager.original_init,
                                    instance, args, kwargs)
                        return init_instance
                    event.listen(self.class_manager, 'init',
                                 go(ls_meth), raw=False, propagate=True)
                elif meth == 'init_failed':
                    def go(ls_meth):
                        def init_failed(instance, args, kwargs):
                            util.warn_exception(
                                ls_meth, self, self.class_,
                                self.class_manager.original_init,
                                instance, args, kwargs)

                        return init_failed
                    event.listen(self.class_manager, 'init_failure',
                                 go(ls_meth), raw=False, propagate=True)
                else:
                    event.listen(self, "%s" % meth, ls_meth,
                                 raw=False, retval=True, propagate=True) 
開發者ID:jpush,項目名稱:jbox,代碼行數:39,代碼來源:deprecated_interfaces.py

示例3: instrument_class

# 需要導入模塊: from sqlalchemy.orm import interfaces [as 別名]
# 或者: from sqlalchemy.orm.interfaces import MapperExtension [as 別名]
def instrument_class(self, mapper, class_):
        """Receive a class when the mapper is first constructed, and has
        applied instrumentation to the mapped class.

        The return value is only significant within the ``MapperExtension``
        chain; the parent mapper's behavior isn't modified by this method.

        """
        return EXT_CONTINUE 
開發者ID:jpush,項目名稱:jbox,代碼行數:11,代碼來源:deprecated_interfaces.py

示例4: init_instance

# 需要導入模塊: from sqlalchemy.orm import interfaces [as 別名]
# 或者: from sqlalchemy.orm.interfaces import MapperExtension [as 別名]
def init_instance(self, mapper, class_, oldinit, instance, args, kwargs):
        """Receive an instance when its constructor is called.

        This method is only called during a userland construction of
        an object.  It is not called when an object is loaded from the
        database.

        The return value is only significant within the ``MapperExtension``
        chain; the parent mapper's behavior isn't modified by this method.

        """
        return EXT_CONTINUE 
開發者ID:jpush,項目名稱:jbox,代碼行數:14,代碼來源:deprecated_interfaces.py

示例5: init_failed

# 需要導入模塊: from sqlalchemy.orm import interfaces [as 別名]
# 或者: from sqlalchemy.orm.interfaces import MapperExtension [as 別名]
def init_failed(self, mapper, class_, oldinit, instance, args, kwargs):
        """Receive an instance when its constructor has been called,
        and raised an exception.

        This method is only called during a userland construction of
        an object.  It is not called when an object is loaded from the
        database.

        The return value is only significant within the ``MapperExtension``
        chain; the parent mapper's behavior isn't modified by this method.

        """
        return EXT_CONTINUE 
開發者ID:jpush,項目名稱:jbox,代碼行數:15,代碼來源:deprecated_interfaces.py

示例6: after_insert

# 需要導入模塊: from sqlalchemy.orm import interfaces [as 別名]
# 或者: from sqlalchemy.orm.interfaces import MapperExtension [as 別名]
def after_insert(self, mapper, connection, instance):
        """Receive an object instance after that instance is inserted.

        The return value is only significant within the ``MapperExtension``
        chain; the parent mapper's behavior isn't modified by this method.

        """

        return EXT_CONTINUE 
開發者ID:jpush,項目名稱:jbox,代碼行數:11,代碼來源:deprecated_interfaces.py

示例7: before_update

# 需要導入模塊: from sqlalchemy.orm import interfaces [as 別名]
# 或者: from sqlalchemy.orm.interfaces import MapperExtension [as 別名]
def before_update(self, mapper, connection, instance):
        """Receive an object instance before that instance is updated.

        Note that this method is called for all instances that are marked as
        "dirty", even those which have no net changes to their column-based
        attributes. An object is marked as dirty when any of its column-based
        attributes have a "set attribute" operation called or when any of its
        collections are modified. If, at update time, no column-based
        attributes have any net changes, no UPDATE statement will be issued.
        This means that an instance being sent to before_update is *not* a
        guarantee that an UPDATE statement will be issued (although you can
        affect the outcome here).

        To detect if the column-based attributes on the object have net
        changes, and will therefore generate an UPDATE statement, use
        ``object_session(instance).is_modified(instance,
        include_collections=False)``.

        Column-based attributes can be modified within this method
        which will result in the new value being updated.  However
        *no* changes to the overall flush plan can be made, and
        manipulation of the ``Session`` will not have the desired effect.
        To manipulate the ``Session`` within an extension, use
        ``SessionExtension``.

        The return value is only significant within the ``MapperExtension``
        chain; the parent mapper's behavior isn't modified by this method.

        """

        return EXT_CONTINUE 
開發者ID:jpush,項目名稱:jbox,代碼行數:33,代碼來源:deprecated_interfaces.py

示例8: after_update

# 需要導入模塊: from sqlalchemy.orm import interfaces [as 別名]
# 或者: from sqlalchemy.orm.interfaces import MapperExtension [as 別名]
def after_update(self, mapper, connection, instance):
        """Receive an object instance after that instance is updated.

        The return value is only significant within the ``MapperExtension``
        chain; the parent mapper's behavior isn't modified by this method.

        """

        return EXT_CONTINUE 
開發者ID:jpush,項目名稱:jbox,代碼行數:11,代碼來源:deprecated_interfaces.py

示例9: before_delete

# 需要導入模塊: from sqlalchemy.orm import interfaces [as 別名]
# 或者: from sqlalchemy.orm.interfaces import MapperExtension [as 別名]
def before_delete(self, mapper, connection, instance):
        """Receive an object instance before that instance is deleted.

        Note that *no* changes to the overall flush plan can be made
        here; and manipulation of the ``Session`` will not have the
        desired effect. To manipulate the ``Session`` within an
        extension, use ``SessionExtension``.

        The return value is only significant within the ``MapperExtension``
        chain; the parent mapper's behavior isn't modified by this method.

        """

        return EXT_CONTINUE 
開發者ID:jpush,項目名稱:jbox,代碼行數:16,代碼來源:deprecated_interfaces.py

示例10: after_delete

# 需要導入模塊: from sqlalchemy.orm import interfaces [as 別名]
# 或者: from sqlalchemy.orm.interfaces import MapperExtension [as 別名]
def after_delete(self, mapper, connection, instance):
        """Receive an object instance after that instance is deleted.

        The return value is only significant within the ``MapperExtension``
        chain; the parent mapper's behavior isn't modified by this method.

        """

        return EXT_CONTINUE 
開發者ID:jpush,項目名稱:jbox,代碼行數:11,代碼來源:deprecated_interfaces.py


注:本文中的sqlalchemy.orm.interfaces.MapperExtension方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。