[Zope] getting parent in product

Christopher N. Deckard cnd@ecn.purdue.edu
Fri, 1 Aug 2003 13:04:49 -0500


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') ---