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

Python interfaces.IAnnotations类代码示例

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

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



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

示例1: registerPersistentConfig

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
开发者ID:kroman0,项目名称:products,代码行数:26,代码来源:exportimport.py


示例2: migrate

    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'
开发者ID:socialplanning,项目名称:opencore-listen,代码行数:60,代码来源:migrations.py


示例3: __init__

 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
开发者ID:socialplanning,项目名称:opencore,代码行数:8,代码来源:pending_requests.py


示例4: __init__

 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
开发者ID:socialplanning,项目名称:opencore,代码行数:8,代码来源:historyview.py


示例5: __init__

 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
开发者ID:socialplanning,项目名称:opencore,代码行数:8,代码来源:home_page.py


示例6: __init__

 def __init__(self, context):
     self.context = context
     key = str(context)
     annotations = IAnnotations(context)
     storage = annotations.setdefault(ANNOT_KEY,
                                      PersistentMapping())
     storage.setdefault('hmac_key', key)
     self.storage = storage
开发者ID:a25kk,项目名称:stv2,代码行数:8,代码来源:password_hashers.py


示例7: clearMemoCache

 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()
开发者ID:socialplanning,项目名称:opencore,代码行数:9,代码来源:openplanstestcase.py


示例8: __init__

 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'] = ""
开发者ID:kroman0,项目名称:products,代码行数:9,代码来源:adapters.py


示例9: addPath

 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
开发者ID:wpjunior,项目名称:proled,代码行数:10,代码来源:__init__.py


示例10: __init__

 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
开发者ID:catalinmititiuc,项目名称:eea.design,代码行数:10,代码来源:page_design_view.py


示例11: LoggerSection

class LoggerSection(object):
    classProvides(ISectionBlueprint)
    implements(ISection)

    def __init__(self, transmogrifier, name, options, previous):
        self.transmogrifier = transmogrifier
        keys = options.get('keys') or ''
        self.pathkey = options.get('path-key', '_path').strip()
        self.keys = Matcher(*keys.splitlines())
        self.previous = previous
        self.logger = name
        self.storage = IAnnotations(transmogrifier).setdefault(VALIDATIONKEY, [])

    def __iter__(self):
        start_time = time()
        count = 0
        problematic = 0
        for item in self.previous:
            # source sections add store path of current generated item in annotation
            # it gives posibility to monitor what items go through all pipeline
            # sections between source section and this section and what don't
            if self.pathkey in item and item[self.pathkey] in self.storage:
                self.storage.remove(item[self.pathkey])
            count += 1
            # print item data stored on keys given as option
            items = []
            for key in item.keys():
                if self.keys(key)[0] is not None:
                    items.append("%s=%s" % (key, item[key]))
            if items:
                msg = ", ".join(items)
                logging.getLogger(self.logger).info(msg)
            yield item
        
        working_time = int(round(time() - start_time))

        # log items that maybe have some problems
        if self.storage:
            problematic = len(self.storage)
            logging.getLogger(self.logger).warning('\nNext objects didn\'t go through full pipeline:\n%s' % \
                '\n'.join(['\t'+i for i in self.storage]))
        # delete validation data from annotations
        anno = IAnnotations(self.transmogrifier)
        if VALIDATIONKEY in anno:
            del anno[VALIDATIONKEY]

        seconds = working_time % 60
        minutes = working_time / 60 % 60
        hours = working_time / 3600
        stats = "\nPipeline processing time: %02d:%02d:%02d\n" % (hours, minutes, seconds)
        stats += "\t%4d items were generated in source sections\n" % (count + problematic)
        stats += "\t%4d went through full pipeline\n" % count
        stats += "\t%4d were discarded in some section" % problematic
        logging.getLogger(self.logger).info(stats)
开发者ID:kroman0,项目名称:products,代码行数:54,代码来源:logger.py


示例12: capture

    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
开发者ID:collective,项目名称:getpaid.virtualmerchant,代码行数:12,代码来源:virtualmerchant.py


示例13: testExportNodeWithAnnotation

 def testExportNodeWithAnnotation(self):
     """
     when membrane tool is annotated, hash-type node should get exported
     attribute 'name' on the node should contain the hash-type
     """
     # initially add the annotation on to the membrane_tool
     annot = IAnnotations(self.portal.membrane_tool)
     annot.setdefault(ANNOT_KEY, {})['hash_type'] = 'bcrypt'
     node = self.adapter._exportNode()
     self.failUnless('<hash-type name="bcrypt"/>' in node.toxml())
     # clear the bogus annotation
     del annot[ANNOT_KEY]
开发者ID:a25kk,项目名称:stv2,代码行数:12,代码来源:test_install.py


示例14: save_import_history

 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)
开发者ID:socialplanning,项目名称:opencore-listen,代码行数:13,代码来源:import_export.py


示例15: removePath

 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]
开发者ID:wpjunior,项目名称:proled,代码行数:13,代码来源:__init__.py


示例16: authenticated_memberid

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
开发者ID:socialplanning,项目名称:opencore,代码行数:14,代码来源:indexing.py


示例17: GEOMap

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
开发者ID:kroman0,项目名称:products,代码行数:34,代码来源:geomap.py


示例18: GEOLocated

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)
开发者ID:kroman0,项目名称:products,代码行数:35,代码来源:geolocation.py


示例19: _extractQueryIndexMap

    def _extractQueryIndexMap(self):
        fragment = self._doc.createDocumentFragment()
        annots = IAnnotations(self.context)
        query_index_map = annots.get(QIM_ANNOT_KEY)
        if query_index_map is not None:
            child = self._doc.createElement('query_index_map')
            
            for key, value in query_index_map.items():
                sub = self._doc.createElement('index')
                sub.setAttribute('name', key)
                inner = self._doc.createTextNode(value)
                sub.appendChild(inner)
                child.appendChild(sub)

            fragment.appendChild(child)
        return fragment
开发者ID:a25kk,项目名称:stv2,代码行数:16,代码来源:membranetool.py


示例20: post_validate

    def post_validate(self, REQUEST, errors):
        form = REQUEST.form
        if form.has_key("password") or form.has_key("confirmPassword"):
            password = form.get("password", None)
            confirm = form.get("confirmPassword", None)

            annotations = IAnnotations(self)
            passwordDigest = annotations.get(PASSWORD_KEY, None)

            if not passwordDigest:
                if not password and not confirm:
                    errors["password"] = u"An initial password must be set"
                    return
            if password or confirm:
                if password != confirm:
                    errors["password"] = errors["confirmPassword"] = u"Passwords do not match"
开发者ID:marchon,项目名称:Journal-Commons,代码行数:16,代码来源:gcPerson.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python hooks.getSite函数代码示例发布时间:2022-05-26
下一篇:
Python interfaces.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