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


Python interfaces.IReferenceable类代码示例

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


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

示例1: working_copy

 def working_copy(self):
     adapted = IReferenceable(self.context, None)
     if adapted is None:
         return None
     refs = adapted.getBRefs(WorkingCopyRelation.relationship)
     if len(refs) > 0:
         return refs[0]
     else:
         return None
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:9,代码来源:info.py

示例2: get_references

    def get_references(self):
        """ AT references
        """
        try:
            from Products.Archetypes.interfaces import IReferenceable
            if not IReferenceable.providedBy(self.context):
                return
        except:
            return

        self['_atrefs'] = {}
        self['_atbrefs'] = {}
        relationships = self.context.getRelationships()
        for rel in relationships:
            self['_atrefs'][rel] = []
            refs = self.context.getRefs(relationship=rel)
            for ref in refs:
                if ref is not None:
                    self['_atrefs'][rel].append('/'.join(ref.getPhysicalPath()))
        brelationships = self.context.getBRelationships()
        for brel in brelationships:
            self['_atbrefs'][brel] = []
            brefs = self.context.getBRefs(relationship=brel)
            for bref in brefs:
                if bref is not None:
                    self['_atbrefs'][brel].append('/'.join(bref.getPhysicalPath()))
开发者ID:atreal,项目名称:collective.jsonify,代码行数:26,代码来源:wrapper.py

示例3: _notifyOfCopyTo

    def _notifyOfCopyTo(self, container, op=0):
        """In the case of a move (op=1) we need to make sure
        references are mainained for all referencable objects within
        the one being moved.

        manage_renameObject calls _notifyOfCopyTo so that the
        object being renamed doesn't lose its references. But
        manage_renameObject calls _delObject which calls
        manage_beforeDelete on all the children of the object
        being renamed which deletes all references for children
        of the object being renamed. Here is a patch that does
        recursive calls for _notifyOfCopyTo to address that
        problem.
        """
        # XXX this doesn't appear to be necessary anymore, if it is
        # it needs to be used in BaseBTreeFolder as well, it currently
        # is not.
        BaseObject._notifyOfCopyTo(self, container, op=op)
        # keep reference info internally when op == 1 (move)
        # because in those cases we need to keep refs
        if op==1:
            self._v_cp_refs = 1
        for child in self.contentValues():
            if IReferenceable.providedBy(child):
                child._notifyOfCopyTo(self, op)
开发者ID:dtgit,项目名称:dtedu,代码行数:25,代码来源:BaseFolder.py

示例4: checkout_allowed

    def checkout_allowed(self):
        """Check if a checkout is allowed.
        """
        context = aq_inner(self.context)
        checkPermission = getSecurityManager().checkPermission
        
        if not interfaces.IIterateAware.providedBy(context):
            return False
        
        if not IReferenceable.providedBy(context):
            return False

        archiver = interfaces.IObjectArchiver(context)
        if not archiver.isVersionable():
            return False

        # check if there is an existing checkout
        if len(context.getBRefs(WorkingCopyRelation.relationship)) > 0:
            return False
        
        # check if it is a checkout or contains a checkout
        if recursivelyCheckForWorkingCopies(context):
            return False

        # check if it is contained by a checkout
        if recursivelyCheckParentsForWorkingCopies(context):
            return False

        # check the permission
        if not checkPermission(permissions.CheckoutPermission, context):
            return False
        
        return True
开发者ID:tdenny,项目名称:plone.app.iterate,代码行数:33,代码来源:control.py

示例5: update_links

def update_links(event):
    obj = event.object
    if is_outdated(obj) or not is_publically_visible(obj):
        return
    temporary = hasattr(obj, 'meta_type') and \
        obj.meta_type == TempFolder.meta_type
    if temporary:
        # Objects that are temporary (read: portal_factory) and do not have a
        # (stable) URL (yet) do not need to be crawled: relative links will be
        # off quickly and we can't really use the UID anyway.
        return
    try:
        link_checker = getToolByName(obj, 'portal_linkchecker').aq_inner
    except AttributeError:
        return
    if not link_checker.active:
        return
    retriever = IRetriever(obj, None)
    if retriever is not None:
        sm = getSecurityManager()
        if not sm.checkPermission(ModifyPortalContent, obj):
            return
        if (not IReferenceable.providedBy(obj)):
            return
        async = getUtility(IAsyncService)
        tpath = '/'.join(obj.getPhysicalPath())
        job = async.queueJob(retrieve_async, obj, tpath, online=True)
        callback = job.addCallbacks(failure=job_failure_callback)
        callback  # for pep
开发者ID:EU-OSHA,项目名称:osha.policy,代码行数:29,代码来源:handlers.py

示例6: transmogrify

    def transmogrify(self, item):
        path = self.get_path(item)
        obj = self.get_object(item)

        uid = item.get(self.uidkey, "")
        if not uid:
            raise NothingToDoHere

        at_uid = ATIReferenceable.providedBy(obj)
        dx_uid = DXIReferenceable.providedBy(obj)

        old_uid = obj.UID()
        if old_uid != uid:
            # Code from plone.app.transmogrifier used for AT objects:
            if at_uid:
                if not old_uid:
                    setattr(obj, AT_UUID_ATTR, uid)
                else:
                    obj._setUID(uid)
            elif dx_uid:
                setattr(obj, DX_UID_ATTR, uid)
            else: #Don't ask, JUST DO IT!
                  # If the attribute is not used as UID, it
                  # is not used as anything else as well,
                  # and at least the desired UID value stays recorded in the
                  # object, allowing for a post-migration retrieval
                setattr(obj, DEFAULT_UID_ATTR, uid)
        return item
开发者ID:simplesconsultoria,项目名称:sc.transmogrifier,代码行数:28,代码来源:universal_uid_updater.py

