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


Python interfaces.IAnnotations类代码示例

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


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

示例1: getSourceName

 def getSourceName(self, instance):
     """Get the name of the data source that is used in this context."""
     mapping = IAnnotations(instance).setdefault(
         'collective.table',
         PersistentMapping()
     )
     return mapping.get('source_name', self.defaultSourceName)
开发者ID:collective,项目名称:collective.table,代码行数:7,代码来源:field_widget.py

示例2: get_number

 def get_number(self, obj):
     ann = IAnnotations(obj)
     if SEQUENCE_NUMBER_ANNOTATION_KEY not in ann.keys():
         generator = getAdapter(obj, ISequenceNumberGenerator)
         value = generator.generate()
         ann[SEQUENCE_NUMBER_ANNOTATION_KEY] = value
     return ann.get(SEQUENCE_NUMBER_ANNOTATION_KEY)
开发者ID:hellfish2,项目名称:opengever.core,代码行数:7,代码来源:sequence.py

示例3: handleUpdate

    def handleUpdate(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        annotations = IAnnotations(self.context)
        storage = annotations.setdefault('geoportlet', PersistentMapping())
        database = Software77GeoDatabase(storage)

        url = data['url']
        url = url and url.encode('utf-8') or None

        try:
            count = database.update(url)
        except IOError as exc:
            IStatusMessage(self.request).addStatusMessage(
                _(u"An error occurred: ${error}.",
                  mapping={'error': exc}), "info")
        else:
            try:
                count = '{0:,}'.format(count)
            except ValueError:
                pass

            IStatusMessage(self.request).addStatusMessage(
                _(u"Database updated (${count} records read).",
                  mapping={'count': count}),
                "info")
开发者ID:collective,项目名称:collective.portlet.geo,代码行数:29,代码来源:controlpanel.py

示例4: localPortletAssignmentMappingAdapter

def localPortletAssignmentMappingAdapter(context, manager):
    """This is pretty much the same code of the original one from

    `plone.app.portlets.assignable.localPortletAssignmentMappingAdapter`

    but it changes the assignment klass with `Mapping`.

    This is needed in order to use our custom view '+'
    for adding the portlet.
    """
    annotations = IAnnotations(context)
    local = annotations.get(CONTEXT_ASSIGNMENT_KEY, None)
    if local is None:
        local = annotations[CONTEXT_ASSIGNMENT_KEY] = OOBTree()

    portlets = local.get(manager.__name__, None)
    if portlets is None:
        portlets = local[manager.__name__] = Mapping(manager=manager.__name__,
                                                     category=CONTEXT_CATEGORY)

    # XXX: For graceful migration
    if not getattr(portlets, '__manager__', ''):
        portlets.__manager__ = manager.__name__

    if not getattr(portlets, '__category__', ''):
        portlets.__category__ = CONTEXT_CATEGORY

    return portlets
开发者ID:plone,项目名称:plone.app.standardtiles,代码行数:28,代码来源:assignment.py

示例5: show

    def show(self):
        """ Removes all status messages (including HTML) and returns them 
            for display.
        """
        context = self.context
        annotations = IAnnotations(context)
        msgs = annotations.get(STATUSMESSAGEKEY,
                                context.cookies.get(STATUSMESSAGEKEY))
        msgs = msgs and adapter._decodeCookieValue(msgs) or []

        html_msgs = annotations.get(HTMLMESSAGEKEY,
                                context.cookies.get(HTMLMESSAGEKEY))
        html_msgs = html_msgs and adapter._decodeCookieValue(html_msgs) or []

        for msg in html_msgs:
            msg.message = literal(sanitize(msg.message, cleaner=msgcleaner, wrap=None))

        value = msgs + html_msgs
        
        # clear the existing cookie entries, except on responses that don't
        # actually render in the browser (really, these shouldn't render
        # anything so we shouldn't get to this message, but some templates
        # are sloppy).
        if self.context.response.getStatus() not in (301, 302, 304):
            context.cookies[STATUSMESSAGEKEY] = None
            context.response.expireCookie(STATUSMESSAGEKEY, path='/')
            annotations[STATUSMESSAGEKEY] = None

            context.cookies[HTMLMESSAGEKEY] = None
            context.response.expireCookie(HTMLMESSAGEKEY, path='/')
            annotations[HTMLMESSAGEKEY] = None
        
        return value
开发者ID:jean,项目名称:NuPlone,代码行数:33,代码来源:adapter.py

示例6: get_reference_mapping

    def get_reference_mapping(self, obj=None):
        type_key = self.get_type_key(obj)
        annotations = IAnnotations(self.context)

        if not annotations.get(type_key):
            annotations[type_key] = PersistentDict({})
        return annotations[type_key]
开发者ID:hellfish2,项目名称:opengever.core,代码行数:7,代码来源:adapters.py

示例7: test_annotations_key_is_cleared

    def test_annotations_key_is_cleared(self):
        annotations = IAnnotations(self.document)
        self.assertEquals(TEST_USER_ID, annotations.get(CHECKIN_CHECKOUT_ANNOTATIONS_KEY))

        self.manager.checkin()

        self.assertEquals(None, annotations.get(CHECKIN_CHECKOUT_ANNOTATIONS_KEY))
开发者ID:4teamwork,项目名称:opengever.core,代码行数:7,代码来源:test_checkout.py

示例8: cleanComments

 def cleanComments(self):
     """
     """
     annotations = IAnnotations(self.context)
     if annotations.has_key(self.key):
         del annotations[self.key]
     self._comments = None
开发者ID:collective,项目名称:atreal.filecart,代码行数:7,代码来源:comments.py

示例9: get_member_vote

 def get_member_vote(self, object):
     """ """
     if not IAttributeAnnotatable.providedBy(object):
         alsoProvides(object, IAttributeAnnotatable)
     annotations = IAnnotations(object)
     voters = annotations.get('opkode.rateablediscussion.voters', {})
     return voters.get(self.member.getId(), None)
开发者ID:collective,项目名称:collective.rateablediscussion,代码行数:7,代码来源:comments.py

示例10: has_videos

    def has_videos(self):
        view = getMultiAdapter((self.context, self.request), name='nota')
        videos = []
        if view:
            context_path = '/'.join(self.context.getPhysicalPath())
            query = {'Type': ('Link',)}
            query['path'] = {'query': context_path,
                             'depth': 1, }
            query['sort_on'] = 'getObjPositionInParent'
            query['limit'] = None

            results = self.context.getFolderContents(contentFilter=query,
                                                     batch=False,
                                                     b_size=10,
                                                     full_objects=False)

            for link in results:
                link_obj = link.getObject()
                annotations = IAnnotations(link_obj)
                is_video = annotations.get('thumbnail_pequeno', None)
                if is_video:
                    videos.append({'obj': link,
                                   'url': link_obj.absolute_url() + '/@@thumbnail_mediano'})

        return videos
开发者ID:pradaj9,项目名称:telesur.theme,代码行数:25,代码来源:browser.py

示例11: __init__

 def __init__(self, context):
     self.context = context
     annotations = IAnnotations(context)
     mapping = annotations.get(KEY)
     if mapping is None:
         mapping = annotations[KEY] = PersistentDict({'status' : 'Bad'})
     self.mapping = mapping
开发者ID:syslabcom,项目名称:osha.status,代码行数:7,代码来源:adapters.py

示例12: selectedPacket

    def selectedPacket(self):
        annotations = IAnnotations(self.context)
        packet_key = annotations.get(PACKETS_KEY + '.type')
        packet_fields = annotations.get(PACKETS_KEY + '.fields')
        packet_mapui = annotations.get(PACKETS_KEY + '.mapui')

        return dict(packet_key=packet_key, value=packet_fields.get(packet_mapui.get('codi')), element=packet_fields.get(packet_mapui.get('element')))
开发者ID:UPCnet,项目名称:genweb.packets,代码行数:7,代码来源:views.py

示例13: getContent

 def getContent(self):
     """Get the annotations with the local MLS config."""
     annotations = IAnnotations(self.context)
     return annotations.get(
         CONFIGURATION_KEY,
         annotations.setdefault(CONFIGURATION_KEY, {}),
     )
开发者ID:propertyshelf,项目名称:plone.mls.core,代码行数:7,代码来源:localconfig.py

示例14: get_journal_data

    def get_journal_data(self):
        if IAnnotationsJournalizable.providedBy(self.context):
            annotations = IAnnotations(self.context)
            data = annotations.get(JOURNAL_ENTRIES_ANNOTATIONS_KEY, [])
            return deepcopy(data)

        return []
开发者ID:lukasgraf,项目名称:opengever.core,代码行数:7,代码来源:dossierjournal.py

示例15: update

 def update(self):
     super(ShopArticleListingViewlet, self).update()
     annotations = IAnnotations(self.context)
     current_objs_p_mtime = annotations.get('_objs_p_mtime')
     objs_p_mtime = [obj.image._p_mtime for obj in self._objs()]
     if current_objs_p_mtime != objs_p_mtime:
         annotations['_objs_p_mtime'] = objs_p_mtime
开发者ID:taito,项目名称:slt.theme,代码行数:7,代码来源:viewlet.py


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