Back to index

plone3  3.1.7
Classes | Functions | Variables
Archetypes.WebDAVSupport Namespace Reference

Classes

class  PdataStreamIterator

Functions

def collection_check
def PUT
def manage_FTPget
def manage_afterPUT

Variables

list _marker = []

Function Documentation

Definition at line 50 of file WebDAVSupport.py.

00050 
00051 def collection_check(self):
00052     if not shasattr(self, '__dav_marshall__'):
00053         # Backwards-compatible, if property not set ignore.
00054         return
00055     if not self.__dav_marshall__:
00056         # If property is set to a false value, do not allow
00057         # marshalling.
00058         raise MethodNotAllowed, 'Method not supported.'

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.WebDAVSupport.manage_afterPUT (   self,
  data,
  marshall_data,
  file,
  context,
  mimetype,
  filename,
  REQUEST,
  RESPONSE 
)
After webdav/ftp PUT method

Definition at line 168 of file WebDAVSupport.py.

00168 
00169                     filename, REQUEST, RESPONSE):
00170     """After webdav/ftp PUT method
00171     """
00172     pass

Here is the caller graph for this function:

def Archetypes.WebDAVSupport.manage_FTPget (   self,
  REQUEST = None,
  RESPONSE = None 
)
Get the raw content for this object (also used for the WebDAV source)

Definition at line 127 of file WebDAVSupport.py.

00127 
00128 def manage_FTPget(self, REQUEST=None, RESPONSE=None):
00129     """Get the raw content for this object (also used for the WebDAV source)
00130     """
00131 
00132     if REQUEST is None:
00133         REQUEST = self.REQUEST
00134 
00135     if RESPONSE is None:
00136         RESPONSE = REQUEST.RESPONSE
00137 
00138     if not self.Schema().hasLayer('marshall'):
00139         RESPONSE.setStatus(501) # Not implemented
00140         return RESPONSE
00141 
00142     self.dav__init(REQUEST, RESPONSE)
00143     collection_check(self)
00144 
00145     marshaller = self.Schema().getLayerImpl('marshall')
00146     ddata = marshaller.marshall(self, REQUEST=REQUEST, RESPONSE=RESPONSE)
00147     if (shasattr(self, 'marshall_hook') and self.marshall_hook):
00148         ddata = self.marshall_hook(ddata)
00149 
00150     content_type, length, data = ddata
00151 
00152     RESPONSE.setHeader('Content-Type', content_type)
00153     # Only set Content-Length header length is not None. If we want to
00154     # support 'chunked' Transfer-Encoding we shouldn't set
00155     # this. However ExternalEditor *expects* it to be set if we return
00156     # a StreamIterator, so until that gets fixed we must set it.
00157     if length is not None:
00158         RESPONSE.setHeader('Content-Length', length)
00159 
00160     if type(data) is type(''):
00161         return data
00162 
00163     # We assume 'data' is a 'Pdata chain' as used by OFS.File and
00164     # return a StreamIterator.
00165     assert length is not None, 'Could not figure out length of Pdata chain'
00166     return PdataStreamIterator(data, length)

Here is the call graph for this function:

def Archetypes.WebDAVSupport.PUT (   self,
  REQUEST = None,
  RESPONSE = None 
)
HTTP PUT handler with marshalling support

Definition at line 59 of file WebDAVSupport.py.

00059 
00060 def PUT(self, REQUEST=None, RESPONSE=None):
00061     """ HTTP PUT handler with marshalling support
00062     """
00063     if not REQUEST:
00064         REQUEST = self.REQUEST
00065     if not RESPONSE:
00066         RESPONSE = REQUEST.RESPONSE
00067     if not self.Schema().hasLayer('marshall'):
00068         RESPONSE.setStatus(501) # Not implemented
00069         return RESPONSE
00070 
00071     self.dav__init(REQUEST, RESPONSE)
00072     collection_check(self)
00073 
00074     self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1)
00075 
00076     file = REQUEST.get('BODYFILE', _marker)
00077     if file is _marker:
00078         data = REQUEST.get('BODY', _marker)
00079         if data is _marker:
00080             raise AttributeError, 'REQUEST neither has a BODY nor a BODYFILE'
00081     else:
00082         data = ''
00083         file.seek(0)
00084 
00085     mimetype = REQUEST.get_header('content-type', None)
00086     # mimetype, if coming from request can be like:
00087     # text/plain; charset='utf-8'
00088     #
00089     # XXX we should really parse the extra params and pass them on as
00090     # keyword arguments.
00091     if mimetype is not None:
00092         mimetype = str(mimetype).split(';')[0].strip()
00093 
00094     filename = posixpath.basename(REQUEST.get('PATH_INFO', self.getId()))
00095     # XXX remove after we are using global services
00096     # use the request to find an object in the traversal hierachy that is
00097     # able to acquire a mimetypes_registry instance
00098     # This is a hack to avoid the acquisition problem on FTP/WebDAV object
00099     # creation
00100     parents = (self,) + tuple(REQUEST.get('PARENTS', ()))
00101     context = None
00102     for parent in parents:
00103         if getToolByName(parent, 'mimetypes_registry', None) is not None:
00104             context = parent
00105             break
00106 
00107     # Marshall the data
00108     marshaller = self.Schema().getLayerImpl('marshall')
00109 
00110     args = [self, data]
00111     kwargs = {'file':file,
00112               'context':context,
00113               'mimetype':mimetype,
00114               'filename':filename,
00115               'REQUEST':REQUEST,
00116               'RESPONSE':RESPONSE}
00117     ddata = mapply(marshaller.demarshall, *args, **kwargs)
00118 
00119     if (shasattr(self, 'demarshall_hook') and self.demarshall_hook):
00120         self.demarshall_hook(ddata)
00121     self.manage_afterPUT(data, marshall_data = ddata, **kwargs)
00122     self.reindexObject()
00123     event.notify(ObjectModifiedEvent(self))
00124     
00125     RESPONSE.setStatus(204)
00126     return RESPONSE

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 48 of file WebDAVSupport.py.