• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python interfaces.IAnnotations类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: openFileReference

def openFileReference(transmogrifier, ref):
    """
    Get an open file handle in one of the following forms:

    * importcontext:file.txt
    * dotted.package:file.txt
    * /file/system/file.txt

    Where "importcontext:" means find the file in the GS import context.
    Return None if there was no file to be found
    """
    if ref.startswith('importcontext:'):
        try:
            from collective.transmogrifier.genericsetup import IMPORT_CONTEXT
            from zope.annotation.interfaces import IAnnotations
            context = IAnnotations(transmogrifier).get(IMPORT_CONTEXT, None)
            (subdir, filename) = os.path.split(ref.replace('importcontext:', ''))
            if subdir == '':
                # Subdir of '' results import contexts looking for a ''
                # directory I think
                subdir = None
            if hasattr(context, "openDataFile"):
                return context.openDataFile(filename, subdir=subdir)
            if hasattr(context, "readDataFile"):
                import StringIO
                return StringIO.StringIO(
                    context.readDataFile(filename, subdir=subdir))
        except ImportError:
            return None
    # Either no import context or not there.
    filename = resolvePackageReferenceOrFile(ref)
    if os.path.isfile(filename):
        return open(filename, 'r')
    return None
开发者ID:tobiasherp,项目名称:collective.transmogrifier,代码行数:34,代码来源:utils.py


示例17: __init__

 def __init__(self, context, request):
     """self:zope.app.pagetemplate.simpleviewclass.SimpleViewClass -> 
                 templates/workspace-index.pt
        context:bungeni.core.content.Section
     """
     LD = IAnnotations(request)["layer_data"]
     assert interfaces.IWorkspaceSectionLayer.providedBy(request)
     assert LD.get("workspaces") is not None
     super(WorkspaceSectionView, self).__init__(context, request)
     cls_name = self.__class__.__name__ 
     # NOTE: Zope morphs this class's name to "SimpleViewClass from ..." 
     log.debug("%s.__init__ %s context=%s url=%s" % (
                         cls_name, self, self.context, request.getURL()))
     
     # transfer layer data items, for the view/template
     self.user_id = LD.user_id
     self.user_group_ids = LD.user_group_ids
     self.government_id = LD.government_id # may be None
     self.ministries = LD.ministries # may be None
     if self.ministries:
         # then, ONLY if an ancestor container is actually a Ministry, 
         # this must be a MinisterWorkspace
         if misc.get_parent_with_interface(self, model_interfaces.IMinistry):
             interface.alsoProvides(self, interfaces.IMinisterWorkspace)
     
     # roles are function of the context, so always recalculate
     roles = get_roles(self.context)
     for role_id in roles:
         iface = self.role_interface_mapping.get(role_id)
         if iface is not None:
             interface.alsoProvides(self, iface)
     log.debug("%s.__init__ %s" % (cls_name, debug.interfaces(self)))
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:32,代码来源:workspace.py


示例18: clean_folder

 def clean_folder(self, catalog, storage_loc):
     if not os.path.isdir(storage_loc):
         return 0
     count = 0
     for foldername in os.listdir(storage_loc):
         if len(foldername) == 1:
             # we're in a container, check inside
             count += self.clean_folder(catalog,
                 os.path.join(storage_loc, foldername))
         else:
             #foldername should be file uid
             brains = catalog(UID=foldername)
             folderpath = os.path.join(storage_loc, foldername)
             if len(brains) == 0:
                 shutil.rmtree(folderpath)
                 count += 1
             else:
                 obj = brains[0].getObject()
                 settings = Settings(obj)
                 if obj.getLayout() != 'documentviewer':
                     if not settings.converting:
                         shutil.rmtree(folderpath)
                         count += 1
                         # also delete settings
                         annotations = IAnnotations(obj)
                         data = annotations.get('collective.documentviewer',
                                                None)
                         if data:
                             del annotations['collective.documentviewer']
                 elif settings.storage_type == 'Blob':
                     shutil.rmtree(folderpath)
                     count += 1
     return count
开发者ID:adam139,项目名称:devplone422,代码行数:33,代码来源:views.py


示例19: handle_layout

    def handle_layout(self):
        """
        This will check if the file does not have the
        document viewer display selected.

        In addition, if the currently selected display
        is for wc.pageturner, we'll clean out the annotations
        from that product. Additionally, we'll also look
        for wildcard.pdfpal related values.
        """
        current = self.context.getLayout()
        if current != 'documentviewer':
            self.context.layout = 'documentviewer'
        annotations = IAnnotations(self.context)
        # remove page turner related
        data = annotations.get('wc.pageturner', None)
        if data:
            del annotations['wc.pageturner']

        # remove pdfpal related
        field = self.context.getField('ocrText')
        if field:
            field.set(self.context, '')

        data = annotations.get('wildcard.pdfpal', None)
        if data:
            del annotations['wildcard.pdfpal']
开发者ID:gbastien,项目名称:collective.documentviewer,代码行数:27,代码来源:convert.py


示例20: _update_AgentInfoPortlet_ProfilePage

    def _update_AgentInfoPortlet_ProfilePage(self, folders, data):
        """Override Annotation for plone.mls.listing AgentInfo inside AgentProfilePages"""
        #get agents portrait/ avatar url
        avatar_url = self.membershiptool.getPersonalPortrait(id=self.userid).absolute_url()
        #get AgencyInfo
        agency = self.__AgencyInfo

        for folder in folders:

            if IAgentFolder.providedBy(folder) and ILocalAgencyInfo.providedBy(folder):
                #get annotations for this folder
                mls_ano = IAnnotations(folder).get("plone.mls.listing.localagencyinfo", None)

                if mls_ano is None:
                    #initialize Annotations
                    anno = IAnnotations(folder)
                    anno.get("plone.mls.listing.localagencyinfo", anno.setdefault("plone.mls.listing.localagencyinfo", {}))
                    mls_ano = IAnnotations(folder).get("plone.mls.listing.localagencyinfo", {})

                # set global Agency Info
                mls_ano['agency_name'] = agency.get('agency_name', u'Krain Real Estate')
                mls_ano['agency_logo_url'] = agency.get('agency_logo_url', u'')
                mls_ano['agency_office_phone'] = agency.get('agency_office_phone', u'')
                mls_ano['agency_website'] = agency.get('agency_website', u'')
                
                #Agent Info
                mls_ano['agent_name'] = data.get('fullname', u'')
                mls_ano['agent_office_phone'] = data.get('office_phone', u'')
                mls_ano['agent_cell_phone'] = data.get('cell_phone', u'')
                mls_ano['agent_email'] = data.get('email', u'')
                mls_ano['agent_avatar_url'] = avatar_url

                #force overrding of Any other agent
                mls_ano['force'] = 'selected'
开发者ID:propertyshelf,项目名称:customer.krainrealestate,代码行数:34,代码来源:CustomizedUserDataPanel.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python interfaces.IAnnotations类代码示例发布时间:2022-05-26
下一篇:
Python annotation.IAnnotations类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap