[Zope] Patch for Custom upload hook.

Jay, Dylan djay@lucent.com
Mon, 7 Feb 2000 15:29:09 +1100


When using webdav and other upload techniques it is not possible to
customize what object a file is uploaded as. This patch will determine if a
hook function named ManageUploadHook is present in the aquisistion path and
if it is, use it to handle the file creation process. If it returns 1 the
file was created, else the normal process is followed.

In file webdav/NullResource.py, line 143

        parent = self.__parent__
        try:
           hashook = parent.this().ManageUploadHook
        except:
           hashook = 0
        
        if hashook and parent.this().ManageUploadHook(name,type,body):
            blah = 'blah'
        elif type in ('text/html', 'text/xml', 'text/plain'):
            self.__parent__.manage_addDTMLDocument(name, '', body)


This works nicely with a python function such as this

if type[:6]=='image/':
   self.manage_addProduct['Photo'].manage_addPhoto(self.this(),name, file,
content_type=type)
   return 1
else:
   return 0