; gBc@sdkZdkZdklZlZdkZdkZdklZl Z dk l Z dk l Z lZlZlZdklZlZlZlZlZdklZlZlZlZlZdklZdkl Z l!Z!l"Z"d k#l$Z$d k%l&Z&d k'l(Z(d k)l*Z*d k+l,Z,l-Z-dk.l/Z/dk.l0Z0dk1l2Z2dk3l4Z4dk5l6Z6dk7l8Z8dk9l:Z:dk;l<Z<dk=l>Z>dk?l@Z@dkAlBZBdkCZCdkDlEZFeiGiHeiGiIeJdZKeiGiHeiGiIe>iJdZLeefZMdkNlNZNdeNe(fdYZOe,eOdZPd e*eOfd!YZQe,eQd"fd#YZRe,eRd$e<fd%YZSe,eSd&eSfd'YZTd(e:fd)YZUe,eUd*eUfd+YZVd,eUfd-YZWgZXd.e&fd/YZYe,eYd0eZfd1YZ[d2e0eYe8fd3YZ\d4e0eYe8fd5YZ]e,e]e^e^d6Z_e,e]e^e^d7Z`dS(8N(s StringTypes UnicodeType(slogslog_exc(sIReferenceable(s IReferencesIContentReferencesIReferenceCatalogs IUIDCatalog(suniques make_uuids getRelURLs getRelPathsshasattr(s UID_CATALOGsREFERENCE_CATALOGs UUID_ATTRsREFERENCE_ANNOTATIONs TOOL_NAME(sReferenceException(saq_bases aq_parentsaq_inner(sClassSecurityInfo(sBase(s SimpleItem(s ObjectManager(sInitializeClasssDTMLFile(s getToolByName(s UniqueObject(sCMFCorePermissions(s BTreeFolder2(sPageTemplateFile(sZCatalog(sCatalog(sAbstractCatalogBrain(sCMFCore(s ConflictError(sNotFound(smanage_zcatalog_entriesswwwsdtml(s Referenceables ReferencecBstZeiefZeZdZdZhdd<dd(sselfs sourceUIDs targetUIDs relationship(sself((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pys__repr__TscCstt|tSdS(sthe uid method for compatN(sgetattrsaq_basesselfs UUID_ATTR(sself((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysUIDWscCsgt|t}| odSn|d|i}x/|D]'}|i}|t j o|Sq8q8WdS(NssUID( s getToolByNamesselfs UID_CATALOGstools sourceUIDsbrainssbrains getObjectsobjsNone(sselfsobjsbrainssbrainstool((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysgetSourceObject]s  cCsjt|tt}| odSn|d|i}x/|D]'}|i}|tj o|Sq;q;WdS(NssUID( s getToolByNamesselfs UID_CATALOGsNonestools targetUIDsbrainssbrains getObjectsobj(sselfsobjsbrainssbrainstool((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysgetTargetObjectfs  cCs/|i}|tj o|iSndSdS(Ns(sselfsgetTargetObjectstargetsNonesgetId(sselfstarget((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pystargetIdqs  cCs/|i}|tj o|iSndSdS(Ns(sselfsgetTargetObjectstargetsNonesTitle(sselfstarget((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pys targetTitlews  cCs|iiSdS(N(sselfs __class__s__name__(sself((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysType}scCsdS(N((sselfstools sourceObjects targetObject((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysaddHookscCsdS(N((sselfstools sourceObjects targetObject((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysdelHookscCsdS(sKcalled before target object is deleted so the source can have a sayN((sself((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysbeforeTargetDeleteInformSourcescCsdS(sEcalled when the refering source Object is about to be deletedN((sself((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysbeforeSourceDeleteInformTargetscCstti||||}yt|t}Wn|}t|t}nXt ||i }|i ||dS(N( s Referenceablesmanage_afterAddsselfsitems containersbases getToolByNamesREFERENCE_CATALOGsrcs getRelURLsgetPhysicalPathsurlscatalog_object(sselfsitems containersurlsbasesrc((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysmanage_afterAddscCsHti|||t|t}t||i }|i |dS(N( s Referenceablesmanage_beforeDeletesselfsitems containers getToolByNamesREFERENCE_CATALOGsrcs getRelURLsgetPhysicalPathsurlsuncatalog_object(sselfsitems containersurlsrc((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysmanage_beforeDeletes( s__name__s __module__s Referenceables__implements__s IReferencesClassSecurityInfossecuritys portal_types meta_types SimpleItemsmanage_optionssdeclareProtectedsCMFCorePermissionss ManagePortalsPageTemplateFiles_wwws manage_views__init__s__repr__sUIDsgetSourceObjectsgetTargetObjectstargetIds targetTitlesTypesNonesaddHooksdelHooksbeforeTargetDeleteInformSourcesbeforeSourceDeleteInformTargetsmanage_afterAddsmanage_beforeDelete(((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pys Reference.s, "         scontentsContentReferencecBs]tZdZeiefZdZeZdZ dZ dZ dZ dZ RS(sFSubclass of Reference to support contentish objects inside references cOsti|||dS(N(s References__init__sselfsargsskw(sselfsargsskw((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pys__init__scOst|itdtdfjo)t|d}|i|i|tn/t|t|ittt |t_ dS(Nsus portal_types( stypesselfs contentTypes getToolByNamesttsconstructContentsREFERENCE_CONTENT_INSTANCE_NAMEssetattrsPersistentMappingsgetattrs_md(sselfsargsskwstt((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysaddHooks(  cOsJt|itdtdfjo|itnt|tdS(Nsu(stypesselfs contentTypes _delObjectsREFERENCE_CONTENT_INSTANCE_NAMEsdelattr(sselfsargsskw((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysdelHooks(cCst|iitSdS(N(sgetattrsselfsaq_inners aq_explicitsREFERENCE_CONTENT_INSTANCE_NAME(sself((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysgetContentObjectscCs*ti|||ti|||dS(N(s Referencesmanage_afterAddsselfsitems containers ObjectManager(sselfsitems container((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysmanage_afterAddscCs*ti|||ti|||dS(N(s ObjectManagersmanage_beforeDeletesselfsitems containers Reference(sselfsitems container((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysmanage_beforeDeletes(s__name__s __module__s__doc__s References__implements__sIContentReferences__init__sClassSecurityInfossecuritysaddHooksdelHooksgetContentObjectsmanage_afterAddsmanage_beforeDelete(((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysContentReferences     sContentReferenceCreatorcBs)tZdZeZdZdZRS(s\Helper class to construct ContentReference instances based on a certain content type cCs ||_dS(N(s contentTypesself(sselfs contentType((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pys__init__scOs#t||}|i|_|SdS(N(sContentReferencesargsskwsressselfs contentType(sselfsargsskwsres((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pys__call__s (s__name__s __module__s__doc__sClassSecurityInfossecuritys__init__s__call__(((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysContentReferenceCreators   sUIDCatalogBrainscBs#tZdZeZedZRS(sfried my little brainscCst}y|i}y:t|di}|i|i}t |}Wnt j o nnX| o9|tjo |i }n|i i |i|}n|SWn>t j o n*tidtiddtinXdS(s{ Used to resolve UIDs into real objects. This also must be annotation aware. The protocol is: We have the path to an object. We get this object. If its UID is not the UID in the brains then we need to pull it from the reference annotation and return that object Thus annotation objects store the path to the source object s portal_urlsUIDCatalogBrainssgetObject raised an errorserrorN(sNonesobjsselfsgetPathspaths getToolByNamesgetPortalObjectsportalsunrestrictedTraversesaq_inners ConflictErrorsREQUESTs aq_parents resolve_urlszLOGsLOGsINFOssyssexc_info(sselfsREQUESTsobjsportalspath((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pys getObjects.    (s__name__s __module__s__doc__sClassSecurityInfossecuritysNones getObject(((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysUIDCatalogBrainss  sReferenceCatalogBrainscBstZRS(N(s__name__s __module__(((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysReferenceCatalogBrainsssPluggableCatalogcBstZeZdZRS(NcCsd|i|fdY}|i}|i}t|i|dssReferenceBaseCatalogcBstZeZRS(N(s__name__s __module__sReferenceCatalogBrainss BASE_CLASS(((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysReferenceBaseCatalogAssReferenceResolvercBs&tZeZdZedZRS(NcCsV|id}|ii}y|i|SWn tt t fj o t SnXdS(sStrip path prefix during resolution, This interacts with the default brains.getObject model and allows and fakes the ZCatalog protocol for traversal s/N( spathssplitspartssselfs portal_urlsgetPortalObjects portal_objectsunrestrictedTraversesKeyErrorsAttributeErrorsNotFoundsNone(sselfspathsREQUESTs portal_objectsparts((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pys resolve_url\sc Kstt|dt}| o:t|d}|ii}t |}||_ n|i|}di|}t||f}ti||||dS(svUse the relative path from the portal root as uid Ordinary the catalog is using the path from root towards object but we want only a relative path from the portal root Note: This method could be optimized by improving the calculation of the relative path like storing the portal root physical path in a _v_ var. s_v_portal_path_lens portal_urls/N(sgetattrsaq_basesselfsNonesportal_path_lens getToolByNamesurlToolsgetPortalObjectsgetPhysicalPaths portal_pathslens_v_portal_path_lensobjsrelpathsjoinsuidsreprs__traceback_info__sZCatalogscatalog_objectskwargs( sselfsobjsuidskwargss__traceback_info__surlTools portal_pathsrelpathsportal_path_len((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pyscatalog_objectns   (s__name__s __module__sClassSecurityInfossecuritys resolve_urlsNonescatalog_object(((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysReferenceResolverWs  sIndexableObjectWrappercBs)tZdZdZdZdZRS(s!Wwrapper for object indexing cCs ||_dS(N(sobjsselfs_obj(sselfsobj((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pys__init__scCst|i|SdS(N(sgetattrsselfs_objsname(sselfsname((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pys __getattr__scCsD|ii}yt|SWn tj o|iiSnXdS(N(sselfs_objsTitlestitlesstrsUnicodeDecodeErrorsgetId(sselfstitle((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysTitles (s__name__s __module__s__doc__s__init__s __getattr__sTitle(((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysIndexableObjectWrappers   s UIDCatalogcBstZdZeZeZeZe de Z e i hdd<dd|i|\}}|id|d|}|i|SdS(s(return a collection of reference objectsssids relationshipN( sselfs_uidForsobjectssIDssobjs _queryFors relationshipsbrainss_resolveBrains(sselfsobjects relationshipsbrainsssobjssID((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pys getReferences>scCs>|i|\}}|id|d|}|i|SdS(s(return a collection of reference objectsstids relationshipN( sselfs_uidForsobjectssIDssobjs _queryFors relationshipsbrainss_resolveBrains(sselfsobjects relationshipsbrainsssobjssID((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pysgetBackReferencesDsc Csy|i|\}}|i|\} } |i|| |}x/|D]'}|i }|tj otSqFqFWtSdS(N(sselfs_uidForssourcessIDssobjstargetstIDstobjs _queryFors relationshipsbrainssbrains getObjectsobjsNonesTruesFalse( sselfssourcestargets relationshipsobjsbrainsbrainsssobjssIDstIDstobj((sI/mnt/gmirror/ports/www/zope-archetypes/work/Archetypes/ReferenceEngine.pyshasRelationshipToKs   cCsY|i|\}}|id|}h}x|D]}d||i