mò /á¸Ec@s×dZdkZdkZdklZdkZdklZdkl Z dkl Z dk l Z dk l Z dk lZd k lZd k lZd k lZd klZd klZlZdklZlZlZdklZdklZdkZdk Z dk!l"Z"l#Z#l$Z$l%Z%l&Z&dk!l'Z'dk!l(Z(dk!l)Z)l*Z*l+Z+dk,l-Z-dk,l.Z.dk/l/Z/dk0l1Z1dk2l3Z3dk4Z5dei6e i7fd„ƒYZ8ee8ƒdS(sVWebDAV support - resource objects. $Id: Resource.py 69725 2006-08-22 10:55:38Z shh $ N(sunquote(sInitializeClass(sgetSecurityManager(sClassSecurityInfo(sdelete_objects(smanage_properties(sview(swebdav_lock_items(swebdav_unlock_items(s webdav_access(saq_base(s BadRequestsMethodNotAllowed(s Unauthorizeds ForbiddensNotFound(s implements(sHTTPRangeInterface(sabsattrsurlfixs rfc1123_dates tokenFindersurlbase(sIfParser(sisDavCollection(sLockedsConflictsPreconditionFailed(s IDAVResource(s IWriteLock(sWriteLockInterface(snotify(sObjectClonedEventtResourcecBs–tZdZeeƒdZd&ZeƒZei e d'ƒd„Z d„Z dde dd„Zeiedƒd„Zd„Zeidƒd„Zeidƒd„Zeiedƒd„Zeie d ƒd„Zeied ƒd„Zd„Zeid ƒd„Zeid ƒd„Zeiedƒd „Zeie dƒd!„Z!eie d"ƒd#„Z"eie d$ƒd%„Z#RS((s%The Resource mixin class provides basic WebDAV support for non-collection objects. It provides default implementations for most supported WebDAV HTTP methods, however certain methods such as PUT should be overridden to ensure correct behavior in the context of the object type.itGETtHEADtPOSTtPUTtDELETEtOPTIONStTRACEtPROPFINDt PROPPATCHtMKCOLtCOPYtMOVEtLOCKtUNLOCKt AuthenticatedtManagercCsrt|dƒp*|iddƒ|idtƒdƒnti|ƒo|iddƒn|iddƒdS( Nt_server_versiont ConnectiontclosetDateis Accept-Rangestbytestnone(thasattrtresponset setHeadert rfc1123_datetHTTPRangeInterfacetisImplementedBytself(RtrequestR((t./data/zmath/zope/lib/python/webdav/Resource.pyt dav__initIs cCs—d}d}t||ƒot||ƒ}n$y|i|ƒ}Wn d}nX|dj o+ytƒi d|||ƒSWqŠqŠXnt |‚dS(Ns@You are not authorized to access this resource.( tmsgtNonetmethodRtobjectt methodnametgetattrt aq_acquiretgetSecurityManagertvalidatet Unauthorized(RR$R%tREQUESTR!R#((Rt dav__validateZs    icCs?|iddƒ}ti|ƒo| o td‚n|pdSnti|ƒpdSn|djot |d|ƒ}nt |ƒ}|o||i dƒd }n|d„} d}d} t|ƒ} x.| D]&}|ip€tt|iƒ}t| |ƒ} | pqÛn|ioqÛn|o(x%| D]} |i| ƒiƒq9Wnd} d}PqÛt |iƒ|jo€d} tt|iƒ}t| |ƒ} | pqÛn|ioqÛn|o(x%| D]} |i| ƒiƒqÕWnd}PqÛqÛW| o| o td‚n| o|odSndSdS( NtIfsResource is locked.tURLt/icCs |i|ƒS(N(Rt wl_hasLocktx(R1R((Rt€sisCondition failed.( Rt get_headerR"tifhdrtLockablet wl_isLockedRtLockedturlturlfixR#turlbasetcoltrfindthavetagtfoundtresourcetaggedtIfParserttaglistttagtresourcetmapt tokenFindertlistttag_listtfiltertwehavetNOTTEDtrefreshttokent wl_getLocktPreconditionFailed(RRRR#R;R8RKRBR4RARIR=R?RLR>RG((Rtdav__simpleifhandlerls`           c Cs³|i||ƒd}t|dƒot|iƒ}n|djoNt|ddƒ}t t d|i dƒdƒƒ}ti|ƒ\}}n|djo't|dƒot|iƒ}qÈn|djo d}n|id|iƒƒtt|ƒd ƒo|id t|iƒƒnt|d ƒo#t|iƒ}|id |ƒntt|ƒd ƒo1|iddƒ}|o|id|ƒq¢n|idƒ|S(s6Retrieve resource information without a response body.t content_typeR.RR/iÿÿÿÿtdefault_content_typesapplication/octet-streams Content-Typetget_sizesContent-Lengtht_p_mtimes Last-Modifiedt http__etagtreadonlyitEtagiÈN(RR R+tRESPONSER"RPRtabsattrR9R8tunquoteRHtsplittnamet mimetypest guess_typetencodingRQRtlowertaq_baseRRRRStmtimeRTtetagt setStatus( RR+RWR^R8RbRPRaR[((RR¥s4 "    cCs|i||ƒtd‚dS(s/Replace the GET response entity of an existing resource. Because this is often object-dependent, objects which handle PUT should override the default PUT implementation with an object-specific implementation. By default, PUT requests fail with a 405 (Method Not Allowed).s'Method not supported for this resource.N(RR R+RWtMethodNotAllowed(RR+RW((RRÃscCs`|i||ƒ|iddi|iƒƒ|iddƒ|idddƒ|idƒ|S( sRetrieve communication options.tAllows, sContent-LengthitDAVs1,2iiÈN(RR R+RWRtjoint__http_methods__Rc(RR+RW((RRÍs cCs|i||ƒtd‚dS(stReturn the HTTP message received back to the client as the entity-body of a 200 (OK) response. This will often usually be intercepted by the web server in use. If not, the TRACE request will fail with a 405 (Method Not Allowed), since it is not often possible to reproduce the HTTP request verbatim from within the Zope environment.s'Method not supported for this resource.N(RR R+RWRd(RR+RW((RR×scCs:|i||ƒ|iddƒ}t|ddƒ}tt d|i dƒdƒƒ}|i }ti|ƒo+|o|i||dƒqùtd‚n_ti|ƒpti|ƒo>|iƒo1|o|i||ddd ƒqùtd ‚n|i|gd dƒdjo|id ƒn|id ƒ|S(s~Delete a resource. For non-collection resources, DELETE may return either 200 or 204 (No Content) to indicate success.R-tR.RR/iÿÿÿÿsResource is locked.R;is3Resource is locked, and no condition was passed in.R+iÌi“N(RR R+RWR3R4R9R8RYRHR"RZR[t aq_parenttparentR5R6ROR7t IWriteLockt providedBytWriteLockInterfaceRRNtmanage_delObjectsRc(RR+RWR[RkR8R4((RRâs$"  -  cCsš|i||ƒti|ƒ}|i|ƒ}|i dƒdjo(|i ddƒ}|i ddƒ}n|i dƒ|i dd ƒ|i |ƒ|S( s,Retrieve properties defined on the resource.s User-Agents:Microsoft Data Access Internet Publishing Provider DAV 1.1s"sssskiÏs Content-Typestext/xml; charset="utf-8"N(RR R+RWtdavcmdstPropFindtcmdtapplytresultR3treplaceRcRtsetBody(RR+RWRrRt((RR s      cCsÌ|i||ƒtt|ƒdƒp td‚n|iddƒ}t i |ƒo+|o|i ||dƒq€t d‚nt i|ƒ}|i|ƒ}|idƒ|idd ƒ|i|ƒ|S( s5Set and/or remove properties defined on the resource.tpropertysheetss'Method not supported for this resource.R-RiR sResource is locked.iÏs Content-Typestext/xml; charset="utf-8"N(RR R+RWRR`RdR3R4R5R6ROR7Rpt PropPatchRrRsRtRcRRv(RR+RWRrR4Rt((RR s    cCs|i||ƒtd‚dS(s{Create a new collection resource. If called on an existing resource, MKCOL must fail with 405 (Method Not Allowed).sThe resource already exists.N(RR R+RWRd(RR+RW((RR 0scCs¾|i||ƒtt|ƒdƒ p|iƒ o td‚n|iddƒ}|d#jo t d‚n|iddƒ} x'| o| d d jo| d } qƒW| p t d ‚ny|i | ƒ} Wntj ot d ‚nX| iƒ} |id dƒiƒ} | d$jo t d‚ny|i| ƒ}Wn[tj otd‚nAtj otd‚n&tiƒ\}}}||‚nXt|dƒo td‚ntt|ƒ| ƒ}|o| djo td‚ny|i| ddƒWnttiƒd‚nXy|i |ƒWn/t!j o ‚nttiƒd‚nX|iddƒ}|oŠt|ƒi#| ƒ}t%i&|ƒpt'i(|ƒoQ|i)ƒoD|o0|i*||dddƒ} | p t,‚qqt-d‚qjn_t%i&|ƒpt'i(|ƒo>|i)ƒo1|o|i*||dddƒqjt-d‚n|i.|ddƒ|i/|ƒ}|i1| ƒ|djo5t2|ƒo(x%|i3ƒD]}|i5|ƒqÀWn|o3t6|| ƒ}|i8|d|ƒ|i5| ƒn|i9| |ƒ|i#| ƒ}|i:|ddƒt;i<i=d||ƒt>t?|ƒƒ|i@ƒ|iA|odpd ƒ|p|iBd!| ƒn|iCdƒ|S(%s=Create a duplicate of the source resource whose state and behavior match that of the source resource as closely as possible. Though we may later try to make a copy appear seamless across namespaces (e.g. from Zope to Apache), COPY is currently only supported within the Zope namespace.t cb_isCopyablesThis object may not be copied.tDepthtinfinityt0sInvalid Depth header.t DestinationRiiÿÿÿÿR/sInvalid Destination header.sInvalid Destination headert OverwritetFtTsInvalid Overwrite header.s(Attempt to copy to an unknown namespace.s$Object ancestors must already exist.t__null_resource__sDestination resource exists.t allow_dupiR-R RKsDestination is locked.topiRtmanage_afterCloneiÌiÉtLocationN(R|R{(R€R(DRR R+RWRR`RyRdR3tdeptht BadRequesttdesttphysicalPathFromURLtpatht ValueErrortpopR[tuppertoflagtrestrictedTraverseRktConflicttNotFoundtsystexc_infotttvttbtexistingRNt_checkIdt Forbiddent_verifyObjectPasteR*R4t_getObtdestobRlRmRnRR6ROtitruetPreconditonFailedR7t_notifyOfCopyTot_getCopytobt_setIdtisDavCollectiont objectIdstidt _delObjectR&R$R,t _setObjectt _postCopytOFSt subscriberstcompatibilityCalltnotifytObjectClonedEventt wl_clearLocksRcRRv(RR+RWRœR—R¥R–R$RkRˆRŽRRŠR[R4R¡R†R”R•((RR 7s¢%            --     c Csº|i||ƒ|i|d|ƒtt|ƒdƒ p|iƒ o td‚n|i ddƒ} y|i | ƒ} Wnt j otd‚nX|i ddƒ} | iƒ} | iƒ} d i| ƒ}y|i| ƒ}Wn_t j otd ‚nEd j otd |‚n&tiƒ\}}}||‚nXt|d ƒotd |‚ntt|ƒ| ƒ}|o| djotd| ‚ny|i| ddƒWnt tiƒd‚nXy|i!|ƒWn/t"j o ‚nt tiƒd‚nX|i ddƒ}|ot|ƒi$| ƒ}t&i'|ƒpt(i)|ƒoW|i*ƒoJ|o6|i+||dd| ddƒ} | p t‚qºq¾t-d‚qBnt&i'|ƒpt(i)|ƒo`|i*ƒoS|o?|i+||dddd| ddƒ} | p td‚q>qBt-d‚nt.i*|ƒoG|o3|i+||dddƒ} | p td‚q•q™td‚n|i/ddƒ|i0|ddƒt|i1|ƒƒ}|i3i4t5|i6ƒƒ|i7| ƒ|o3t8|| ƒ}|i|d|ƒ|i4| ƒn|i:| |ƒ|i$| ƒ}|i;|ddƒ|i/ddƒ|i<|odpdƒ|p|i=d| ƒn|i>dƒ|S( sÛMove a resource to a new location. Though we may later try to make a move appear seamless across namespaces (e.g. from Zope to Apache), MOVE is currently only supported within the Zope namespace.Rt cb_isMoveablesThis object may not be moved.R}RisNo destination givenR~RR/s(Attempt to move to an unknown namespace.s Not FoundsThe resource %s must exist.RsResource %s exists.R‚iR-R R8RKsDestination is locked.R;sCondition failed.s0Source is locked and no condition was passed in.texplicitRƒiiÌiÉR…N(?RR R+RWR,RR`R¯RdR3RˆR‰RŠR‹R‡tflagRRŒR[Rgt parent_pathRRkRR’R“R”R•R–R—RNR˜R™RšR*R4R›RœRlRmRnRR6RORR7R5tmanage_changeOwnershipTypeRŸR R¡RjR¦RXR¥R¢R&R$R§R¨RcRRv(RR+RWRœR—R²R–R$RkRˆR±RRŠR[R4R¡R”R•((RR ¥sž%     -!-     cCsH|i||ƒtƒ}|iƒ}|iddƒ} |i ddƒ} |i ddƒ}ti|ƒ}| o|o|idƒn¼| o¹ti|ƒ} | i||d|ƒ\}}|o.|idƒ|id d ƒ|i|ƒqD|i|ƒ}|id ƒ|id d ƒ|id d |ƒ|i|iƒƒnü| p td‚nt| ƒ} d}xº| D]²}x|i"D]’} t$| ƒ}|oy|i%|ƒoi|i|ƒ}|i ddƒ}|i'|ƒd}|id ƒ|id d ƒ|i|iƒƒPq†q†W|oPqvqvW|p|idƒn|S(sLock a resourcetBODYRiR-RzR{i§R†iÏs Content-Typestext/xml; charset="utf-8"iÈs Lock-Tokensopaquelocktoken:sIf Header MissingitTimeouttInfiniteiiœN((RR R+RWR(tsecuritytgetUsertcreatortgettbodyR3R"R4R†R5R6t alreadylockedRcRptLockRrRsRLRtRRvRMtlocktasXMLRNR@RAR>RBRFtlistitemRER0ttimeoutt setTimeout(RR+RWR¹R¾RBRtR¼RLRÀR4RAR»RrR†RÁR>R·((RR s\             cCs¨|i||ƒtƒ}|iddƒ}|d}t |ƒ}t i ƒ}|i |||ƒ}|o.|idƒ|iddƒ|i|ƒn|idƒ|S( s&Remove an existing lock on a resource.s Lock-TokenRiR.iÏs Content-Typestext/xml; charset="utf-8"iÌN(RR R+RWR(R·R3RLR8RERptUnlockRrRsRtRcRRv(RR+RWR8RrRLRtR·((RRUs      t manage_DAVgetcCs |iƒS(sGets the document sourceN(Rt manage_FTPget(R((RRÄjstlistDAVObjectscCsgS(N((R((RRÆps(RsHEADRsPUTsDELETEsOPTIONSsTRACEsPROPFINDs PROPPATCHsMKCOLsCOPYsMOVEsLOCKsUNLOCK(RR($t__name__t __module__t__doc__t implementst IDAVResourcet__dav_resource__RhtClassSecurityInfoR·tsetPermissionDefaultt webdav_accessR R,R"ROtdeclareProtectedtViewRRt declarePublicRRtdelete_objectsRRtmanage_propertiesR R R R twebdav_lock_itemsR twebdav_unlock_itemsRRÄRÆ(((RR5sF     8     &     m  s ;  (9RÉR\R’turllibRYtExtensionClasstGlobalstInitializeClasst AccessControlR(RÍtAccessControl.PermissionsRÓRÔtviewRÑRÕRÖRÏt AcquisitionR`t zExceptionsR‡RdR*R™R‘tzope.interfaceRÊtZPublisher.HTTPRangeSupportRRpR5tcommonRXR9RRER:R@R£R7RRNt interfacesRËRlRnt zope.eventR¬t OFS.eventR­tOFS.subscribersR©tBaset LockableItemR((RYRlR£RR¬R7RnR‡RÓRÕR9R@RRXR5RÔR\RNRÖR`R*R­RÍRÚR’R©R:RËRdRÑRÊR‘RRØR(R™RRpRÏRE((Rt?sD                  %        ÿÿ@