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


Python IAnnotations.get方法代码示例

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


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

示例1: ContactInfo

# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import get [as 别名]
class ContactInfo(object):
    ''' adapter for IContactInfo '''

    implements(IContactInfo)
    adapts(IPerson)

    def __init__(self, context):
        self.context = context
        self.annotation = IAnnotations(self.context)

    @property
    def emails(self):
        return self.annotation.get('s17.person.emails', [])

    @emails.setter
    def emails(self, value):
        self.annotation['s17.person.emails'] = value

    @property
    def instant_messengers(self):
        return self.annotation.get('s17.person.instant_messengers', [])

    @instant_messengers.setter
    def instant_messengers(self, value):
        self.annotation['s17.person.instant_messengers'] = value

    @property
    def telephones(self):
        return self.annotation.get('s17.person.telephones', [])

    @telephones.setter
    def telephones(self, value):
        self.annotation['s17.person.telephones'] = value
开发者ID:simplesconsultoria,项目名称:s17.person,代码行数:35,代码来源:contact.py

示例2: show

# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import get [as 别名]
    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,代码行数:35,代码来源:adapter.py

示例3: Allocation

# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import get [as 别名]
class Allocation(object):
    ''' adapter for IAllocation '''

    implements(IAllocation)
    adapts(ISession)

    def __init__(self, context):
        self.context = context
        self.annotation = IAnnotations(self.context)

    @property
    def location(self):
        return self.annotation.get('allocation.location', '')

    @location.setter
    def location(self, value):
        self.annotation['allocation.location'] = value

    @property
    def start_date(self):
        return self.annotation.get('allocation.start_date', '')

    @start_date.setter
    def start_date(self, value):
        self.annotation['allocation.start_date'] = value

    @property
    def end_date(self):
        return self.annotation.get('allocation.end_date', '')

    @end_date.setter
    def end_date(self, value):
        self.annotation['allocation.end_date'] = value
开发者ID:plonegovbr,项目名称:conference.program,代码行数:35,代码来源:allocation.py

示例4: check_if_mappings_are_persistent

# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import get [as 别名]
    def check_if_mappings_are_persistent(self):
        check_result = 'PASSED'
        catalog = self.site.portal_catalog

        dossier_brains = catalog(object_provides=IDossierMarker.__identifier__)
        repo_brains = catalog(object_provides=IRepositoryFolder.__identifier__)

        all_brains = []
        all_brains.extend(dossier_brains)
        all_brains.extend(repo_brains)

        for brain in all_brains:
            obj = brain.getObject()
            url = obj.absolute_url()
            ann = IAnnotations(obj)

            if OLD_CODE_BASE:
                child_refs = ann.get(CHILD_REF_KEY)
                prefix_refs = ann.get(PREFIX_REF_KEY)
            else:
                child_refs = self.helper.get_new_mapping(CHILD_REF_KEY, obj)
                prefix_refs = self.helper.get_new_mapping(PREFIX_REF_KEY, obj)

            if child_refs:
                child_refs_persistent = is_persistent(child_refs)
                if not child_refs_persistent:
                    check_result = 'FAILED'
                    self.log("FAILED: child refs not persistent for %s" % url)

            if prefix_refs:
                prefix_refs_persistent = is_persistent(prefix_refs)
                if not prefix_refs_persistent:
                    check_result = 'FAILED'
                    self.log("FAILED: prefix refs not persistent for %s" % url)
        return check_result
开发者ID:4teamwork,项目名称:opengever.maintenance,代码行数:37,代码来源:refnum_selfcheck.py

示例5: move_repository_reference_mappings

# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import get [as 别名]
    def move_repository_reference_mappings(self, obj):
        intids = getUtility(IIntIds)
        annotations = IAnnotations(obj)

        if annotations and annotations.get(CHILD_REF_KEY):
            repository_mapping = PersistentDict(
                {CHILD_REF_KEY: {},
                 PREFIX_REF_KEY: {}})
            dossier_mapping = PersistentDict(
                {CHILD_REF_KEY: {},
                 PREFIX_REF_KEY: {}})

            for number, intid in annotations.get(CHILD_REF_KEY).items():
                try:
                    child = intids.getObject(intid)
                except KeyError:
                    # the object with this intid does not longer exist.
                    continue

                if IDossierMarker.providedBy(child):
                    dossier_mapping[CHILD_REF_KEY][number] = intid
                    dossier_mapping[PREFIX_REF_KEY][intid] = number
                else:
                    repository_mapping[CHILD_REF_KEY][number] = intid
                    repository_mapping[PREFIX_REF_KEY][intid] = number

            # save mapping
            annotations[REPOSITORY_FOLDER_KEY] = repository_mapping
            annotations[DOSSIER_KEY] = dossier_mapping

            # drop old mapings
            annotations.pop(CHILD_REF_KEY)
            annotations.pop(PREFIX_REF_KEY)
