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


Python mapping.PersistentMapping类代码示例

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


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

示例1: create_root

def create_root(storage, oid=z64, check_new=True):
    """
    Creates public or private root in storage.
    Root has the type PersistentMapping.

    :param storage: ZODB storage to create the root in
    :param str oid: Object id to give to the root (z64 is global root)
    :param bool check_new: If True, do nothing if the root exists
    """

    if check_new:
        try:
            storage.load(oid, '')
            return
        except KeyError:
            pass
    # Create the database's root in the storage if it doesn't exist
    from persistent.mapping import PersistentMapping
    root = PersistentMapping()
    # Manually create a pickle for the root to put in the storage.
    # The pickle must be in the special ZODB format.
    file = BytesIO()
    p = Pickler(file, _protocol)
    p.dump((root.__class__, None))
    p.dump(root.__getstate__())
    t = transaction.Transaction()
    t.description = 'initial database creation'
    storage.tpc_begin(t)
    storage.store(oid, None, file.getvalue(), '', t)
    storage.tpc_vote(t)
    storage.tpc_finish(t)
开发者ID:felixonmars,项目名称:zerodb,代码行数:31,代码来源:subdb.py

示例2: __init__

    def __init__(self):

        PersistentMapping.__init__(self)

        self.blogs = IOBTree()
        self.categories = Categories()
        self.tags = Tags()
开发者ID:gliheng,项目名称:Mojo,代码行数:7,代码来源:models.py

示例3: checkPackKeepNewObjects

    def checkPackKeepNewObjects(self):
        # Packing should not remove objects created or modified after
        # the pack time, even if they are unreferenced.
        db = DB(self._storage)
        try:
            # add some data to be packed
            c = db.open()
            extra1 = PersistentMapping()
            c.add(extra1)
            extra2 = PersistentMapping()
            c.add(extra2)
            transaction.commit()

            # Choose the pack time
            now = packtime = time.time()
            while packtime <= now:
                time.sleep(0.1)
                packtime = time.time()
            while packtime == time.time():
                time.sleep(0.1)

            extra2.foo = "bar"
            extra3 = PersistentMapping()
            c.add(extra3)
            transaction.commit()

            self._storage.pack(packtime, referencesf)

            # extra1 should have been garbage collected
            self.assertRaises(KeyError, self._storage.load, extra1._p_oid, "")
            # extra2 and extra3 should both still exist
            self._storage.load(extra2._p_oid, "")
            self._storage.load(extra3._p_oid, "")
        finally:
            db.close()
开发者ID:,项目名称:,代码行数:35,代码来源:

示例4: __init__

    def __init__(self):
        self.filename = None
        self.package = None
        self.start_time = None
        self.end_time = None

        self._entities = PersistentMapping()
        """contains all entities in the form of (simplified):
        {
            class_name: (
                [entitiy, ...],
                Binary tree of all entities (key: primary_identifier)
            )
        }
        """

        self._events = OOBTree.TreeSet()
        """contains all entities
        """

        self._event_index = PersistentMapping()
        """contains indices for events in the form of
        {
            class_name: {
                key: Binary Tree {
                        attribute_value: set(event, ...)
                    }
            }
        }
        """

        self.plugins = {}
        self.hashes = {}
开发者ID:MalwareLabHagenberg,项目名称:ambrosia,代码行数:33,代码来源:__init__.py

示例5: __init__

 def __init__(self):
     """
     """
     self.rankedNouns = PersistentMapping()
     self.rankedNPs = PersistentMapping()
     self.extractor = getUtility(ITermExtractor)
     self.friendlyTypes = PersistentList()
开发者ID:soerensigfusson,项目名称:collective.classification,代码行数:7,代码来源:npstorage.py

示例6: test_set_acl_set_resource_dirty

def test_set_acl_set_resource_dirty():
    """Regression test."""
    from persistent.mapping import PersistentMapping
    from . import set_acl
    resource = PersistentMapping()
    resource._p_jar = Mock()  # make _p_changed property work
    set_acl(resource, [('Deny', 'role:creator', 'edit')])
    assert resource._p_changed is True
开发者ID:Janaba,项目名称:adhocracy3,代码行数:8,代码来源:test_init.py

示例7: __init__

    def __init__(self, content_id, data=None, **kwargs):

        if not data:
            data = {}

        PersistentMapping.__init__(self)
        Base.__init__(self, content_id, data=data)
        self._order = []
