• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sync.populate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sqlalchemy.orm.sync.populate函数的典型用法代码示例。如果您正苦于以下问题:Python populate函数的具体用法?Python populate怎么用?Python populate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了populate函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _postfetch

def _postfetch(mapper, uowtransaction, table, 
                state, dict_, prefetch_cols, postfetch_cols,
                            params, value_params):
    """Expire attributes in need of newly persisted database state,
    after an INSERT or UPDATE statement has proceeded for that
    state."""

    if mapper.version_id_col is not None:
        prefetch_cols = list(prefetch_cols) + [mapper.version_id_col]

    for c in prefetch_cols:
        if c.key in params and c in mapper._columntoproperty:
            mapper._set_state_attr_by_column(state, dict_, c, params[c.key])

    if postfetch_cols:
        state.expire_attributes(state.dict, 
                            [mapper._columntoproperty[c].key 
                            for c in postfetch_cols if c in 
                            mapper._columntoproperty]
                        )

    # synchronize newly inserted ids from one table to the next
    # TODO: this still goes a little too often.  would be nice to
    # have definitive list of "columns that changed" here
    for m, equated_pairs in mapper._table_to_equated[table]:
        sync.populate(state, m, state, m, 
                                        equated_pairs, 
                                        uowtransaction,
                                        mapper.passive_updates)
开发者ID:barraemme,项目名称:ankiqml,代码行数:29,代码来源:persistence.py


示例2: test_populate_flag_cascaded

 def test_populate_flag_cascaded(self):
     uowcommit, a1, b1, a_mapper, b_mapper = self._fixture()
     pairs = [(a_mapper.c.id, b_mapper.c.id)]
     a1.obj().id = 7
     assert 'id' not in b1.obj().__dict__
     sync.populate(a1, a_mapper, b1, b_mapper, pairs, uowcommit, True)
     eq_(b1.obj().id, 7)
     eq_(b1.obj().__dict__['id'], 7)
     eq_(uowcommit.attributes[("pk_cascaded", b1, b_mapper.c.id)], True)
开发者ID:chatch,项目名称:pinyin-toolkit,代码行数:9,代码来源:test_sync.py


示例3: _synchronize

    def _synchronize(self, state, child, associationrow, clearkeys, uowcommit):
        if state is None or (not self.post_update and uowcommit.is_deleted(state)):
            return

        if clearkeys or child is None:
            sync.clear(state, self.parent, self.prop.synchronize_pairs)
        else:
            self._verify_canload(child)
            sync.populate(child, self.mapper, state, self.parent, self.prop.synchronize_pairs)
开发者ID:GunioRobot,项目名称:xsbs,代码行数:9,代码来源:dependency.py


示例4: _process_key_switches

 def _process_key_switches(self, deplist, uowcommit):
     switchers = set(s for s in deplist if self._pks_changed(uowcommit, s))
     if switchers:
         # yes, we're doing a linear search right now through the UOW.  only
         # takes effect when primary key values have actually changed.
         # a possible optimization might be to enhance the "hasparents" capability of
         # attributes to actually store all parent references, but this introduces
         # more complicated attribute accounting.
         for s in [elem for elem in uowcommit.session.identity_map.all_states()
             if issubclass(elem.class_, self.parent.class_) and
                 self.key in elem.dict and
                 elem.dict[self.key] is not None and 
                 attributes.instance_state(elem.dict[self.key]) in switchers
             ]:
             uowcommit.register_object(s)
             sync.populate(attributes.instance_state(s.dict[self.key]), self.mapper, s, self.parent, self.prop.synchronize_pairs)
开发者ID:GunioRobot,项目名称:xsbs,代码行数:16,代码来源:dependency.py


示例5: _process_key_switches

 def _process_key_switches(self, deplist, uowcommit):
     switchers = self._key_switchers(uowcommit, deplist)
     if switchers:
         # if primary key values have actually changed somewhere, perform
         # a linear search through the UOW in search of a parent.
         for state in uowcommit.session.identity_map.all_states():
             if not issubclass(state.class_, self.parent.class_):
                 continue
             dict_ = state.dict
             related = state.get_impl(self.key).get(state, dict_,
                     passive=self._passive_update_flag)
             if related is not attributes.PASSIVE_NO_RESULT and \
                 related is not None:
                 related_state = attributes.instance_state(dict_[self.key])
                 if related_state in switchers:
                     uowcommit.register_object(state, 
                                                 False, 
                                                 self.passive_updates)
                     sync.populate(
                                 related_state, 
                                 self.mapper, state, 
                                 self.parent, self.prop.synchronize_pairs, 
                                 uowcommit, self.passive_updates)
开发者ID:BeegorMif,项目名称:maraschino,代码行数:23,代码来源:dependency.py


示例6: _process_key_switches

 def _process_key_switches(self, deplist, uowcommit):
     switchers = self._key_switchers(uowcommit, deplist)
     if switchers:
         # if primary key values have actually changed somewhere, perform
         # a linear search through the UOW in search of a parent.
         # note that this handler isn't used if the many-to-one 
         # relationship has a backref.
         for state in uowcommit.session.identity_map.all_states():
             if not issubclass(state.class_, self.parent.class_):
                 continue
             dict_ = state.dict
             related = dict_.get(self.key)
             if related is not None:
                 related_state = attributes.instance_state(dict_[self.key])
                 if related_state in switchers:
                     uowcommit.register_object(state, 
                                                 False, 
                                                 self.passive_updates)
                     sync.populate(
                                 related_state, 
                                 self.mapper, state, 
                                 self.parent, self.prop.synchronize_pairs, 
                                 uowcommit, self.passive_updates)
开发者ID:advatar,项目名称:thevault,代码行数:23,代码来源:dependency.py


示例7: _synchronize

    def _synchronize(self, state, child, associationrow,
                                        clearkeys, uowcommit, operation=None):
        if state is None or \
            (not self.post_update and uowcommit.is_deleted(state)):
            return

        if operation is not None and \
            child is not None and \
            not uowcommit.session._contains_state(child):
            util.warn(
                "Object of type %s not in session, %s "
                "operation along '%s' won't proceed" % 
                (mapperutil.state_class_str(child), operation, self.prop))
            return

        if clearkeys or child is None:
            sync.clear(state, self.parent, self.prop.synchronize_pairs)
        else:
            self._verify_canload(child)
            sync.populate(child, self.mapper, state, 
                            self.parent, 
                            self.prop.synchronize_pairs, 
                            uowcommit,
                            False) 
开发者ID:BeegorMif,项目名称:maraschino,代码行数:24,代码来源:dependency.py



注:本文中的sqlalchemy.orm.sync.populate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sync.source_modified函数代码示例发布时间:2022-05-27
下一篇:
Python session.Session类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap