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

Python info.get_obj_info函数代码示例

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

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



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

示例1: get_where_for_local

    def get_where_for_local(self, other):
        """Generate a column comparison expression for reference properties.

        The returned expression may be used to find objects of the I{local}
        type referring to C{other}.

        It handles the following cases::

            Class.reference == obj
            Class.reference == obj.id
            Class.reference == (obj.id1, obj.id2)

        Where the right-hand side is the C{other} object given.
        """
        try:
            obj_info = get_obj_info(other)
        except ClassInfoError:
            if type(other) is not tuple:
                remote_variables = (other,)
            else:
                remote_variables = other
        else:
            # Don't use other here, as it might be
            # security proxied or something.
            other = get_obj_info(other).get_obj()
            remote_variables = self.get_remote_variables(other)
        return compare_columns(self.local_key, remote_variables)
开发者ID:DamnWidget,项目名称:mamba-storm,代码行数:27,代码来源:references.py


示例2: __set__

    def __set__(self, local, remote):
        # Don't use local here, as it might be security proxied or something.
        local = get_obj_info(local).get_obj()

        if self._cls is None:
            self._cls = _find_descriptor_class(local.__class__, self)

        if remote is None:
            if self._on_remote:
                remote = self.__get__(local)
                if remote is None:
                    return
            else:
                remote = self._relation.get_remote(local)
            if remote is None:
                remote_info = None
            else:
                remote_info = get_obj_info(remote)
            self._relation.unlink(get_obj_info(local), remote_info, True)
        else:
            # Don't use remote here, as it might be
            # security proxied or something.
            try:
                remote = get_obj_info(remote).get_obj()
            except ClassInfoError:
                pass # It might fail when remote is a tuple or a raw value.
            self._relation.link(local, remote, True)
开发者ID:DamnWidget,项目名称:mamba-storm,代码行数:27,代码来源:references.py


示例3: test_set_get_delete_with_wrapper

 def test_set_get_delete_with_wrapper(self):
     obj = self.Class()
     get_obj_info(obj) # Ensure the obj_info exists for obj.
     self.Class.prop1.__set__(Wrapper(obj), 10)
     self.assertEquals(self.Class.prop1.__get__(Wrapper(obj)), 10)
     self.Class.prop1.__delete__(Wrapper(obj))
     self.assertEquals(self.Class.prop1.__get__(Wrapper(obj)), None)
开发者ID:anilbektash,项目名称:storm,代码行数:7,代码来源:properties.py


示例4: test_class_is_collectable

 def test_class_is_collectable(self):
     class Class(Storm):
         __storm_table__ = "table_name"
         prop = Property(primary=True)
     obj = Class()
     get_obj_info(obj) # Build all wanted meta-information.
     obj_ref = weakref.ref(obj)
     del obj
     gc.collect()
     self.assertEquals(obj_ref(), None)
开发者ID:DamnWidget,项目名称:mamba-storm,代码行数:10,代码来源:base.py


示例5: test_adding_similar_obj_infos

 def test_adding_similar_obj_infos(self):
     """If __eq__ is broken, this fails."""
     obj_info1 = get_obj_info(StubClass())
     obj_info2 = get_obj_info(StubClass())
     cache = self.Cache(5)
     cache.add(obj_info1)
     cache.add(obj_info2)
     cache.add(obj_info2)
     cache.add(obj_info1)
     self.assertEquals([hash(obj_info) for obj_info in cache.get_cached()],
                       [hash(obj_info1), hash(obj_info2)])
开发者ID:anilbektash,项目名称:storm,代码行数:11,代码来源:cache.py


示例6: __set__

    def __set__(self, local, remote):
        if self._relation is None:
            # Don't use local.__class__ here, as it might be security
            # proxied or something. # XXX UNTESTED!
            self._build_relation(get_obj_info(local).cls_info.cls)

        if remote is None:
            remote = self._relation.get_remote(local)
            if remote is not None:
                self._relation.unlink(get_obj_info(local), get_obj_info(remote), True)
        else:
            self._relation.link(local, remote, True)
开发者ID:paiser,项目名称:component-management,代码行数:12,代码来源:references.py


