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


Python IAnnotations.has_key方法代码示例

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


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

示例1: NotificationConfiglet

# 需要导入模块: from zope.annotation import IAnnotations [as 别名]
# 或者: from zope.annotation.IAnnotations import has_key [as 别名]
class NotificationConfiglet(BrowserView):
    
    template = ViewPageTemplateFile('configlet.pt')
    
    def __call__(self, delete=None):
        self.storage = IAnnotations(self.context)
        if delete and self.storage.has_key(STORAGE_KEY) and self.storage[STORAGE_KEY].has_key(delete):
            del self.storage[STORAGE_KEY][delete]
            statusmessages = IStatusMessage(self.request)
            statusmessages.addStatusMessage(_('message_deleted', default='Notification template deleted'), type='info')
        
        return self.template()
    
    @memoize
    def templates(self):
        if not self.storage.has_key(STORAGE_KEY):
            return []
        templates_raw = self.storage.get(STORAGE_KEY)
        vocabulary = availableWorkflows(self.context)
        templates = []
        for name, template in templates_raw.items():
            template = {'name': name,
                        'template': template}
            try:
                term = vocabulary.getTermByToken(name)
                template.update(dict(title=(term.title or term.token)))
            except:
                pass
            templates.append(template)
        return templates
开发者ID:Raptus,项目名称:raptus.workflownotificationtemplates,代码行数:32,代码来源:configlet.py

示例2: registerPersistentConfig

# 需要导入模块: from zope.annotation import IAnnotations [as 别名]
# 或者: from zope.annotation.IAnnotations import has_key [as 别名]
def registerPersistentConfig(site, type_):
    """ Try to get persistent pipeline configuration of given type (export or import)
        and register it for use with transmogrifier.
    """
    global CONFIGFILE
    anno = IAnnotations(site)
    key = '%s.%s' % (ANNOKEY, type_)
    config = anno.has_key(key) and anno[key] or None

    # unregister old config
    name = 'persitent-%s' % type_
    if name in configuration_registry._config_ids:
        configuration_registry._config_ids.remove(name)
        del configuration_registry._config_info[name]

    # register new
    if config is not None:
        title = description = u'Persistent %s pipeline'
        tf = tempfile.NamedTemporaryFile('w+t', suffix='.cfg')
        tf.write(config)
        tf.seek(0)
        CONFIGFILE = tf
        configuration_registry.registerConfiguration(name, title, description, tf.name)
        return name
    else:
        return None
开发者ID:acsr,项目名称:quintagroup.transmogrifier,代码行数:28,代码来源:exportimport.py

示例3: __init__

# 需要导入模块: from zope.annotation import IAnnotations [as 别名]
# 或者: from zope.annotation.IAnnotations import has_key [as 别名]
 def __init__(self, context):
     self.context = context
     self.portal = getToolByName(self.context, 'portal_url').getPortalObject()
     storage = IAnnotations(self.portal)
     if not storage.has_key(STORAGE_KEY):
         storage[STORAGE_KEY] = PersistentDict()
     self.storage = storage[STORAGE_KEY]
开发者ID:Raptus,项目名称:raptus.workflownotificationtemplates,代码行数:9,代码来源:adapter.py

示例4: queue

# 需要导入模块: from zope.annotation import IAnnotations [as 别名]
# 或者: from zope.annotation.IAnnotations import has_key [as 别名]
 def queue(self):
     queue = getattr(self, "_queue", None)
     if queue is None:
         annotations = IAnnotations(self.context)
         if not annotations.has_key(self.key):
             annotations[self.key] = IOBTree()
         self._queue = annotations[self.key]
     return self._queue
开发者ID:socialplanning,项目名称:ClockQueue,代码行数:10,代码来源:__init__.py

示例5: getInfoByRevision

# 需要导入模块: from zope.annotation import IAnnotations [as 别名]
# 或者: from zope.annotation.IAnnotations import has_key [as 别名]
 def getInfoByRevision(self, instance, name, rev):
     """ Get info about a storage item by a give revision
     """
     annotations = IAnnotations(instance)
     if not annotations.has_key(LOG_KEY) or \
        not annotations[LOG_KEY].has_key(name) or \
        not annotations[LOG_KEY][name].has_key(rev):
         return
     return annotations[LOG_KEY][name][rev]
