[Checkins] SVN: z3c.formjs/trunk/src/z3c/formjs/jsclientevent. Fixed a bug relating to event catching when no request was used (i.e.

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu Aug 23 17:43:26 EDT 2007


Log message for revision 79189:
  Fixed a bug relating to event catching when no request was used (i.e. 
  Zope 3 startup)
  

Changed:
  U   z3c.formjs/trunk/src/z3c/formjs/jsclientevent.py
  U   z3c.formjs/trunk/src/z3c/formjs/jsclientevent.txt

-=-
Modified: z3c.formjs/trunk/src/z3c/formjs/jsclientevent.py
===================================================================
--- z3c.formjs/trunk/src/z3c/formjs/jsclientevent.py	2007-08-23 21:39:08 UTC (rev 79188)
+++ z3c.formjs/trunk/src/z3c/formjs/jsclientevent.py	2007-08-23 21:43:26 UTC (rev 79189)
@@ -103,7 +103,13 @@
     the form and rendered as a client side function call."""
 
     # Step 1: Get the interaction.
-    interaction = getInteraction()
+    try:
+        interaction = getInteraction()
+    except zope.security.interfaces.NoInteraction:
+        # If there is no interaction, we simply return, because we cannot do
+        # any work anyways. This also means that the event was not created
+        # during a request, so we do not have a form anyways.
+        return
     participations = interaction.participations
 
     # Step 2-1: Look for a request in the participation.

Modified: z3c.formjs/trunk/src/z3c/formjs/jsclientevent.txt
===================================================================
--- z3c.formjs/trunk/src/z3c/formjs/jsclientevent.txt	2007-08-23 21:39:08 UTC (rev 79188)
+++ z3c.formjs/trunk/src/z3c/formjs/jsclientevent.txt	2007-08-23 21:43:26 UTC (rev 79189)
@@ -126,6 +126,17 @@
   >>> from z3c.form.testing import TestRequest
   >>> request = TestRequest(form={'form.widgets.title':u'New Title',
   ...                             'form.buttons.apply':u'Apply'})
+
+  >>> form = ArticleEditForm(article, request)
+  >>> form.update()
+
+  >>> request.annotations.get(jsclientevent.CLIENT_EVENT_REQUEST_KEY)
+
+Initially nothing happens, because we did not register an interaction:
+
+  >>> request = TestRequest(form={'form.widgets.title':u'New Title 2',
+  ...                             'form.buttons.apply':u'Apply'})
+
   >>> from zope.security import management
   >>> from zope.security.testing import Participation
   >>> management.endInteraction()



More information about the Checkins mailing list