Product that catches webdav PUTs and does something else
Folks, I'm trying to create a product (dtml-documentish) that will allow me to catch PUT requests from Netscape Composer so that I can clean up the mess that Composer makes of dtml before the upload is actually added to the ZODB. Is this feasible idea *without patching and Zope source*? Will Zope let me define a 'PUT' method in the product that gets invoked when an upload is tried? Or is the procedure pre-defined in the guts of Zope? Any help is much appreciated. Cheers Tim
I'm trying to create a product (dtml-documentish) that will allow me to catch PUT requests from Netscape Composer so that I can clean up the mess that Composer makes of dtml before the upload is actually added to the ZODB. Is this feasible idea *without patching and Zope source*? Will Zope let me define a 'PUT' method in the product that gets invoked when an upload is tried? Or is the procedure pre-defined in the guts of Zope?
Any help is much appreciated.
You should probably check out: http://dev.zope.org/Wikis/DevSite/Proposals/HookablePUTCreation Hope this helps! Brian Lloyd brian@digicool.com Software Engineer 540.371.6909 Digital Creations http://www.digicool.com
----- Original Message ----- From: "Brian Lloyd" <brian@digicool.com> To: "Tim Hicks" <tim@sitefusion.co.uk>; <zope@zope.org> Sent: Tuesday, March 27, 2001 4:48 PM Subject: RE: [Zope] Product that catches webdav PUTs and does something else
I'm trying to create a product (dtml-documentish) that will allow me to catch PUT requests from Netscape Composer so that I can clean up the mess that Composer makes of dtml before the upload is actually added to the ZODB. Is this feasible idea *without patching and Zope source*? Will Zope let me define a 'PUT' method in the product that gets invoked when an upload is tried? Or is the procedure pre-defined in the guts of Zope?
Any help is much appreciated.
You should probably check out:
http://dev.zope.org/Wikis/DevSite/Proposals/HookablePUTCreation
Thanks Brian, that does seem to be what I'm after, however, I couldn't make it do what I expected. After many attempts at solving the problem, I defined a PUT method that seems to be called instead of the PUT_factory when uploading from Composer into the webdav_src_port. Is this what would be expected? If so, I think I misunderstand the use of PUT_factory. cheers for the help tim
Hope this helps!
Brian Lloyd brian@digicool.com Software Engineer 540.371.6909 Digital Creations http://www.digicool.com
Thanks Brian, that does seem to be what I'm after, however, I couldn't make it do what I expected. After many attempts at solving the problem, I defined a PUT method that seems to be called instead of the PUT_factory when uploading from Composer into the webdav_src_port. Is this what would be expected? If so, I think I misunderstand the use of PUT_factory.
Here is a quick primer on what happens when a PUT occurs. Lets say you do a PUT on /foo/bar/file.html, an object *that already exists* in the system. In this case: - the publisher traverses to the object /foo/bar/file.html - if the HTTP request method is GET or POST, it looks for index_html. Otherwise (as in this case), it looks for a method on the object matching the HTTP method (PUT). So if /foo/bar/file.html already exists, it's PUT method will be called. This is the case for editing / updating existing objects. Where the PUT_factory comes in is when /foo/bar/file.html does *not* yet exist. In this case: - the publisher traverses to /foo/bar/file.html. When it asks 'bar' for 'file.html' ( assuming 'bar' is a Folder), 'bar' finds that it doesn't exist so it returns a special object called a 'NullResource'. NullResource is a class defined in the lib/python/webdav package, and its sole purpose is to have a PUT method that will be called in this case (where no object exists yet). The PUT implementation of NullResource objects first tries to delegate to self.PUT_factory(...), which gives app developers an opportunity to expand on the default handling of a PUT on a non-existing resource. The NullResource is an acquirer, so the developer can implement a PUT_factory as a method of the container, or as a Python Script, whatever, to override the default behavior of the NullResource PUT. The default behavior (used if no PUT_factory is found), is to try to 'do the right thing' based on the mime-type or file extension (create a DTMLDocument for .txt, .html; Image for .gif, .jpg; File for anything else). Hopefully this sheds some light on what happens underneath and make the PUT_factory document more useful - if you still can't get PUT_factory to work as expected you might want to contact the author (Tres) to make sure it is up to date (I can't tell from a glance - but knowing Tres I suspect it is up to date :). Brian Lloyd brian@digicool.com Software Engineer 540.371.6909 Digital Creations http://www.digicool.com
----- Original Message ----- From: "Brian Lloyd" <brian@digicool.com> To: "Tim Hicks" <tim@sitefusion.co.uk>; <zope@zope.org> Cc: <brian@digicool.com> Sent: Wednesday, March 28, 2001 7:50 PM Subject: RE: [Zope] Product that catches webdav PUTs and does something else <snipped excellent tutorial>
Hopefully this sheds some light on what happens underneath and make the PUT_factory document more useful - if you still can't get PUT_factory to work as expected you might want to contact the author (Tres) to make sure it is up to date (I can't tell from a glance - but knowing Tres I suspect it is up to date :).
Thank you so much, that is just what I needed. I was trying to implement the PUT_factory method from within my dtml-documentish class, and consequently, it wasn't working as Zope couldn't find a PUT_factory for an instance that hadn't been created. I haven't tried having a PUT_factory in a parent folder yet (I'm having other difficulties atm), but I hope it'll work now I actually know what I'm doing! Thanks so much tim
participants (2)
-
Brian Lloyd -
Tim Hicks