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


Python interfaces.SessionExtension方法代碼示例

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


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

示例1: before_insert

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

        This is a good place to set up primary key values and such
        that aren't handled otherwise.

        Column-based attributes can be modified within this method
        which will result in the new value being inserted.  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,代碼行數:22,代碼來源:deprecated_interfaces.py

示例2: _adapt_listener

# 需要導入模塊: from sqlalchemy.orm import interfaces [as 別名]
# 或者: from sqlalchemy.orm.interfaces import SessionExtension [as 別名]
def _adapt_listener(cls, self, listener):
        for meth in [
            'before_commit',
            'after_commit',
            'after_rollback',
            'before_flush',
            'after_flush',
            'after_flush_postexec',
            'after_begin',
            'after_attach',
            'after_bulk_update',
            'after_bulk_delete',
        ]:
            me_meth = getattr(SessionExtension, meth)
            ls_meth = getattr(listener, meth)

            if not util.methods_equivalent(me_meth, ls_meth):
                event.listen(self, meth, getattr(listener, meth)) 
開發者ID:jpush,項目名稱:jbox,代碼行數:20,代碼來源:deprecated_interfaces.py

示例3: before_update

# 需要導入模塊: from sqlalchemy.orm import interfaces [as 別名]
# 或者: from sqlalchemy.orm.interfaces import SessionExtension [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

示例4: before_delete

# 需要導入模塊: from sqlalchemy.orm import interfaces [as 別名]
# 或者: from sqlalchemy.orm.interfaces import SessionExtension [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


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