mò /á¸Ec@sddZdkZdklZdklZdkZdklZdk l Z dk l Z dk lZlZdklZlZlZlZlZd klZd klZd klZd klZd klZdklZdd„Zde fd„ƒYZdfd„ƒYZ dfd„ƒYZ!dfd„ƒYZ"dfd„ƒYZ#dfd„ƒYZ$dS(sQWebDAV xml request objects. $Id: davcmds.py 69164 2006-07-17 23:34:32Z sidnei $ N(sStringIO(squote(sgetSecurityManager(s aq_parent(s DAVProperties(s BadRequests Forbidden(sabsattrsaq_basesurlfixsurlbasesurljoin(sisDavCollection(sPreconditionFailed(s IWriteLock(sLockItem(sWriteLockInterface(s XmlParsert%cCs(|i|ƒdjo|Snt|ƒS(Niÿÿÿÿ(turltfindtmarktquote(RR((t-/data/zmath/zope/lib/python/webdav/davcmds.pyt safe_quote%stDAVPropscBs&tZdZd„Zd„ZeZRS(sÅEmulate required DAV properties for objects which do not themselves support properties. This is mainly so that non-PropertyManagers can appear to support DAV PROPFIND requests.cCs ||_dS(N(tobjtselft__obj__(R R((Rt__init__1scCs|iS(N(R R (R ((Rtv_self4s(t__name__t __module__t__doc__R R tp_self(((RR+s   tPropFindcBs8tZdZd„Zdd„Zededd„ZRS(sModel a PROPFIND request.cCs>||_d|_d|_d|_g|_|i|ƒdS(Ntinfinityi(trequestR tdepthtallproptpropnamet propnamestparse(R R((RR =s      sDAV:cCsµ|iddƒ|_|idjo td‚n|iddƒ}t|ƒ |_|pdSnyt ƒi |ƒ}Wntt i ƒd‚nX|id d |ƒ}|p td ‚n|d }|id d |ƒod|_dSn|idd |ƒod|_dSn|idd |ƒ}|p td ‚n|d }x6|iƒD](}|ii|iƒ|iƒfƒqWW|i o#|i o|i o td ‚ndS(NtDepthRt0t1sInvalid Depth header.tBODYtitpropfindtnssInvalid xml request.iRRtprop(RRsinfinity(Rt get_headerR Rt BadRequesttgettbodytlenRt XmlParserRtroottsystexc_infotelementstdavteRR tvalRtappendtnamet namespace(R RR+R$R,R-R R'((RREs>        &! iicCsM|djoEtƒ}|i}t|iddƒ}t|ƒ}|i dƒnt |ƒ}|o|ddjo|d}n|i dt |ƒƒtt|ƒdƒo|iiƒ}|i}n%t|ƒ} | f}hd| <}|iokg} x;|D]3} tt| ƒd ƒo| i| iƒƒqqWd i| ƒpd } |i | ƒn™|iokg} x;|D]3} tt| ƒd ƒo| i| iƒƒq}q}Wd i| ƒpd } |i | ƒn$|ioh}xª|iD]Ÿ\}} |i"| dƒ} | dj o,tt| ƒd ƒo| i#||ƒ}qõd|| f} d}|i'|ƒp| g|| iÿÿÿÿt/s! %s tpropertysheetssDAV:t dav__allpropRs200 OK tdav__propnamest dav__propstatss 404 Not Founds s= HTTP/1.1 %s sInvalid requests RRt meta_typesBroken Because Product is Gonet _p_changedt__locknull_resource__t__dav_resource__ittops(Rsinfinity(:tresulttNonetStringIOR RturlfixRRturlbasetwritetisDavCollectionRtiscolRthasattrtaq_baseR4tvaluestpropsetstobsheetsRtdavpropsRtstatstpsR.R5tjoinRR6RtrdictR/RR#R7tstatR tcodethas_keytkeystsorttkeytmapR"tlistDAVObjectstobR8R9tdflagt _p_deactivateturljointabsattrtgetIdturitapplyR<tgetvalue(R RRRR=R<RPROR]RJRLRKR RRXRRRTRIR/RNRWRDRH((RR^fs’            #        (R RRR RR>R^(((RR:s   !t PropPatchcBs,tZdZd„Zdd„Zd„ZRS(sModel a PROPPATCH request.cCs#||_g|_|i|ƒdS(N(RR RGR(R R((RR »s  sDAV:cCsž|iddƒ}ytƒi|ƒ}Wnttiƒd‚nX|i } |i dd|ƒ}|p td‚n|d}x|i ƒD]}|iƒdjoV|iƒ|joC|i d d|ƒ} | p td‚n| d} x | i ƒD]û} | iƒ| iƒ}}| i ƒ| iƒ}} | o1| o)||| iƒhf} | i| ƒqúh} | ih|d <ƒ| id ƒx*| iƒD]}|iƒ| |iƒ %s s200 OKiRtmetais 409 Conflicts%s cannot be deleted.sl HTTP/1.1 %s s sThe operation succeded.sR %s s424 Failed Dependency('R@R RRRCRR?R=terrorsRBRR4RHRGRntstatusR%R/RR-RpR#R>tpropsettmanage_addPropertySheett hasPropertyt_updatePropertyR.tstrR(R)t _setPropertyt _delPropertyRMterrmsgR_t transactiontaborttreplace(R RR=RsR-RRtRpR/RRuRnRHR|((RR^îsZ          (R RRR RR^(((RR`¸s   .tLockcBs>tZdZd„Zdd„Zedeeedd„ZRS(sModel a LOCK request.cCsu||_|iddƒ}d|_d|_d|_|iddƒ}|i dƒdi ƒ|_|i |ƒdS( NRRt exclusiveRBtTimeouttinfinitet,iÿÿÿÿ( RR R#tdatatscopettypetownerR!ttimeouttsplittstripR(R RR…R‰((RR 3s    sDAV:c Csmtƒi|ƒ} | idd|ƒd}|idd|ƒd} | iƒdiƒ|_ |idd|ƒd}|iƒdiƒ|_ |idd|ƒ} | o¾| d} xž| iƒD]}|iƒ|iƒ}}|pT| ih|d<ƒd|_xH|iƒD] }|iƒp d|_qqWqÂ|ih|d<ƒqÂW| iƒ|_ndS( NtlockinfoRit lockscopetlocktypeRˆtotto(R&RR…R'R*R+tinfotlsR/R R†tltR‡t lockownertelR0telnsRkt __nskey__tsubelRiRˆ( R R…R+R‘R•R–R/R˜R“R’R'R”((RR=s*     Ric Csû|djo/tƒ}t|iddƒ}t|ƒ}nt|ƒ} | o|ddjo|d}nd}d}yKt ||i||i|i|i|ƒ}|djo|iƒ}nWn%tj o d}nd}nXy¯ti|ƒp ti|ƒp|o d}q›nw|iƒo d}n`t|d ƒ} tƒi d|d | ƒ} | o(|o!|dj o|i"||ƒnd}Wn d}nX|o{|o#|djp| o|d ‚n|i#ƒp|i$d ƒn|i$d|ƒ|i$d|ƒ|i$dƒn|djos| olxi|i%ƒD]W} t'|dƒoAt(|t)| i*ƒƒƒ} |i,| ||||| dd ƒqOqOWn|p||fSn|i#ƒo|i$dƒt-i.ƒn||i#ƒfS(s_ Apply, built for recursion (so that we may lock subitems of a collection if requested R1tLOCKiÿÿÿÿR3s412 Precondition Faileds 403 Forbiddens405 Method Not Alloweds 423 Lockedt wl_setLockiRisG s" %s s" HTTP/1.1 %s s RR;R<sN(iR(/R=R>R?R@R RRRARCRRDR|tlocktLockItemtcreatorRˆRR‰R‡R†ttokent getLockTokent ValueErrort IWriteLockt providedBytWriteLockInterfacetisImplementedByR<t wl_isLockedtgetattrtmethodtgetSecurityManagertvalidatetvldRšR_RBt objectValuesRWRERZR[R\R]R^R}R~(R RRRRžR=RR<R›R]RªRWR§RDR|((RR^Ysn                 (R RRR RR>R^(((RR€0s  tUnlockcBs tZdZeedd„ZRS(s Model an Unlock request ic Cse|djo(tƒ}t|dƒ}t|ƒ}nt|ƒ} | o|ddjo|d}nd} t i |ƒp t i |ƒ} | o\|i|ƒoLt|dƒ}tƒid|d|ƒ}|o|i|ƒq d} n| p|o d} q n| o…|o-| o%| d djo t‚qdt‚n|iƒp|id ƒn|id |ƒ|id | ƒ|id ƒn| o†xƒ|iƒD]q} t| d ƒo[t i | ƒpt i | ƒo;t|t | i!ƒƒƒ}|i$| |||ddƒq«q«Wn|p|Sn|iƒo|idƒt%i&ƒn|iƒS(NtUNLOCKiÿÿÿÿR3t wl_delLocks 403 Forbiddens405 Method Not Allowedit403sG s" %s s" HTTP/1.1 %s s R;R<is('R=R>R?R@RRARCRRDR|R¡R¢R£R¤t islockablet wl_hasLockRžR¦R§R¨R©RªR®R<t ForbiddentPreconditionFailedR_RBR«RWRERZR[R\R]R R^R}R~( R RRžRR=R<R]R§RªR°RWRDR|((RR^«sP        0(  (R RRR>R^(((RR¬¨s tDeleteCollectioncBs tZdZeedd„ZRS(s» With WriteLocks in the picture, deleting a collection involves checking *all* descendents (deletes on collections are always of depth infinite) for locks and if the locks match. ic Cs,|djo(tƒ}t|dƒ}t|ƒ}nt|ƒ} d}t |ƒ}t i |ƒp ti|ƒ} |o|id|ƒ o d}n@| o8|iƒo+|o|i|ƒo d}qÖd}n|ot|o| o|d} | ‚n|iƒp|idƒn|id|ƒ|id |ƒ|id ƒn| oxš|iƒD]ˆ} t| d ƒo | idj} t| d ƒoSt|t | i!ƒƒƒ}|i$| ||||d dƒ| o| i%ƒqíqeqeWn|p|Sn|iƒo|idƒn|iƒS(NtDELETEsDelete objectss 403 ForbiddenRs 423 LockedisG s" %s s" HTTP/1.1 %s s R9R;R<is (&R=R>R?R@RRARCRRDR|t aq_parenttparentR¡R¢R£R¤R°tuserthas_permissionR¥RžR±R<terrR_RBR«RWRER9RXRZR[R\R]R R^RY(R RRžR¸RR=R<R]R·RXR°RºRWRDR|((RR^ísJ            (R RRR>R^(((RR´ès (%RR(t cStringIOR?turllibRR}t AccessControlR¨t AcquisitionR¶tOFS.PropertySheetst DAVPropertiest zExceptionsR"R²tcommonR[RFR@RARZRCR³t interfacesR¡RœR£txmltoolsR&RRRR`R€R¬R´(RRRR¡RCR¶RÀRœR£R"R@R[RZR´RFRR³R(RAR&R}R?R¨R²R`R¬R€((Rt?s,       %       ~xx@