Hi Dieter. I think I understand. What I have done so far is to make a upload folder product. I have taken the portal folder base class to create a portal upload folder base class, commented out the PUT_factory method and added the following methods for bobo traverse and PUT. I am then subclassing this to create upload folder types that will be available to portal.

I commented out the portion of the PUT's method that creates the object so it should proceed to the response without making the object. I have yet to test any of this out but this is what I have got so far. Does this look sensible?
        
        # Catch put in traversal
        def __bobo_traverse__(self, REQUEST):
                method=REQUEST.get('REQUEST_METHOD', 'GET')
                if method == 'PUT':
                        PUT(REQUEST, RESPONSE)

        # Using default put method from NullResource
        def _default_PUT_factory( self, name, typ, body ):
                # Return DTMLDoc/PageTemplate/Image/File, based on sniffing.
                if name and name.endswith('.pt'):
                        from Products.PageTemplates.ZopePageTemplate import 
ZopePageTemplate
                        ob = ZopePageTemplate(name, body, content_type=typ)
                elif typ in ('text/html', 'text/xml', 'text/plain'):
                        from OFS.DTMLDocument import DTMLDocument
                        ob = DTMLDocument( '', __name__=name )
                elif typ[:6]=='image/':
                        from OFS.Image import Image
                        ob=Image(name, '', body, content_type=typ)
                else:
                        from OFS.Image import File
                        ob=File(name, '', body, content_type=typ)
                return ob
        
        # Modified PUT from NullResource        
        PUT__roles__ = ('Anonymous',)
        def PUT(self, REQUEST, RESPONSE):
                """Create a new non-collection resource.
                """
                from ZServer import LARGE_FILE_THRESHOLD
                
                self.dav__init(REQUEST, RESPONSE)
                
                name = self.__name__
                parent = self.__parent__
                
                ifhdr = REQUEST.get_header('If', '')
if WriteLockInterface.isImplementedBy(parent) and parent.wl_isLocked():
                        if ifhdr:
                                parent.dav__simpleifhandler(REQUEST, RESPONSE, 
col=1)
                        else:
                                # There was no If header at all, and our parent 
is locked,
                                # so we fail here
                                raise Locked
                elif ifhdr:
                        # There was an If header, but the parent is not locked
                        raise PreconditionFailed
        
                # SDS: Only use BODY if the file size is smaller than
                # LARGE_FILE_THRESHOLD, otherwise read LARGE_FILE_THRESHOLD
                # bytes from the file which should be enough to trigger
                # content_type detection, and possibly enough for CMF's
                # content_type_registry too.
                #
                # Note that body here is really just used for detecting the
                # content type and figuring out the correct factory. The correct
                # file content will be uploaded on ob.PUT(REQUEST, RESPONSE) 
after
                # the object has been created.
                #
                # A problem I could see is content_type_registry predicates
                # that do depend on the whole file being passed here as an
                # argument. There's none by default that does this though. If
                # they really do want to look at the file, they should use
                # REQUEST['BODYFILE'] directly and try as much as possible not
                # to read the whole file into memory.
                
                if int(REQUEST.get('CONTENT_LENGTH') or 0) > 
LARGE_FILE_THRESHOLD:
                        file = REQUEST['BODYFILE']
                        body = file.read(LARGE_FILE_THRESHOLD)
                        file.seek(0)
                else:
                        body = REQUEST.get('BODY', '')
                
                typ=REQUEST.get_header('content-type', None)
                if typ is None:
                        typ, enc=OFS.content_types.guess_content_type(name, 
body)
        
                factory = getattr(parent, 'PUT_factory', 
self._default_PUT_factory )
                ob = factory(name, typ, body)
                if ob is None:
                        ob = self._default_PUT_factory(name, typ, body)
                
                # We call _verifyObjectPaste with verify_src=0, to see if the
                # user can create this type of object (and we don't need to
                # check the clipboard.
                try:
                        parent._verifyObjectPaste(ob.__of__(parent), 0)
                except CopyError:
                        raise Unauthorized, sys.exc_info()[1]
                
                # We don' want an object  - so object creation below commented 
out

                # Delegate actual PUT handling to the new object,
                # SDS: But just *after* it has been stored.
                # self.__parent__._setObject(name, ob)
                # ob = self.__parent__._getOb(name)
                # ob.PUT(REQUEST, RESPONSE)
                
                RESPONSE.setStatus(201)
                RESPONSE.setBody('')
                return RESPONSE

On Sunday, August 21, 2005, at 05:58 PM, Dieter Maurer wrote:

David Pratt wrote at 2005-8-19 15:38 -0300:
First step is to make new type - will
do this today but might need to ask a question or two when I get to
bobo traverse portion. When you say another auxillary object, what kind
of object is this so I understand a bit better?

One similar to "webdav.Resource.NullResource" (and probably deriving
from it) but with a PUT method that does what you want.

--
Dieter

_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to