当前位置: 首页>>代码示例>>Python>>正文


Python sync.populate函数代码示例

本文整理汇总了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;未经允许,请勿转载。