本文整理汇总了Python中zope.app.annotation.interfaces.IAnnotations.get方法的典型用法代码示例。如果您正苦于以下问题:Python IAnnotations.get方法的具体用法?Python IAnnotations.get怎么用?Python IAnnotations.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zope.app.annotation.interfaces.IAnnotations
的用法示例。
在下文中一共展示了IAnnotations.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: authenticated_memberid
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import get [as 别名]
def authenticated_memberid(context):
""" the last modified author is set on an annotation """
from opencore.project.browser.metadata import ANNOT_KEY
from Missing import Value as MissingValue
annot = IAnnotations(context)
annot = annot.get(ANNOT_KEY, {})
val = annot.get('lastModifiedAuthor')
if val:
return val
# @@ adapters must return something or code must expect component
# errors
return MissingValue
示例2: GEOMap
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import get [as 别名]
class GEOMap(object):
""" geomap
"""
implements(IGEOMap)
def __init__(self, context):
""" init """
self.annotations = IAnnotations(context)
self.geomap = self.annotations.get(GEOMAP_KEY, None)
if self.geomap == None:
self.annotations[GEOMAP_KEY] = PersistentMapping()
self.geomap = self.annotations[GEOMAP_KEY]
self.geomap['mapcenter'] = None
self.geomap['mapzoom'] = None
self.geomap['maptype'] = None
def getMapCenter(self):
""" return map center """
return self.geomap['mapcenter']
def getMapZoom(self):
""" return map zoom """
return self.geomap['mapzoom']
def getMapType(self):
""" return map type """
return self.geomap['maptype']
def setMap(self, mapcenter, mapzoom, maptype):
""" set map options """
self.geomap['mapcenter'] = mapcenter
self.geomap['mapzoom'] = mapzoom
self.geomap['maptype'] = maptype
示例3: GEOLocated
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import get [as 别名]
class GEOLocated(object):
""" geolocation
"""
implements(IGEOLocated)
def __init__(self, context):
""" init """
self.annotations = IAnnotations(context)
self.geolocation = self.annotations.get(GEOLOCATION_KEY, None)
if self.geolocation == None:
self.annotations[GEOLOCATION_KEY] = PersistentMapping()
self.geolocation = self.annotations[GEOLOCATION_KEY]
self.geolocation['latitude'] = None
self.geolocation['longitude'] = None
def getLongitude(self):
""" return longtitude """
return self.geolocation['longitude']
def getLatitude(self):
""" return latitude """
return self.geolocation['latitude']
def setLongitude(self, value):
""" set longtitude """
self.geolocation['longitude'] = float(value)
def setLatitude(self, value):
""" set latitutde """
self.geolocation['latitude'] = float(value)
def setLocation(self, latitude, longitude):
""" set location """
self.geolocation['longitude'] = float(longitude)
self.geolocation['latitude'] = float(latitude)
示例4: migrate
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import get [as 别名]
def migrate(self):
if self.is_updated():
return 'already migrated'
# set the appropriate list type based on the previous settings
# this may need to mark the appropriate interface on the mailing
# list as well
if self.context.moderated:
self.context.list_type = PostModeratedListTypeDefinition
elif self.context.closed:
self.context.list_type = MembershipModeratedListTypeDefinition
else:
self.context.list_type = PublicListTypeDefinition
# copy over the membership stuff
annot = IAnnotations(self.context)
listen_annot = annot.get('listen', {})
old_subscribers = listen_annot.get('subscribers', [])
# create the new annotations by using current adapters
mem_list = IWriteMembershipList(self.context)
for subscriber in old_subscribers:
mem_list.subscribe(subscriber)
# unsubscribe (but leave as allowed senders) those who don't
# receive mail
nomail = listen_annot.get('norecvmail', [])
for allowed_sender in nomail:
mem_list.unsubscribe(allowed_sender)
# copy over the moderation messages
self.mod_post_pending_list = getAdapter(self.context, IPostPendingList, 'pending_pmod_post')
for i in self.context.mqueue.objectIds():
(header, body) = splitMail(self.context.mqueue[i])
post = {'header':header, 'body':body}
(user_name, user_email) = parseaddr(header.get('from', ''))
self.mod_post_pending_list.add(user_email, user_name=user_name, post=post)
# creates list managers from moderators and list owner
managers = []
managers.append(self.context.list_owner)
for moderator in self.context.moderators:
managers.append(moderator)
self.context.managers = tuple(managers)
convert_manager_emails_to_memberids(self.context)
# translate archived vocabulary
if self.context.archived == 'not archived':
self.context.archived = 2
elif self.context.archived == 'plain text':
self.context.archived = 1
elif self.context.archived == 'with attachments':
self.context.archived = 0
else:
return 'error translating archive option'
# annotate the list to say the migration completed
self.migration_annot.append('policy_migration')
return 'successfully migrated'
示例5: __init__
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import get [as 别名]
def __init__(self, context):
self.context = context
annot = IAnnotations(context)
homepage_annot = annot.get(self.KEY, None)
if homepage_annot is None:
homepage_annot = OOBTree()
annot['opencore.project.browser.home_page'] = homepage_annot
self.annot = homepage_annot
示例6: __init__
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import get [as 别名]
def __init__(self, context):
self.context = context
annot = IAnnotations(context)
wiki_annot = annot.get(annot_key, None)
if wiki_annot is None:
wiki_annot = IOBTree()
annot[annot_key] = wiki_annot
self.annot = wiki_annot
示例7: __init__
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import get [as 别名]
def __init__(self, context):
self.context = context
annot = IAnnotations(context)
req_annot = annot.get(annot_key, None)
if req_annot is None:
req_annot = set()
annot[annot_key] = req_annot
self._req_store = req_annot
示例8: clearMemoCache
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import get [as 别名]
def clearMemoCache(self):
# from the request
req = self.portal.REQUEST
annotations = IAnnotations(req)
cache = annotations.get(ViewMemo.key, None)
if cache is not None:
annotations[ViewMemo.key] = dict()
# from the timestamp cache
opencore.utils.timestamp_cache.clear()
示例9: __init__
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import get [as 别名]
def __init__(self, context):
_ATCTFileAudio.__init__(self, context)
annotations = IAnnotations(context)
self.encoding_data = annotations.get(self.ENCODING_KEY, None)
if self.encoding_data == None:
self.encoding_data = PersistentDict()
annotations[self.ENCODING_KEY] = self.encoding_data
self.encoding_data['encoding'] = ""
self.encoding_data['original_encoding'] = ""
示例10: __init__
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import get [as 别名]
def __init__(self, context, request):
self.context = context
self.request = request
annotations = IAnnotations(context.getCanonical())
mapping = annotations.get(KEY)
if mapping is None:
mapping = annotations[KEY] = PersistentDict({
'page_background': None,
})
self.mapping = mapping
示例11: addPath
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import get [as 别名]
def addPath(self, path):
path = self._make_relative(path)
annotations = IAnnotations(self.context)
old = annotations.get(self.key, ())
fixed = map(self._make_relative, old)
if path not in fixed:
fixed.append(path)
new = tuple(fixed)
if new != old:
annotations[self.key] = new
示例12: capture
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import get [as 别名]
def capture(self, order, amount):
annotations = IAnnotations(order)
trans_id = annotations[interfaces.keys.processor_txn_id]
if annotations.has_key(APPROVAL_KEY):
annotation = IAnnotations( order )
if annotation.get( interfaces.keys.capture_amount ) is None:
annotation[ interfaces.keys.capture_amount ] = amount
else:
annotation[ interfaces.keys.capture_amount ] += amount
return interfaces.keys.results_success
return result.response_reason
示例13: save_import_history
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import get [as 别名]
def save_import_history(self):
annot = IAnnotations(self.context)
listen_annot = annot.get(PROJECTNAME)
if listen_annot is None:
annot[PROJECTNAME] = listen_annot = OOBTree()
import_annot = listen_annot.get('import')
if import_annot is None:
listen_annot['import'] = import_annot = OOBTree()
now = str(time.time())
data = dict(msgids=self.msgids,
filename=self.filename)
import_annot[now] = OOBTree(data)
示例14: removePath
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import get [as 别名]
def removePath(self, path):
path = self._make_relative(path)
annotations = IAnnotations(self.context)
old = annotations.get(self.key, ())
if old:
fixed = map(self._make_relative, old)
fixed = [loc for loc in fixed if loc != path]
new = tuple(fixed)
if new != old:
if new:
annotations[self.key] = new
else:
del annotations[self.key]
示例15: Point
# 需要导入模块: from zope.app.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import get [as 别名]
class Point(object):
implements(IPoint)
def __init__(self, context):
""" init """
self.annotations = IAnnotations(context)
self.point = self.annotations.get(GEOLOCATION_KEY, None)
if self.point == None:
self.annotations[GEOLOCATION_KEY] = PersistentMapping()
self.point = self.annotations[GEOLOCATION_KEY]
self.point['targetId'] = ''
self.point['extrude'] = 0
self.point['tessellate'] = 0
self.point['altitudeMode'] = 'clampToGround'
self.point['coordinates'] = (0,0,0)
def getCoordinates(self):
return self.point['coordinates']
def setCoordinates(self, coordinates):
self.point['coordinates'] = coordinates
def getAltitudeMode(self):
return self.point['altitudeMode']
def setAltitudeMode(self, altitudeMode):
self.point['altitudeMode'] = altitudeMode
def getTessellate(self):
return self.point['tessellate']
def setTessellate(self, tessellate):
self.point['tessellate'] = tessellate
def getExtrude(self):
return self.point['extrude']
def setExtrude(self, extrude):
self.point['extrude'] = extrude
def getTargetId(self):
return self.point['targetId']
def setTargetId(self, targetId):
self.point['targetId'] = targetId
coordinates = property(getCoordinates, setCoordinates, """ see interface """)
altitudeMode = property(getAltitudeMode, setAltitudeMode, """ see interface """)
tessellate = property(getTessellate, setTessellate, """ see interface """)
extrude = property(getExtrude, setExtrude, """ see interface """)
targetId = property(getTargetId, setTargetId, """ see interface """)