示例7: __get__

    def __get__(self, local, cls=None):
        if local is not None:
            # Don't use local here, as it might be security proxied.
            local = get_obj_info(local).get_obj()

        if self._cls is None:
            self._cls = _find_descriptor_class(cls or local.__class__, self)

        if local is None:
            return self

        remote = self._relation.get_remote(local)
        if remote is not None:
            return remote

        if self._relation.local_variables_are_none(local):
            return None

        store = Store.of(local)
        if store is None:
            return None

        if self._relation.remote_key_is_primary:
            remote = store.get(self._relation.remote_cls,
                               self._relation.get_local_variables(local))
        else:
            where = self._relation.get_where_for_remote(local)
            result = store.find(self._relation.remote_cls, where)
            remote = result.one()

        if remote is not None:
            self._relation.link(local, remote)

        return remote
开发者ID:DamnWidget,项目名称:mamba-storm,代码行数:34,代码来源:references.py


示例8: __get__

    def __get__(self, local, cls=None):
        if local is None:
            if self._cls is None:
                # Must set earlier, since __eq__() has no access
                # to the used class.
                self._cls = _find_descriptor_class(cls, self)
            return self

        if self._relation is None:
            # Don't use local.__class__ here, as it might be security
            # proxied or something. # XXX UNTESTED!
            self._build_relation(get_obj_info(local).cls_info.cls)

        remote = self._relation.get_remote(local)
        if remote is not None:
            return remote

        store = Store.of(local)
        if store is None:
            return None

        if self._relation.remote_key_is_primary:
            remote = store.get(self._relation.remote_cls, self._relation.get_local_variables(local))
        else:
            where = self._relation.get_where_for_remote(local)
            result = store.find(self._relation.remote_cls, where)
            remote = result.one()

        if remote is not None:
            self._relation.link(local, remote)

        return remote
开发者ID:paiser,项目名称:component-management,代码行数:32,代码来源:references.py


示例9: local_variables_are_none

 def local_variables_are_none(self, local):
     """Return true if all variables of the local key have None values."""
     local_info = get_obj_info(local)
     for column in self._get_local_columns(local.__class__):
         if local_info.variables[column].get() is not None:
             return False
     return True
开发者ID:DamnWidget,项目名称:mamba-storm,代码行数:7,代码来源:references.py


示例10: _remote_variables

def _remote_variables(relation, obj):
    """A helper function to extract the foreign key values of an object.
    """
    try:
        get_obj_info(obj)
    except ClassInfoError:
        if type(obj) is not tuple:
            remote_variables = (obj,)
        else:
            remote_variables = obj
    else:
        # Don't use other here, as it might be
        # security proxied or something.
        obj = get_obj_info(obj).get_obj()
        remote_variables = relation.get_remote_variables(obj)
    return remote_variables
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:16,代码来源:stormexpr.py


示例11: remove

 def remove(self, remote):
     store = Store.of(self._local)
     if store is None:
         raise NoStoreError("Can't perform operation without a store")
     # Don't use remote here, as it might be security proxied or something.
     remote = get_obj_info(remote).get_obj()
     where = self._relation1.get_where_for_remote(self._local) & self._relation2.get_where_for_remote(remote)
     store.find(self._link_cls, where).remove()
开发者ID:puhep,项目名称:cms-pixel-db-pisa,代码行数:8,代码来源:references.py


示例12: get_remote

    def get_remote(self, local):
        """Return the remote object for this relation, using the local cache.

        If the object in the cache is invalidated, we validate it again to
        check if it's still in the database.
        """
        local_info = get_obj_info(local)
        try:
            obj = local_info[self]["remote"]
        except KeyError:
            return None
        remote_info = get_obj_info(obj)
        if remote_info.get("invalidated"):
            try:
                Store.of(obj)._validate_alive(remote_info)
            except LostObjectError:
                return None
        return obj
开发者ID:DamnWidget,项目名称:mamba-storm,代码行数:18,代码来源:references.py


示例13: remove

    def remove(self, obj):
        """Remove an objet from the store

        The associated row will be deleted from the database.
        """
        # Overwrite store.remove so we can emit our own event for when the
        # object is goin to be deleted (but before anything is actually modified)
        obj_info = get_obj_info(obj)
        obj_info.event.emit("before-removed")
        super(StoqlibStore, self).remove(obj)
开发者ID:rg3915,项目名称:stoq,代码行数:10,代码来源:runtime.py


示例14: event_key

    def event_key(self):
        """See `ILongPollEvent`.

        Constructs the key from the table name and primary key values of the
        Storm model object.
        """
        cls_info = get_obj_info(self.source).cls_info
        return generate_event_key(
            cls_info.table.name.lower(),
            *gen_primary_key(self.source))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:10,代码来源:storm.py


