[Zope] getting parent in product

Dylan Reinhardt zope@dylanreinhardt.com
01 Aug 2003 11:20:12 -0700


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