示例7: __iter__

    def __iter__(self):

        for item in self.previous:

            pathkey = self.pathkey(*item.keys())[0]
            uidkey = self.uidkey(*item.keys())[0]

            if not pathkey or not uidkey:  # not enough info
                yield item
                continue

            path = item[pathkey]
            uid = item[uidkey]

            obj = traverse(self.context, str(path).lstrip('/'), None)
            if obj is None:  # path doesn't exist
                yield item
                continue

            if IReferenceable.providedBy(obj):
                oldUID = obj.UID()
                if oldUID != uid:
                    if not oldUID:
                        setattr(obj, UUID_ATTR, uid)
                    else:
                        obj._setUID(uid)

            if IAttributeUUID.providedBy(obj):
                IMutableUUID(obj).set(uid)

            yield item
开发者ID:collective,项目名称:plone.app.transmogrifier,代码行数:31,代码来源:uidupdater.py

示例8: getObjectsFromLinks

def getObjectsFromLinks(base, links):
    """ determine actual objects refered to by given links """
    objects = set()
    url = base.absolute_url()
    scheme, host, path, query, frag = urlsplit(url)
    for link in links:
        s, h, path, q, f = urlsplit(link)
        # relative or local url
        if (not s and not h) or (s == scheme and h == host):
            # Paths should always be strings
            if isinstance(path, unicode):
                path = path.encode('utf-8')

            obj, extra = findObject(base, path)
            if obj:
                if IOFSImage.providedBy(obj):
                    # use atimage object for scaled images
                    obj = aq_parent(obj)
                if not IReferenceable.providedBy(obj):
                    try:
                        obj = IReferenceable(obj)
                    except:
                        continue
                objects.add(obj)
    return objects
开发者ID:urska19,项目名称:Plone-test,代码行数:25,代码来源:handlers.py

示例9: beforeChange_at_uuid

 def beforeChange_at_uuid(self):
     """Load AT universal uid."""
     self._checkLoadAttr('UID')
     if IReferenceable.providedBy(self.old):
         self.UID = self.old.UID()
         self.old._uncatalogUID(self.parent)
     else:
         self.UID = None
开发者ID:plone,项目名称:Products.contentmigration,代码行数:8,代码来源:inplace.py

示例10: getuid

 def getuid(self):
     if HAS_PLONE_UUID:
         uid = IUUID(self.context, None)
         if uid is not None:
             return uid
     if HAS_AT:
         if IReferenceable.providedBy(self.context):
             return self.context.UID()
     return None
开发者ID:collective,项目名称:collective.inviting,代码行数:9,代码来源:item.py

示例11: prepareIterateObjectTabs

 def prepareIterateObjectTabs(self, *args, **kwargs):
     tabs = self.prepareObjectTabs(*args, **kwargs)
     
     if IReferenceable.providedBy(self.context):
         iterate_control = plone.app.iterate.browser.control.Control(self.context, self.request)
         if tabs and iterate_control.checkout_allowed():
             for tab in [e for e in tabs if e['id'] == 'edit']:
                 tab['url'] = self.context.absolute_url() + '/@@content-checkout'
      
     return tabs
开发者ID:ceko,项目名称:ceko.iterate,代码行数:10,代码来源:viewlets.py

示例12: getSourceId

 def getSourceId(self, name, filename, instance, fresh=False):
     sid = ''
     if IReferenceable.providedBy(instance):
         sid = sid + instance.UID()
     sid = "%s_%s" % (sid, self.make_prefix())
     sid = "%s_%s" % (sid, name)
     fname = self.getNormalizedName(filename)
     if fname:
         sid = '%s_%s' % (sid, fname)
     return sid
开发者ID:quintagroup,项目名称:collective.contentfiles2aws,代码行数:10,代码来源:storage.py

示例13: migrate_at_uuid

 def migrate_at_uuid(self):
     """Migrate AT universal uid
     """
     if not IReferenceable.providedBy(self.old):
         return  # old object doesn't support AT uuids
     uid = self.old.UID()
     self.old._uncatalogUID(self.parent)
     if queryAdapter(self.new, IMutableUUID):
         IMutableUUID(self.new).set(str(uid))
     else:
         self.new._setUID(uid)
开发者ID:jean,项目名称:Products.contentmigration,代码行数:11,代码来源:migrator.py

示例14: test_upgrade

 def test_upgrade(self):
     doc3 = self.portal['doc3']
     doc1 = self.portal['doc1']
     self.assertTrue(IReferenceable.providedBy(doc3))
     doc3.setText('<a href="doc1">doc1</a>', mimetype='text/html')
     doc3.addReference(doc1, relationship=referencedRelationship)
     self.assertFalse(hasIncomingLinks(doc1))
     self.assertFalse(hasIncomingLinks(doc3))
     migrate_linkintegrity_relations(self.portal)
     self.assertTrue(hasIncomingLinks(doc1))
     self.assertFalse(hasIncomingLinks(doc3))
开发者ID:FHNW,项目名称:plone.app.linkintegrity,代码行数:11,代码来源:test_upgrade.py

示例15: migrate_at_uuid

 def migrate_at_uuid(self):
     """Migrate AT universal uid
     """
     if not IReferenceable.providedBy(self.old):
         return  # old object doesn't support AT uuids
     uid = self.old.UID()
     self.old._uncatalogUID(self.parent)
     if UUID_ATTR:  # Prevent object deletion triggering UID related magic
         setattr(self.old, UUID_ATTR, None)
     if queryAdapter(self.new, IMutableUUID):
         IMutableUUID(self.new).set(str(uid))
     else:
         self.new._setUID(uid)
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:13,代码来源:migrator.py


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