示例15: __get__

 def __get__(self, obj, cls=None):
     if obj is None:
         return self._get_column(cls)
     obj_info = get_obj_info(obj)
     if cls is None:
         # Don't get obj.__class__ because we don't trust it
         # (might be proxied or whatever).
         cls = obj_info.cls_info.cls
     column = self._get_column(cls)
     return obj_info.variables[column].get()
开发者ID:Jokymon,项目名称:timetracker,代码行数:10,代码来源:properties.py


示例16: test_reload

 def test_reload(self):
     # reload() loads the given objects using queries generated by
     # gen_reload_queries().
     db_object = self.factory.makeComponent()
     db_object_naked = proxy.removeSecurityProxy(db_object)
     db_object_info = get_obj_info(db_object_naked)
     IStore(db_object).flush()
     self.failUnlessEqual(None, db_object_info.get('invalidated'))
     IStore(db_object).invalidate(db_object)
     self.failUnlessEqual(True, db_object_info.get('invalidated'))
     bulk.reload([db_object])
     self.failUnlessEqual(None, db_object_info.get('invalidated'))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:12,代码来源:test_bulk.py


示例17: _add_all

    def _add_all(self, obj_info, local_info):
        store = Store.of(obj_info)
        store.add(local_info)
        local_info.event.unhook("added", self._add_all, local_info)

        def add(remote_info):
            remote_info.event.unhook("added", self._add_all, local_info)
            store.add(remote_info)
            self._add_flush_order(local_info, remote_info, remote_first=(not self.on_remote))

        if self.many:
            for remote_info in local_info[self]["remote"]:
                add(remote_info)
        else:
            add(get_obj_info(local_info[self]["remote"]))
开发者ID:puhep,项目名称:cms-pixel-db-pisa,代码行数:15,代码来源:references.py


示例18: __storm_pre_flush__

    def __storm_pre_flush__(self):
        obj_info = get_obj_info(self)
        pending = obj_info.get("pending")
        stoq_pending = obj_info.get("stoq-status")
        store = obj_info.get("store")

        if pending is PENDING_ADD:
            obj_info["stoq-status"] = _OBJ_CREATED
        elif pending is PENDING_REMOVE:
            obj_info["stoq-status"] = _OBJ_DELETED
        else:
            # This is storm's approach to check if the obj has pending changes,
            # but only makes sense if the obj is not being created/deleted.
            if store._get_changes_map(obj_info, True) and stoq_pending not in [_OBJ_CREATED, _OBJ_DELETED]:
                obj_info["stoq-status"] = _OBJ_UPDATED
开发者ID:stoq,项目名称:stoq,代码行数:15,代码来源:base.py


示例19: dbify_value

def dbify_value(col, val):
    """Convert a value into a form that Storm can compile directly."""
    if isinstance(val, SQL):
        return (val,)
    elif isinstance(col, Reference):
        # References are mainly meant to be used as descriptors, so we
        # have to perform a bit of evil here to turn the (potentially
        # None) value into a sequence of primary key values.
        if val is None:
            return (None,) * len(col._relation._get_local_columns(col._cls))
        else:
            return col._relation.get_remote_variables(
                get_obj_info(val).get_obj())
    else:
        return (col.variable_factory(value=val),)
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:15,代码来源:bulk.py


示例20: __storm_pre_flush__

    def __storm_pre_flush__(self):
        obj_info = get_obj_info(self)
        pending = obj_info.get("pending")
        stoq_pending = obj_info.get('stoq-status')
        store = obj_info.get("store")

        if pending is PENDING_ADD:
            obj_info['stoq-status'] = _OBJ_CREATED
        elif pending is PENDING_REMOVE:
            obj_info['stoq-status'] = _OBJ_DELETED
        else:
            # This is storm's approach to check if the obj
            # has pending changes
            if (store._get_changes_map(obj_info, True) and
                stoq_pending not in [_OBJ_CREATED, _OBJ_DELETED]):
                obj_info['stoq-status'] = _OBJ_UPDATED
开发者ID:Guillon88,项目名称:stoq,代码行数:16,代码来源:domainv2.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python locals.create_database函数代码示例发布时间:2022-05-27
下一篇:
Python info.get_cls_info函数代码示例发布时间: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