本文整理汇总了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
示例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
示例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]
示例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
示例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]
示例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]
示例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()
示例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__()
示例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)
示例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
示例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()
示例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]
示例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]