getting parent in product
Hello, I've written a ZMI configurable PutFactory Product to allow our users to be able to configure what types of objects are created when files are PUT using WebDav. What I would like to add is the ability to call a script immediately after the object is created. The script could do things like auto-catalog images in a ZCatalog or send out an email every time a file is uploaded. Looking at the code in webdav/NullResource.py NullResources.PUT(): ob = (factory(name, typ, body) or 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 Unauthorized: raise except: raise 'Forbidden', sys.exc_info()[1] # Delegate actual PUT handling to the new object. ob.PUT(REQUEST, RESPONSE) self.__parent__._setObject(name, ob) RESPONSE.setStatus(201) it doesn't look like I can do what I'd like to do without overriding NullResource.PUT(). Any thoughts on how to accomplish this? Thanks, -Chris -- -------------------------------------------------------------------- Christopher N. Deckard | Lead Web Systems Developer cnd@ecn.purdue.edu | Engineering Computer Network http://eng.purdue.edu/ECN/ | Purdue University ---- zlib.decompress('x\234K\316Kq((-J)M\325KM)\005\000)"\005w') ---
Apologies, I forgot to change the subject of the message. -Chris On Fri, 1 Aug 2003 13:04:49 -0500, Christopher N. Deckard spoke forth:
Hello, I've written a ZMI configurable PutFactory Product to allow our users to be able to configure what types of objects are created when files are PUT using WebDav. What I would like to add is the ability to call a script immediately after the object is created. The script could do things like auto-catalog images in a ZCatalog or send out an email every time a file is uploaded.
Looking at the code in webdav/NullResource.py NullResources.PUT():
ob = (factory(name, typ, body) or 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 Unauthorized: raise except: raise 'Forbidden', sys.exc_info()[1]
# Delegate actual PUT handling to the new object. ob.PUT(REQUEST, RESPONSE) self.__parent__._setObject(name, ob)
RESPONSE.setStatus(201)
it doesn't look like I can do what I'd like to do without overriding NullResource.PUT(). Any thoughts on how to accomplish this?
Thanks, -Chris
-- -------------------------------------------------------------------- Christopher N. Deckard | Lead Web Systems Developer cnd@ecn.purdue.edu | Engineering Computer Network http://eng.purdue.edu/ECN/ | Purdue University ---- zlib.decompress('x\234K\316Kq((-J)M\325KM)\005\000)"\005w') ---
add a method with the signature "manage_afterAdd(self, item, container)" to the class that you are instantiating. it is always called after instantiation. jens On Friday, Aug 1, 2003, at 14:04 US/Eastern, Christopher N. Deckard wrote:
What I would like to add is the ability to call a script immediately after the object is created. The script could do things like auto-catalog images in a ZCatalog or send out an email every time a file is uploaded.
Alright, I got that to work, but I have some problems with it. The new manage_afterAdd is permanent. I want the object to have it's normal manage_afterAdd method. I also want that manage_afterAdd method to be called in addition to my extra code. Is there a way to get at it? Is there a way to reset manage_afterAdd to the normal one? This is important. For example, if you have a catalog aware object, the new manage_afterAdd method will not do any of the cataloging. Thanks, -Chris On Fri, 1 Aug 2003 14:13:10 -0400, Jens Vagelpohl spoke forth:
add a method with the signature "manage_afterAdd(self, item, container)" to the class that you are instantiating. it is always called after instantiation.
jens
On Friday, Aug 1, 2003, at 14:04 US/Eastern, Christopher N. Deckard wrote:
What I would like to add is the ability to call a script immediately after the object is created. The script could do things like auto-catalog images in a ZCatalog or send out an email every time a file is uploaded.
If you don't want to override this method (and it's not clear why you wouldn't) you can bring about the same results by having a cron job periodically evaluate if anything has changed since last time the cron job was run. Once you've established if any changes have been made, then you can fire off other scripts to handle them as required. This approach will build some latency into the whole notification process, but depending on your requirements that might be acceptable or even preferable. It will assure, for example, the SMTP problems won't prevent your users from uploading files. :-) HTH, Dylan On Fri, 2003-08-01 at 11:04, Christopher N. Deckard wrote:
Hello, I've written a ZMI configurable PutFactory Product to allow our users to be able to configure what types of objects are created when files are PUT using WebDav. What I would like to add is the ability to call a script immediately after the object is created. The script could do things like auto-catalog images in a ZCatalog or send out an email every time a file is uploaded.
Looking at the code in webdav/NullResource.py NullResources.PUT():
ob = (factory(name, typ, body) or 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 Unauthorized: raise except: raise 'Forbidden', sys.exc_info()[1]
# Delegate actual PUT handling to the new object. ob.PUT(REQUEST, RESPONSE) self.__parent__._setObject(name, ob)
RESPONSE.setStatus(201)
it doesn't look like I can do what I'd like to do without overriding NullResource.PUT(). Any thoughts on how to accomplish this?
Thanks, -Chris
participants (3)
-
Christopher N. Deckard -
Dylan Reinhardt -
Jens Vagelpohl