[Checkins] SVN: grokui.admin/trunk/src/grokui/admin/tests/events.py Add a test for ObjectCreated events.

Uli Fouquet uli at gnufix.de
Mon Sep 14 10:50:48 EDT 2009


Log message for revision 103928:
  Add a test for ObjectCreated events.
  

Changed:
  A   grokui.admin/trunk/src/grokui/admin/tests/events.py

-=-
Added: grokui.admin/trunk/src/grokui/admin/tests/events.py
===================================================================
--- grokui.admin/trunk/src/grokui/admin/tests/events.py	                        (rev 0)
+++ grokui.admin/trunk/src/grokui/admin/tests/events.py	2009-09-14 14:50:48 UTC (rev 103928)
@@ -0,0 +1,46 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+Events
+******
+
+When we create a new app, a grok.IObjectCreatedEvent is called:
+
+  >>> from zope.testbrowser.testing import Browser
+  >>> browser = Browser()
+  >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+  
+We fetch the standard page, which should provide us a menu to get all
+installable grok applications/components.
+
+  >>> browser.open("http://localhost/")
+
+When we create a new instance of our app, the eventhandler defined
+below will be called:
+
+  >>> subform = browser.getForm(name='App')
+  >>> subform.getControl('Name your new app:').value = 'my-app'
+  >>> subform.getControl('Create').click()
+  ObjectCreated event happened.
+
+"""
+import grok
+from zope.component import interfaces
+
+class App(grok.Application, grok.Container):
+    pass
+
+ at grok.subscribe(App, grok.IObjectCreatedEvent)
+def handle_my_event(obj, event):
+    print "ObjectCreated event happened."



More information about the checkins mailing list