mò .á¸Ec@sdZdklZdklZdklZdklZdklZdk l Z dk l Z l Z lZlZdklZd klZd klZd kZd klZlZd klZdklZdklZl Z e!ƒZ"dfd„ƒYZ#ee#ƒd„Z$d S(ssThis module implements a mix-in for traversable objects. $Id: Traversable.py 70153 2006-09-13 16:16:02Z tseaver $ (squote(sInitializeClass(sClassSecurityInfo(sgetSecurityManager(s Unauthorized(sguarded_getattr(sAcquiredsaq_inners aq_parentsaq_base(sNotFound(s ConflictError(s ITraversableN(s implementss Interface(squeryMultiAdapter(sTraversalError(snsParsesnamespaceLookupt TraversablecBs¾tZeeƒeƒZeidƒdd„Zeidƒd„Zeidƒd„Z ei dƒe Z eid ƒd „Z ei d ƒeed „Zeid ƒed„ZRS(Nt absolute_urlicCs_|o|iƒSn|iƒ}y|ii}Wn!tj ot |dƒSnX||ƒS(s{Return the absolute URL of the object. This a canonical URL based on the object's physical containment path. It is affected by the virtual host configuration, if any, and can be used by external agents, such as a browser, to address the object. If the relative argument is provided, with a true value, then the value of virtual_url_path() is returned. Some Products incorrectly use '/'+absolute_url(1) as an absolute-path reference. This breaks in certain virtual hosting situations, and should be changed to use absolute_url_path() instead. iN( trelativetselftvirtual_url_pathtgetPhysicalPathtspptREQUESTtphysicalPathToURLttoUrltAttributeErrortpath2url(RRRR ((t./data/zmath/zope/lib/python/OFS/Traversable.pyR-s tabsolute_url_pathcCsZ|iƒ}y|ii}Wn$tj ot|ƒpdSnX||ddƒpdS(s½Return the path portion of the absolute URL of the object. This includes the leading slash, and can be used as an 'absolute-path reference' as defined in RFC 2396. t/RiN(RRRRRR R R (RRR ((R R Is RcCsP|iƒ}y|ii}Wn!tj ot|dƒSnXt||ƒƒS(sReturn a URL for the object, relative to the site root. If a virtual host is configured, the URL is a path relative to the virtual host's root object. Otherwise, it is the physical path. In either case, the URL does not begin with a slash. iN(RRRRtphysicalPathToVirtualPathttoVirtR R (RRR((R RWs tgetPhysicalRootRcCsF|iƒf}tt|ƒƒ}|dj o|iƒ|}n|S(s%Get the physical path of the object. Returns a path (an immutable sequence of strings) that can be used to access this object again later, for example in a copy/paste operation. getPhysicalRoot() and getPhysicalPath() are designed to operate together. N(RtgetIdtpatht aq_parenttaq_innertptNoneR(RRR((R Ris  tunrestrictedTraversecCsÔ|p|Snt|tƒo|idƒ}n t|ƒ}hd|<} |iƒ|i} t |ƒdjo|d o| dƒn|ot ƒi } n|dpE| ƒ|iƒ} |o'| d d d | ƒ ot|ƒ‚qún|} t}y™xŽ|o†| ƒ}||f} |ddjo t|‚n|djoXt| ƒ}|d j o;|o'| | | ||ƒ ot|ƒ‚n|} qq¥nt| dd ƒ}y´|o´|d d jo£|d jo–t|ƒ\}}|oyySt||| |iƒi| ƒ}|o'| | | ||ƒ ot|ƒ‚nWqqt j ot!|ƒ‚qqXqjnö|d j o|| |ƒ}|oøt"|ƒ|j ott#|ƒƒ}nVt|d d ƒd j o |i%}n0tt"| ƒ|tƒ|jo | }nd }y| | |||ƒ}Wntj o t'}nX|p:|d j pt(| |tƒ|j ot|ƒ‚qŒqqjn×tt"| ƒ|tƒtj o-|ot(| |ƒ}qjt| |ƒ}n‹y:| |}t|t)i*i*ƒo|}t+|ƒ‚nWnt!j ot|ƒ‚nX|o'| | | d |ƒ ot|ƒ‚nWnt!tt+fj o}t-| |ift.|ƒ}|d j oA|i| ƒ}|o'| | | ||ƒ ot|ƒ‚q„q‰|d j o |‚q‰y3|ot(| |tƒ}nt| |tƒ}Wnt!j o |‚nX|tjo!|}|tjo |‚q„q‰nX|} qW| SWn4t/j o ‚n |tj o|SqЂnXd S( scLookup an object by path. path -- The path to the object. May be a sequence of strings or a slash separated string. If the path begins with an empty path element (i.e., an empty string or a slash) then the lookup is performed from the application root. Otherwise, the lookup is relative to self. Two dots (..) as a path element indicates an upward traversal to the acquisition parent. default -- If provided, this is the value returned if the path cannot be traversed for any reason (i.e., no object exists at that path or the object is inaccessible). restricted -- If false (default) then no security checking is performed. If true, then all of the objects along the path are validated with the security machinery. Usually invoked using restrictedTraverse(). RtTraversalRequestNameStackiiiÿÿÿÿt_s..t__bobo_traverse__s@+t+tim_selfN(1RRt isinstancetstrtsplittlistRtreversetpoptpath_poptlent restrictedtgetSecurityManagertvalidateRtobjRt Unauthorizedtnamet_markertresourcet__traceback_info__tNotFoundRtnexttgetattrt bobo_traversetnsParsetnstnmtnamespaceLookupt__of__tTraversalErrorR taq_baseRt containerRtoktFalsetguarded_getattrtwebdavt NullResourcetKeyErrortetqueryMultiAdaptert Interfacet ConflictErrortdefault(RRRER&R:R5R0R;R4R$RR.R)R(R-R+R2RA((R RzsÎ            %!    &          trestrictedTraversecCs|i||dtƒS(NR&(RRRREtTrue(RRRE((R RF+s(t__name__t __module__t implementst ITraversabletClassSecurityInfotsecurityt declarePublicRR RtdeclarePrivatetAcquiredRRR,R<RRF(((R R's            ° cCsditt|ƒƒS(NR(tjointmaptquoteR(R((R R 2s(%t__doc__turllibRStGlobalstInitializeClasst AccessControlRLR'R*tAccessControl.ZopeGuardsR=t AcquisitionRPRRR9t zExceptionsR/tZODB.POSExceptionRDtOFS.interfacesRKR>tzope.interfaceRJRCtzope.componentRBtzope.traversing.interfacesR8tzope.traversing.namespaceR3R6tobjectR,RR (R>RDR=RR6RBR8RKRCR3RR,R9R*RSRLRWR RRJR/RPR'((R t?s(             ÿ