开发者ID:Raptus,项目名称:raptus.mercurialstorage,代码行数:11,代码来源:storage.py

示例6: __init__

# 需要导入模块: from zope.annotation import IAnnotations [as 别名]
# 或者: from zope.annotation.IAnnotations import has_key [as 别名]
 def __init__(self, context, request, view, manager=None):
     super(HeaderViewlet, self).__init__(context, request, view, manager)
     self.mship = getToolByName(self.context, 'portal_membership')
     self.catalog = getToolByName(self.context, 'portal_catalog')
     self.props = getToolByName(self.context, 'portal_properties').site_properties
     if self.request.get('enable_header', False) or self.request.get('disable_header', False) or self.request.get('inherit_header', False):
         if not self.mship.checkPermission(permissions.ModifyPortalContent, self.context):
             return
         annotations = IAnnotations(context)
         if self.request.get('enable_header', False):
             if annotations.has_key(ANNOTATIONS_KEY_DISABLED):
                 del annotations[ANNOTATIONS_KEY_DISABLED]
             annotations[ANNOTATIONS_KEY_ENABLED] = True
         elif self.request.get('disable_header', False):
             if annotations.has_key(ANNOTATIONS_KEY_ENABLED):
                 del annotations[ANNOTATIONS_KEY_ENABLED]
             annotations[ANNOTATIONS_KEY_DISABLED] = True
         elif self.request.get('inherit_header', False):
             if annotations.has_key(ANNOTATIONS_KEY_DISABLED):
                 del annotations[ANNOTATIONS_KEY_DISABLED]
             if annotations.has_key(ANNOTATIONS_KEY_ENABLED):
                 del annotations[ANNOTATIONS_KEY_ENABLED]
开发者ID:Raptus,项目名称:raptus.header,代码行数:24,代码来源:viewlets.py

示例7: __call__

# 需要导入模块: from zope.annotation import IAnnotations [as 别名]
# 或者: from zope.annotation.IAnnotations import has_key [as 别名]
 def __call__(self):
     if not processor_lock.acquire(False):
         return
     try:
         annotations = IAnnotations(self.context)
         processor_lazy_lock.acquire()
         try:
             if not annotations.has_key(QUEUE_KEY):
                 annotations[QUEUE_KEY] = PersistentList()
             queue = annotations[QUEUE_KEY]
             if annotations.has_key(QUEUE_LAZY_KEY):
                 queue_lazy = annotations[QUEUE_LAZY_KEY]
                 while len(queue_lazy):
                     queue.append(queue_lazy.pop(0))
         finally:
             processor_lazy_lock.release()
         if not annotations.has_key(QUEUE_KEY):
             return
         queue = annotations[QUEUE_KEY]
         previous = None
         while len(queue):
             sp = transaction.savepoint(optimistic=True)
             action = queue.pop(0)
             if action == previous:
                 info('skipping action %s' % action)
                 continue
             info('starting action %s' % action)
             try:
                 action.execute(self.context)
                 previous = action
                 info('action finished %s' % action)
             except Exception, e:
                 sp.rollback()
                 exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
                 info('action failed %s\n%s' % (action, ''.join(traceback.format_exception(exceptionType, exceptionValue, exceptionTraceback))))
                 break
     finally:
         processor_lock.release()
开发者ID:Raptus,项目名称:raptus.mercurialstorage,代码行数:40,代码来源:queue.py

示例8: __call__

# 需要导入模块: from zope.annotation import IAnnotations [as 别名]
# 或者: from zope.annotation.IAnnotations import has_key [as 别名]
 def __call__(self, name=None):
     self.name = name
     storage = IAnnotations(self.context)
     if not storage.has_key(STORAGE_KEY):
         storage[STORAGE_KEY] = PersistentDict()
     self.storage = storage[STORAGE_KEY]
     
     self.form_fields.get('name').field = self.form_fields.get('name').field.bind(self.context)
     self.form_fields.get('template').field = self.form_fields.get('template').field.bind(self.context)
     
     self.form_fields.get('template').field.default = None
     self.form_fields.get('template').field.default = None
     if self.name and self.storage.has_key(self.name):
         self.form_fields.get('name').field.default = self.name
         self.form_fields.get('template').field.default = self.storage.get(self.name)
         
     return super(NotificationTemplateForm, self).__call__()