开发者ID:,项目名称:,代码行数:8,代码来源:

示例8: test_set_acl_set_resource_dirty

def test_set_acl_set_resource_dirty():
    from . import set_acl
    from pyramid.security import Deny
    from persistent.mapping import PersistentMapping
    resource = PersistentMapping()
    resource._p_jar = Mock()  # make _p_changed property work
    set_acl(resource, [(Deny, 'role:creator', 'edit_comment')])
    assert resource._p_changed is True
开发者ID:libscott,项目名称:adhocracy3,代码行数:8,代码来源:test_init.py

示例9: __init__

    def __init__(self, crumb_name, owner, id):
        PersistentMapping.__init__(self)
        self.item_number = 0
        self.timestamp = datetime.now()
        self.id = id
        self.owner = owner

        # Name used in breadcrumps
        self.crumb_name = crumb_name
开发者ID:tojuhaka,项目名称:easyblog,代码行数:9,代码来源:models.py

示例10: __init__

    def __init__(self, name, parent, uid, gid, mode, mtime_ns):
        FileMeta.__init__(self, name, parent, uid, gid, mode, mtime_ns)
        
        self.adds         = PersistentMapping()
        self.removes      = PersistentMapping()
        self.meta_changes = PersistentMapping() # name => ((to_uid, to_gid, to_mode), (from_uid, from_gid, from_mode))

        self.subdirs      = PersistentMapping()

        self.state        = PatchedDirectory.EXISTING
开发者ID:cocagne,项目名称:scratch,代码行数:10,代码来源:types.py

示例11: test_persistent_mapping

 def test_persistent_mapping(self):
     value = PersistentMapping({'foo': 'bar'})
     self.assertEquals({u'foo': u'bar'}, json_compatible(value))
     self.assertEquals('{"foo": "bar"}', json.dumps(json_compatible(value)))
     self.assertIsInstance(json_compatible(value.keys()[0]),
                           unicode,
                           'Dict keys should be converted recursively.')
     self.assertIsInstance(json_compatible(value.values()[0]),
                           unicode,
                           'Dict values should be converted recursively.')
开发者ID:casdr,项目名称:plone.restapi,代码行数:10,代码来源:test_serializer_converters.py

示例12: _data

 def _data(self):
     """Return dictionary to store data."""
     sheets_data = getattr(self.context, '_sheets', None)
     if sheets_data is None:
         sheets_data = PersistentMapping()
         setattr(self.context, '_sheets', sheets_data)
     data = sheets_data.get(self._data_key, None)
     if data is None:
         data = PersistentMapping()
         sheets_data[self._data_key] = data
     return data
开发者ID:robx,项目名称:adhocracy3.mercator,代码行数:11,代码来源:__init__.py

示例13: __init__

 def __init__(self, log):
     #self.start_time = log['start_time']
     #self.players    = log['players']
     #self.units      = log['units']
     #self.grid       = log['grid']
     #self['init_locs']  = log['init_locs']
     PersistentMapping.__init__(self, init_locs=log['init_locs'],
                         start_time=log['start_time'],
                         units=log['units'],
                         grid=log['grid'],
                         owners=log['owners'],)
开发者ID:jessetane,项目名称:btpy,代码行数:11,代码来源:zodb_hex_battle.py

示例14: __setitem__

 def __setitem__(self, key, value):
     if key in self.data:
         raise TypeError("Can't update key in AppendOnlyDict!")
     if isinstance(value, (dict, list)):
         raise TypeError("Can't add non-persistent mutable subobjects!")
     if not PY3:
         from types import InstanceType
         if type(value) is InstanceType:
             if not isinstance(value, Persistent):
                 raise TypeError(
                     "Can't add non-persistent mutable subobjects!")
     PersistentMapping.__setitem__(self, key, value)
开发者ID:jean,项目名称:cipher.session,代码行数:12,代码来源:session.py

示例15: record_change

 def record_change(self, context, _userid):
     if self.new:
         key = self.make_key(context)
         data = self.data
         context['gallery'][key] = PersistentMapping(data)
         context['gallery'][key].order = self.order
     else:
         key = self.key
         if self.delete:
             del context['gallery'][key]
         else:
             context['gallery'][key].order = self.order
开发者ID:amarandon,项目名称:opencore,代码行数:12,代码来源:forms.py


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