[Zope-CMF] IObjectAdded vs. manage_afterAdd
Jens Vagelpohl
jens at dataflake.org
Mon Jan 22 18:24:33 EST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 22 Jan 2007, at 21:57, Doyon, Jean-Francois wrote:
> Hello,
>
> I'm trying to use IObjectAdded for an object that looks like this:
>
> class MapServerMap(PortalFolder, PortalContent, CLFMetadataImpl):
> """ Map Server Map Class """
>
> implements(IMapServerMap)
>
> Without success ... The event doesn't seem to fire at all.
If you want to react to an event you need to do two things:
- - mark your content item with an interface (you already did this)
- - code up a handler for the event
- - register your handler for the event
Only implementing some interface is not enough. You could have a
function like this somewhere:
def handleEvent(ob, event):
""" Event subscriber for (IMapServerMap, IObjectAdded) events.
"""
if event.newParent is not None:
<do something>
and a registration like this:
<subscriber
for=".interfaces.IMapServerMap
zope.component.interfaces.IObjectAdded"
handler=".MyModule.handleEvent"
/>
jens
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
iD8DBQFFtUexRAx5nvEhZLIRAs64AJ0X3BFyHHvi0t9Xh6PXu9B7owh1CwCgm15n
LB0X4yyOEc9+fU5XQjvjHC8=
=cB8Z
-----END PGP SIGNATURE-----
More information about the Zope-CMF
mailing list