开发者ID:Raptus,项目名称:raptus.workflownotificationtemplates,代码行数:19,代码来源:configlet.py

示例9: before_file_remove

# 需要导入模块: from zope.annotation import IAnnotations [as 别名]
# 或者: from zope.annotation.IAnnotations import has_key [as 别名]
def before_file_remove(obj, event):
    request = getattr(obj, 'REQUEST', '')
    if request and hasattr(request, 'ACTUAL_URL') and \
       request.ACTUAL_URL.endswith('delete_confirmation') and \
            request.get('REQUEST_METHOD') == 'GET':
                # delete event is fired by link integrity check, skip it.
                return

    # skip source remove if we have appropriate flag set in request
    annotations = IAnnotations(request)
    if annotations and annotations.has_key(SKIP_SOURCE_REMOVE_FLAG) and \
            annotations[SKIP_SOURCE_REMOVE_FLAG]:
        return

    try:
        remove_source(obj)
    except AWSSourceRemoveError, e:
        IStatusMessage(request).addStatusMessage(_(e), type='error')
        utils.abort_transaction(request)
开发者ID:quintagroup,项目名称:collective.contentfiles2aws,代码行数:21,代码来源:handlers.py

示例10: log

# 需要导入模块: from zope.annotation import IAnnotations [as 别名]
# 或者: from zope.annotation.IAnnotations import has_key [as 别名]
 def log(self, name, instance):
     """
     """
     if instance.isTemporary():
         return
     annotations = IAnnotations(instance)
     if not annotations.has_key(LOG_KEY):
         annotations[LOG_KEY] = PersistentDict()
     if not annotations[LOG_KEY].has_key(name):
         annotations[LOG_KEY][name] = PersistentDict()
     revision = self.getRevision(instance, name)
     if not revision:
         return
     try:
         data = PersistentDict()
         data['filepath'] = self.getFilepath(instance, name)
         data['filename'] = self.getFilename(instance, name)
         data['mimetype'] = self.getContentType(instance, name)
         annotations[LOG_KEY][name][revision] = data
     except AttributeError:
         pass
开发者ID:Raptus,项目名称:raptus.mercurialstorage,代码行数:23,代码来源:storage.py

示例11: abort_remove

# 需要导入模块: from zope.annotation import IAnnotations [as 别名]
# 或者: from zope.annotation.IAnnotations import has_key [as 别名]
def abort_remove(obj, event):
    annotations = IAnnotations(obj.REQUEST)
    if annotations and annotations.has_key(ABORT_TRANSACTION_FLAG) and \
            annotations[ABORT_TRANSACTION_FLAG]:
        transaction.abort()
开发者ID:quintagroup,项目名称:collective.contentfiles2aws,代码行数:7,代码来源:handlers.py

示例12: get_storage

# 需要导入模块: from zope.annotation import IAnnotations [as 别名]
# 或者: from zope.annotation.IAnnotations import has_key [as 别名]
def get_storage( context ):
    annotations = IAnnotations( context )
    if not annotations.has_key( annotation_key ):
        annotations[ annotation_key ] = PersistentDict()
    return annotations[annotation_key]
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:7,代码来源:util.py

示例13: __init__

# 需要导入模块: from zope.annotation import IAnnotations [as 别名]
# 或者: from zope.annotation.IAnnotations import has_key [as 别名]
 def __init__(self, context):
     self.context = context
     annotations = IAnnotations(context)
     if not annotations.has_key(ANNOTATIONS_KEY):
         annotations[ANNOTATIONS_KEY] = PersistentDict()
     self.storage = annotations[ANNOTATIONS_KEY]
开发者ID:Raptus,项目名称:pcommerce.stock,代码行数:8,代码来源:stock.py


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