[Grok-dev] Testing and events

Noe Nieto nnieto at noenieto.com
Wed Apr 11 14:13:05 UTC 2012


Thank you very much. It works now!

---
Noe

2012/4/11 Christian Klinger <cklinger at novareto.de>

> Hi Noe,
>
> you have to call in notify not the interface of the event, you have to
> call the event itself. This works in my applications:
>
>    def test_event(self):
>        import grok
>        root = self.layer.getRootFolder()
>        root['app'] = app = Grokbackground()
>        grok.notify(grok.**ApplicationInitializedEvent(**app))
>
> You can access the app in the subscriber via event.object.
>
>
> @grok.subscribe(grok.**IApplicationInitializedEvent)
> def handle_it(event):
>    print event.object
>
> HTH Christian
>
>
> Noe Nieto schrieb:
>
>> I'm doing integration testing and my app has an event subscription to
>> grok.**IApplicationInitializedEvent.
>>
>> When setting up my layer I'm doing the following (layer is
>> zope.fanstatic.testing.**ZopeFanstaticBrowserLayer):
>>
>>     def setUp(self):
>>         #Add test app
>>         from consworks.app import Consworks
>>         import grok
>>         self.root = self.layer.getRootFolder()
>>         self.root['app'] = Consworks()
>>         grok.notify(grok.**IApplicationInitializedEvent)
>>
>>
>> But the handler for IApplicationInitializedEvent is not being called.
>> What else do I need to do to make it work?
>>
>> --
>> ---
>> Noe Nieto
>> NNieto Consulting Services
>> M: nnieto at noenieto.com <mailto:nnieto at noenieto.com>
>> W: http://noenieto.com
>> T: @tzicatl <https://twitter.com/#%21/**tzicatl<https://twitter.com/#%21/tzicatl>
>> >
>> Li: Perfil en LinkedIn <http://www.linkedin.com/**
>> profile/view?id=84300665<http://www.linkedin.com/profile/view?id=84300665>
>> >
>>
>> ______________________________**_________________
>> Grok-dev mailing list
>> Grok-dev at zope.org
>> https://mail.zope.org/mailman/**listinfo/grok-dev<https://mail.zope.org/mailman/listinfo/grok-dev>
>>
>
> ______________________________**_________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/**listinfo/grok-dev<https://mail.zope.org/mailman/listinfo/grok-dev>
>



-- 
---
Noe Nieto
NNieto Consulting Services
M: nnieto at noenieto.com
W: http://noenieto.com
T:  @tzicatl <https://twitter.com/#%21/tzicatl>
Li: Perfil en LinkedIn <http://www.linkedin.com/profile/view?id=84300665>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.zope.org/pipermail/grok-dev/attachments/20120411/4c16d2a8/attachment.html>


More information about the Grok-dev mailing list