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


Python persistent.Persistent方法代码示例

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


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

示例1: __getattribute__

# 需要导入模块: import persistent [as 别名]
# 或者: from persistent import Persistent [as 别名]
def __getattribute__(self, attr):
        ga = persistent.Persistent.__getattribute__
        if attr.startswith(('_p_', '_v_')):
            return ga(self, attr)
        self._p_activate()
        return ga(self, attr) 
开发者ID:enkore,项目名称:borgcube,代码行数:8,代码来源:models.py

示例2: _set_changed

# 需要导入模块: import persistent [as 别名]
# 或者: from persistent import Persistent [as 别名]
def _set_changed(self, value):
        ghost = self._p_jar is not None and self._p_changed is None
        if ghost:
            self._evolve()
        persistent.Persistent._p_changed.__set__(self, value) 
开发者ID:enkore,项目名称:borgcube,代码行数:7,代码来源:models.py

示例3: _p_mtime

# 需要导入模块: import persistent [as 别名]
# 或者: from persistent import Persistent [as 别名]
def _p_mtime(self):
        ghost = self._p_jar is not None and self._p_changed is None
        if ghost:
            self._evolve()
        return persistent.Persistent._p_mtime.__get__(self) 
开发者ID:enkore,项目名称:borgcube,代码行数:7,代码来源:models.py

示例4: kw_function_key_generator

# 需要导入模块: import persistent [as 别名]
# 或者: from persistent import Persistent [as 别名]
def kw_function_key_generator(namespace, fn, to_str=compat.string_type):
    """Return a function that generates a string
    key, based on a given function as well as
    arguments to the returned function itself.

    This is used by :meth:`.CacheRegion.cache_on_arguments`
    to generate a cache key from a decorated function.

    It can be replaced using the ``function_key_generator``
    argument passed to :func:`.make_region`.

    """

    if namespace is None:
        namespace = '%s:%s' % (fn.__module__, fn.__name__)
    else:
        namespace = '%s:%s|%s' % (fn.__module__, fn.__name__, namespace)

    args = inspect.getargspec(fn)
    has_self = args[0] and args[0][0] in ('self', 'cls')
    def generate_key(*args, **kw):
        #if has_self:
        if has_self and args and isinstance(args[0], Persistent):
            # When the kw_function_key_generator is called via
            # the method, we get:
            # args = (<EDBAuthPlugin at /extranetPRIVR/acl_users/eap>, 'vincentfretin')
            # When called via method.invalidate we get:
            # args = ('vincentfretin',)
            args = args[1:]

        genkey = namespace + "|" + " ".join(
            [isinstance(arg, Persistent) and str(get_oid(arg, 'nooid')) or to_str(arg)
             for arg in args]
        )
        if kw:
            local_index = []
            for key, val in kw.items():
                local_index.append((to_str(key), to_str(val)))

            local_index.sort()
            for key, val in local_index:
                genkey += " %s:%s" % (key, val)

        return genkey
    return generate_key


#region_memcached = make_region(
#        function_key_generator=kw_function_key_generator,
#        key_mangler=sha1_mangle_key
#).configure(
#'dogpile.cache.memcached',
#expiration_time=3600,
#arguments={
#    'url': ["127.0.0.1:11211"],
#    'min_compress_len': 1000,
#    'distributed_lock': True,
#},
#) 
开发者ID:ecreall,项目名称:lagendacommun,代码行数:61,代码来源:cache.py

示例5: discriminate

# 需要导入模块: import persistent [as 别名]
# 或者: from persistent import Persistent [as 别名]
def discriminate(self, obj, default):
        """ See interface IIndexInjection """
        if callable(self.discriminator):
            value = self.discriminator(obj, _marker)
        else:
            value = getattr(obj, self.discriminator, _marker)

        if value is _marker:
            return default

        if isinstance(value, Persistent):
            raise ValueError('Catalog cannot index persistent object %s' %
                             value)

        if isinstance(value, Broken):
            raise ValueError('Catalog cannot index broken object %s' %
                             value)

        if not isinstance(value, dict):
            raise ValueError('Catalog can only index dict with '
                'attr and date keys, or date and recurdef keys, given %s' %
                             value)
        # examples:
        # {'attr': 'dates',
        #  'date': datetime.datetime.now()}
        # will get dates_recurrence attribute on the obj to get iCal string
        # for recurrence definition
        # or
        # {'date': datetime.datetime.now(),
        #  'recurdef': ICALSTRING}
        # no access to obj attributes at all

        date = value.get('date')
        default_recurdef = value.get('recurdef', _marker)
        if default_recurdef is not _marker:
            recurdef = default_recurdef
        else:
            attr_recurdef = value.get('attr') + '_recurrence'
            recurdef = getattr(obj, attr_recurdef, None)

        if callable(recurdef):
            recurdef = recurdef()

        if not recurdef:
            dates = [date]
        else:
            dates = recurrence_sequence_ical(date, recrule=recurdef)

        # dates is a generator
        return tuple(dates) 
开发者ID:ecreall,项目名称:lagendacommun,代码行数:52,代码来源:dateindex.py


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