开发者ID:pemzurigo,项目名称:opengever.core,代码行数:35,代码来源:to2601.py

示例6: fix_dossier

# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import get [as 别名]
    def fix_dossier(self, dossier):
        intid = self.intid_utility.getId(dossier)
        parent = aq_parent(aq_inner(dossier))

        former_reference_number = IDossier(dossier).former_reference_number
        if not former_reference_number:
            print 'SKIPPED Dosier ({}{}) created at '.format(
                '/'.join(dossier.getPhysicalPath()), dossier.created())
            return
        former_prefix = former_reference_number.split('-')[-1].split('.')[-1]

        ref_mapping = IAnnotations(parent).get('dossier_reference_mapping')
        old_prefix = former_prefix
        new_prefix = ref_mapping.get('reference_prefix').get(intid)

        # check if former_reference_number is registered for current dossier
        if ref_mapping.get('reference_numbers').get(former_prefix) != intid:
            print 'Check failed'
            import pdb; pdb.set_trace()
        else:
            # free new prefix (remove it from the numbers list)
            ref_mapping['reference_numbers'].pop(new_prefix)

        # set old prefix as current
        ref_mapping['reference_prefix'][intid] = old_prefix.decode('utf-8')

        print '{} --> {} ({})'.format(new_prefix, old_prefix,
                                      '/'.join(dossier.getPhysicalPath()))

        self.reindex_dossier_and_children(dossier)
开发者ID:4teamwork,项目名称:opengever.maintenance,代码行数:32,代码来源:02_fix_reference_number_after_rename.py

示例7: handle_layout

# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import get [as 别名]
    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,代码行数:29,代码来源:convert.py

示例8: addAnnotation

# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import get [as 别名]
def addAnnotation(object, recipients):
    """ Add annotation after change state and send mail
    """
    KEY = 'genweb.rectorat.logMail'

    annotations = IAnnotations(object)

    if annotations is not None:

        logData = annotations.get(KEY, None)

        try:
            len(logData)
            # Get data and append values
            data = annotations.get(KEY)
        except:
            # If it's empty, initialize data
            data = []

        dateMail = datetime.now()
        username = api.user.get_current().id

        values = dict(dateMail=dateMail,
                      fromMail="Sessió convocada per: " + str(username),
                      toMail=', '.join(map(str, recipients)))

        data.append(values)
        annotations[KEY] = data
开发者ID:UPCnet,项目名称:genweb.rectorat,代码行数:30,代码来源:change.py

示例9: render

# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import get [as 别名]
    def render(self):
        context = self.context
        annotations = IAnnotations(context)
        status = annotations.get(STATUS_STORAGE_KEY, None)
        named_file = annotations.get(DATA_STORAGE_KEY, None)
        if status == TASK_IN_PROGRESS:
            return PORTAL_MESSAGE % {'statusid': 'info',
                                     'status': PMF(u"Info"),
                                     'msg': _(u"Processing document generation, please refresh the page...")}
        elif status == TASK_FAILED:
            return PORTAL_MESSAGE % {'statusid': 'warning',
                                     'status': PMF(u"Error"),
                                     'msg': _(u"Document generation failed, please retry or contact your administrator")}
        elif not status:
            return u""

        url = u"%s/getdocumentfusion" % context.absolute_url()
        title = translate(_(u"Get the generated file."), context=self.request)

        mtregistry = getToolByName(self.context, 'mimetypes_registry')
        file_name = named_file.filename
        mimetype = mtregistry.lookupExtension(file_name)
        icon_path = "%s/%s" % (self.portal_url, mimetype.icon_path)
        return u"""
        <div id="generated-pdf">
          <a href="%s" title="%s">
            <img src="%s" /> %s
          </a>
        </div>""" % (url, title, icon_path, file_name)
开发者ID:cedricmessiant,项目名称:collective.documentfusion,代码行数:31,代码来源:views.py

示例10: cropped_image

# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import get [as 别名]
    def cropped_image(self, field, id_name):
        """Retuns html tag for the cropped image.

        :param field: Field name.
        :type field: str

        :param id_name: ID name.
        :type id_name: str
        """
        context = aq_inner(self.context)
        anno = IAnnotations(context)
        name = 'collective.cropimage.{0}'.format(field)
        data = anno[name][id_name] if anno.get(name) is not None and anno.get(name).get(id_name) is not None else None
        if data is not None:
            width = 'width:{0}px;'.format(data['w'])
            height = 'height:{0}px;'.format(data['h'])
            html = '<div class="crop" style="{0}{1}">'.format(width, height)
            clip = 'clip:rect({0}px {1}px {2}px {3}px);'.format(data['y1'], data['x2'], data['y2'], data['x1'])
            top = 'top:-{0}px;'.format(data['y1'])
            left = 'left:-{0}px;'.format(data['x1'])
            html += '<p style="{0}{1}{2}">'.format(clip, top, left)
            src = '{0}/{1}'.format(context.absolute_url(), field)
            title = context.Title()
            html += '<img src="{0}" alt="{1}" title="{1}" />'.format(src, title)
            html += '</p>'
            html += '</div>'
            return html
开发者ID:taito,项目名称:collective.cropimage,代码行数:29,代码来源:miscellaneous.py

示例11: test_annotations_key_is_cleared

# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import get [as 别名]
    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,代码行数:9,代码来源:test_checkout.py

示例12: Journalist

# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import get [as 别名]
class Journalist(object):
    """Stores the extra fields in the anotation
    """
    implements(IJournalist)
    adapts(IPerson)

    def __init__(self, context):
        self.context = context
        self.annotation = IAnnotations(self.context)

    @property
    def email(self):
        return self.annotation.get('s17.person.journalist_email', u"")

    @email.setter
    def email(self, value):
        self.annotation['s17.person.journalist_email'] = value

    @property
    def resume(self):
        return self.annotation.get('s17.person.resume', u"")

    @resume.setter
    def resume(self, value):
        self.annotation['s17.person.resume'] = value

    @property
    def signature(self):
        return self.annotation.get('s17.person.signature', u"")

    @signature.setter
    def signature(self, value):
        self.annotation['s17.person.signature'] = value
开发者ID:simplesconsultoria,项目名称:sc.behavior.journalist,代码行数:35,代码来源:behaviors.py

示例13: WorkflowState

# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import get [as 别名]
class WorkflowState(object):
    state_key = "hurry.workflow.state"
    id_key = "hurry.workflow.id"

    def __init__(self, context):
        # XXX okay, I'm tired of it not being able to set annotations, so
        # we'll do this. Ugh.
        from zope.security.proxy import removeSecurityProxy
        self.context = removeSecurityProxy(context)
        self._annotations = IAnnotations(self.context)

    def initialize(self):
        wf_versions = component.queryUtility(IWorkflowVersions)
        if wf_versions is not None:
            self.setId(wf_versions.createVersionId())

    def setState(self, state):
        if state != self.getState():
            self._annotations[self.state_key] = state

    def setId(self, id):
        # XXX catalog should be informed (or should it?)
        self._annotations[self.id_key] = id

    def getState(self):
        return self._annotations.get(self.state_key, None)

    def getId(self):
        return self._annotations.get(self.id_key, None)
开发者ID:zopefoundation,项目名称:hurry.workflow,代码行数:31,代码来源:workflow.py

示例14: _update_AgentInfoPortlet_ProfilePage

# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import get [as 别名]
    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,代码行数:36,代码来源:CustomizedUserDataPanel.py

示例15: License

# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import get [as 别名]
class License(object):
    """
        This class adds two Dublin Core Fields to content for storing the copyright
        license, and the holder of the copyright
    """
    implements(ILicense)

    def __init__(self, context):
        self.context = context
        self.annotations = IAnnotations(context)
        rightsLicense = self.annotations.get(RIGHTSLICENSE_KEY, None)
        if rightsLicense is None:
            self.annotations[RIGHTSLICENSE_KEY] = ['Site Default', 'None', 'None', 'None']
        rightsHolder = self.annotations.get(RIGHTSHOLDER_KEY, None)
        if rightsHolder is None:
            self.annotations[RIGHTSHOLDER_KEY] = '(site default)'

    def getRightsLicense(self):
        """ Get the contents of the DC.rights.license field. """
        return self.annotations[RIGHTSLICENSE_KEY]

    def setRightsLicense(self, ldata):
        """ Set the DC.rights.license field. """
        self.annotations[RIGHTSLICENSE_KEY] = ldata

    def getRightsHolder(self):
        """ Get the contents of the DC.rightsHolder field. """
        return self.annotations[RIGHTSHOLDER_KEY]

    def setRightsHolder(self, rhdata):
        """ Set the DC.rightsHolder field. """
        self.annotations[RIGHTSHOLDER_KEY] = rhdata

    license = property(fget=getRightsLicense, fset=setRightsLicense)
开发者ID:dtgit,项目名称:dtedu,代码行数:36,代码来源:terms.py


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