John DeStefano, on 2008-04-08: > Thanks, Maurits and Hedley, for an excellent kick-start. I have much > to review and implement here. > > Maurits van Rees wrote: >>> http://deesto.pastebin.com/f4d16e1bd >> >> That subscriber is now subscribed to events on *all* objects. Not all >> objects will have all the info you want, like affectedArea. So that >> can give problems. >> >> You can either check for portal_type='Announcement' in the event >> handler, or (better) you create a (marker) interface, let the >> Announcement class implement it and register the subscriber for that >> interface instead of '*'. > > If I may ask: how would you do this, by adding another condition to > the workflow subscriber? > or portal_type != 'Announcement' # ?
Yes. (well, it would be obj.portal_type of course) An interface would be better though, as that makes sure that your subscriber only gets called when one of your announcements is being transitioned. So that would be something like this in your configure.zcml: ========================================== <configure xmlns="http://namespaces.zope.org/zope"> <subscriber for=".interfaces.IAnnouncement Products.DCWorkflow.interfaces.IAfterTransitionEvent" handler=".subscribers.emailListListener" /> </configure> ========================================== In interfaces.py: ========================================== from zope.interface import Interface class IAnnouncement(Interface): pass ========================================== In announcement.py (or wherever you define the Announcement class): ========================================== from zope.interface import implements from interfaces import IAnnouncement class Announcement(...): ... implements(IAnnouncement) ... ========================================== -- Maurits van Rees | http://maurits.vanrees.org/ Work | http://zestsoftware.nl/ "This is your day, don't let them take it away." [Barlow Girl] _______________________________________________ Product-Developers mailing list [email protected] http://lists.plone.org/mailman/listinfo/product-developers
