[Zope3-Users] Object-deleted-events
Hi, I'd like to implement an event to be fired when an InternalPrincipal shall be deleted from a PrincipalFolder. class IObjectShallBeDeletedEvent(IObjectEvent): Event, when an object will be deleted. class ObjectShallBeDeletedEvent(object): Event, when an object will be deleted. implements(IObjectDeletedEvent) def __init__(self, obj): self.object = obj class MyPrincipal(InternalPrincipal): def __del__(self): notify(ObjectShallBeDeletedEvent(self)) super(MyObject, self).__del__() Because of some reason my event will not be fired. Did I miss something? For now I implemented this by subclassing PrincipalFolder and adding my notify call to the __delitem__ method. That works well. But I would prefer an implementation like drafted above. Regards, Tobias ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Object-deleted-events
Hi Thierry, On Jan 7, 2008, at 4:44 PM, Thierry Florac wrote: For your use case, the only thing you should do is just to implement a subscriber to IObjectRemovedEvent (defined into zope.app.container.interfaces) which is automatically fired by all standard Zope3 containers. Hope this helps, Thank you very much! Works well. Now I know why I didn't find any IObjectDeletedEvent before ;-) Tobias ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How
On 08/25/2007 at 19:22 Yuan HOng wrote: In my page template, I would like to show one message if the request is authenticated, and other if the user has not logged in. Is there a simple test I can use in the template file like? For me the following works well: span tal:condition=python: request.principal.id != 'zope.anybody'Welcome, span tal:replace=request/principal/ titleuser name/span/span Cheers, Tobias ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: catalog of objects' states (hurry.workflow)
Philipp von Weitershausen wrote: Alek Kowalczyk wrote: Hello again, I have a rather big tree of MyObjects. MyObjects are adaptable to hurry.workflow's IWorklowState. Now I'd like to create a catalog to index all MyObjects by their current states. How to do that? An option might be(?) to add to MyObject property like that: @property def currentState(self): return IWorkflowState(self).getState() and index this property. But I'm not sure whether it is elegant solution, as it requires the object to know that it has workflow and (too) strong link between object and adapter. Right. Fortunately, indexes know how to adapt. So, in order to index the workflow state of your objects, configure a FieldIndex (or ValueIndex from zc.catalog) to the IWorkflowState interface. Specify the 'getState' attribute and check the 'callable' option (because it's a method). When encountering an object to be indexed, the FieldIndex (or ValueIndex) will then try to adapt it to IWorkflowState. If that succeeds (and it will for your MyObjects), it will call the getState () method on that adapter and index the return value. That worked for me with zope.app.catalog: catalog = Catalog() catalog[u'workflow_state'] = FieldIndex(interface=IWorkflowState, field_name='getState', field_callable=True) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Using svn checkout with zc packages
Am 30.07.2007 um 19:37 schrieb Philipp von Weitershausen: I'm not sure what working in the zc.buildout is supposed to mean. I don't consider zc.buildout evil. Not totally at least :). I benefit from zc.buildout in two ways for my zope projects since i figured it out: - every-time-and-every-place reproducable development environments - only install what is really necessary But sometimes: - I am bothered by that .installed.cfg (I always stumble over it, because it's hidden). - Someone already mentioned the .pyc-file misery. - And it's not easy to find the right order for including the .zcml-files in larger projects. Maybe there is a recommended order somewhere which I didn't recognize until now. I thought about extracting it from the DEPENDENCIES.cfg and import-statements. Altogether it is really worth to dive into zc.buildout (but you should take a deep breath ;-) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users