m /Ec@sdZdklZdklZlZdefdYZdefdYZdefdYZd efd YZ d S( sNwebdav z3 interfaces. $Id: interfaces.py 39857 2005-11-03 07:56:41Z yuppie $ (s Interface(sBoolsTuplet ILockItemcBstZdZddddedZdZdZdZd Zd Z d Z d Z d Z dZ dZdZdZdZddZdZRS(sA LockItem contains information about a lock. This includes: o The locktoken uri (used to identify the lock by WebDAV) o The lock owner (The string passed in the 'owner' property by WebDAV) o The lock creator (the Zope user who physically owns the lock) o Depth o Timeout information o Modified time (for calculating timeouts) o LockType (only EXCLUSIVE is supported right now) itInfinitytwritet exclusivecCsdS(s If any of the following are untrue, a **ValueError** exception will be raised. - **creator** MUST be a Zope user object or string to find a valid user object. - **owner** MUST be a nonempty string, or type that can be converted to a nonempty string. - **depth** MUST be in the set {0,'infinity'} - **timeout** MUST either be an integer, or a string in the form of 'Seconds-nnn' where nnn is an integer. The timeout value MUST be less than (2^32)-1. *IF* timeout is the string value 'Infinite', the timeout value will be set to 1800 (30 minutes). (Timeout is the value in seconds from creation\modification time until the lock MAY time out). - **locktype** not in set {'write'} *this may expand later* - **lockscope** not in set {'exclusive'} *this may expand later* If the value passed in to 'token' is 'None', the a new locktoken will be generated during the construction process. __init__ must generate the opaquelocktoken uri used to identify the lock (if 'token' is 'None')and set all of the above attributes on the object. N((tcreatortownertdepthttimeouttlocktypet lockscopettoken((t0/data/zmath/zope/lib/python/webdav/interfaces.pyt__init__-scCsdS(s Returns the Zope user who created the lock. This is returned in a tuple containing the Users ID and the path to the user folder they came from.N((((R t getCreatorNscCsdS(s` Returns a string of the path to the user object in the user folder they were found in. N((((R tgetCreatorPathSscCsdS(sL Returns the string value of the 'owner' property sent in by WebDAV N((((R tgetOwnerWscCsdS(s returns the opaque lock token N((((R t getLockToken[scCsdS(s returns the depth of the lock N((((R tgetDepth^scCsdS(s1 returns an integer value of the timeout setting N((((R t getTimeoutascCsdS(sY returns the timeout value in a form acceptable by WebDAV (ie - 'Seconds-40800') N((((R tgetTimeoutStringdscCsdS(s# refreshes the timeout information N((t newtimeout((R t setTimeouthscCsdS(s returns a time.time value of the last time the Lock was modified. From RFC 2518: The timeout counter SHOULD be restarted any time an owner of the lock sends a method to any member of the lock, including unsupported methods or methods which are unsucscessful. The lock MUST be refreshed if a refresh LOCK method is successfully received. The modified time is used to calculate the refreshed value N((((R tgetModifiedTimeks cCsdS(s Tickles the locks modified time by setting it to the current time.time() value. (As stated in the RFC, the timeout counter SHOULD be restarted for any HTTP method called by the lock owner on the locked object). N((((R trefreshvscCsdS(su Returns true if (self.getModifiedTime() + self.getTimeout()) is greater than the current time.time() value. N((((R tisValid|scCsdS(s! returns the lock type ('write') N((((R t getLockTypescCsdS(s& returns the lock scope ('exclusive') N((((R t getLockScopestdcCsdS(s Return the lock rendered as an XML representation of a WebDAV 'lockdiscovery' property. 'ns' is the namespace identifier used on the XML elements.N((tns((R tasLockDiscoveryPropertyscCsdS(sw Render a full XML representation of a lock for WebDAV, used when returning the value of a newly created lock. N((((R tasXMLs(t__name__t __module__t__doc__tNoneR R RRRRRRRRRRRRRR(((R Rs" !            t IWriteLockcBsktZdZddZddZddZddZdZdZdZ d Z d Z RS( sBasic protocol needed to support the write lock machinery. It must be able to answer the questions: o Is the object locked? o Is the lock owned by the current user? o What lock tokens are associated with the current object? o What is their state (how long until they're supposed to time out?, what is their depth? what type are they? And it must be able to do the following: o Grant a write lock on the object to a specified user. - *If lock depth is infinite, this must also grant locks on **all** subobjects, or fail altogether* o Revoke a lock on the object. - *If lock depth is infinite, this must also revoke locks on all subobjects* **All methods in the WriteLock interface that deal with checking valid locks MUST check the timeout values on the lockitem (ie, by calling 'lockitem.isValid()'), and DELETE the lock if it is no longer valid** icCsdS(s Returns (key, value) pairs of locktoken, lock. if 'killinvalids' is true, invalid locks (locks whose timeout has been exceeded) will be deletedN((t killinvalids((R t wl_lockItemsscCsdS(s_ Returns a sequence of locks. if 'killinvalids' is true, invalid locks will be deletedN((R$((R t wl_lockValuesscCsdS(se Returns a sequence of lock tokens. if 'killinvalids' is true, invalid locks will be deletedN((R$((R t wl_lockTokensscCsdS(sU Returns true if the lock identified by the token is attached to the object. N((R R$((R t wl_hasLockscCsdS(sh Returns true if 'self' is locked at all. If invalid locks still exist, they should be deleted.N((((R t wl_isLockedscCsdS(s Store the LockItem, 'lock'. The locktoken will be used to fetch and delete the lock. If the lock exists, this MUST overwrite it if all of the values except for the 'timeout' on the old and new lock are the same. N((t locktokentlock((R t wl_setLockscCsdS(s6 Returns the locktoken identified by the locktokenuri N((R*((R t wl_getLockscCsdS(s6 Deletes the locktoken identified by the locktokenuri N((R*((R t wl_delLockscCsdS(sc Deletes ALL DAV locks on the object - should only be called by lock management machinery. N((((R t wl_clearLockss( RR R!R%R&R'R(R)R,R-R.R/(((R R#s         t IDAVResourcecBstZdZeddZeddddZdZdZdd e d d Z d Z d Z d Z dZdZdZdZdZdZdZdZdZdZdZRS(s8Provide basic WebDAV support for non-collection objects.ttitleuIs DAV resourceu HTTP methodst descriptionuSequence of valid HTTP methodscCsdS(s%Init expected HTTP 1.1 / WebDAV headers which are not currently set by the base response object automagically. Also, we sniff for a ZServer response object, because we don't want to write duplicate headers (since ZS writes Date and Connection itself). N((trequesttresponse((R t dav__initscCsdS(s N((tobjectt methodnametREQUEST((R t dav__validatestPUTicCsdS(s N((R3R4tmethodtcolturlR((R tdav__simpleifhandlerscCsdS(s6Retrieve resource information without a response body.N((R8tRESPONSE((R tHEADscCsdS(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).N((R8R?((R R:scCsdS(sRetrieve communication options.N((R8R?((R tOPTIONSscCsdS(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.N((R8R?((R tTRACE scCsdS(s~Delete a resource. For non-collection resources, DELETE may return either 200 or 204 (No Content) to indicate success.N((R8R?((R tDELETEscCsdS(s,Retrieve properties defined on the resource.N((R8R?((R tPROPFINDscCsdS(s5Set and/or remove properties defined on the resource.N((R8R?((R t PROPPATCHscCsdS(s{Create a new collection resource. If called on an existing resource, MKCOL must fail with 405 (Method Not Allowed).N((R8R?((R tMKCOLscCsdS(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.N((R8R?((R tCOPY!scCsdS(sMove 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.N((R8R?((R tMOVE(scCsdS(sLock a resourceN((R8R?((R tLOCK.scCsdS(s&Remove an existing lock on a resource.N((R8R?((R tUNLOCK1scCsdS(sGets the document sourceN((((R t manage_DAVget4scCsdS(s N((((R tlistDAVObjects7s(RR R!tBoolt__dav_resource__tTuplet__http_methods__R5R9R"R>R@R:RARBRCRDRERFRGRHRIRJRKRL(((R R0s*                 tIDAVCollectioncBs5tZdZeddddZdZdZRS(sThe Collection class provides basic WebDAV support for collection objects. It provides default implementations for all supported WebDAV HTTP methods. The behaviors of some WebDAV HTTP methods for collections are slightly different than those for non-collection resources.R1uIs a DAV collectionR2uShould be truecCsdS(sThe PUT method has no inherent meaning for collection resources, though collections are not specifically forbidden to handle PUT requests. The default response to a PUT request for collections is 405 (Method Not Allowed).N((R8R?((R R:LscCsdS(sDelete a collection resource. For collection resources, DELETE may return either 200 (OK) or 204 (No Content) to indicate total success, or may return 207 (Multistatus) to indicate partial success. Note that in Zope a DELETE currently never returns 207.N((R8R?((R RCRs(RR R!RMt__dav_collection__R:RC(((R RQ?s    N( R!tzope.interfacet Interfacet zope.schemaRMRORR#R0RQ(RROR#RMR0RTRQ((R t?s  J`