當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。