[Checkins] SVN: zamplugin.error/trunk/ - fix ErrorReportingUtility edit form. The form was ignoring the

Roger Ineichen roger at projekt01.ch
Tue Jun 10 10:46:25 EDT 2008


Log message for revision 87287:
  - fix ErrorReportingUtility edit form. The form was ignoring the 
    ``ignored_exceptions`` attribute because of ignoreContext=True and could not 
    store the ``keep_entries`` value because of broken implementation.
  
  - Added tests for edit.html page

Changed:
  U   zamplugin.error/trunk/CHANGES.txt
  U   zamplugin.error/trunk/src/zamplugin/error/README.txt
  U   zamplugin.error/trunk/src/zamplugin/error/browser.py
  U   zamplugin.error/trunk/src/zamplugin/error/manager.py
  U   zamplugin.error/trunk/src/zamplugin/error/widget.py

-=-
Modified: zamplugin.error/trunk/CHANGES.txt
===================================================================
--- zamplugin.error/trunk/CHANGES.txt	2008-06-10 14:42:45 UTC (rev 87286)
+++ zamplugin.error/trunk/CHANGES.txt	2008-06-10 14:46:16 UTC (rev 87287)
@@ -5,8 +5,13 @@
 Version 0.5.1dev (unreleased)
 -----------------------------
 
-- ...
+- fix ErrorReportingUtility edit form. The form was ignoring the 
+  ``ignored_exceptions`` attribute because of ignoreContext=True and could not 
+  store the ``keep_entries`` value because of broken implementation.
 
+- Added tests for edit.html page
+
+
 Version 0.5.0 (2008-04-14)
 -------------------------
 

Modified: zamplugin.error/trunk/src/zamplugin/error/README.txt
===================================================================
--- zamplugin.error/trunk/src/zamplugin/error/README.txt	2008-06-10 14:42:45 UTC (rev 87286)
+++ zamplugin.error/trunk/src/zamplugin/error/README.txt	2008-06-10 14:46:16 UTC (rev 87287)
@@ -43,7 +43,6 @@
       site recently.</p>
     <div>
       <em> No exceptions logged. </em>
-  <BLANKLINE>
     </div>
     <!-- just offer reload button -->
     <form action="." method="get">
@@ -55,3 +54,48 @@
     </form>
   </div>
   ...
+
+Let's go to the edit.html page:
+
+  >>> mgr.open(rootURL + '/++etc++site/default/RootErrorReportingUtility/edit.html')
+  >>> print mgr.contents
+  <!DOCTYPE ...
+  ...<div class="widget"><input type="text" id="form-widgets-keep_entries"
+                     name="form.widgets.keep_entries"
+                     class="text-widget required int-field" value="20" />
+  ...<label for="form-widgets-copy_to_zlog-1">
+      <input type="radio" id="form-widgets-copy_to_zlog-1"
+             name="form.widgets.copy_to_zlog:list"
+             class="radio-widget required bool-field"
+             value="false" checked="checked" />
+      <span class="label">no</span>
+  ...<div class="widget"><textarea id="form-widgets-ignored_exceptions"
+            name="form.widgets.ignored_exceptions"
+            class="textarea-widget required tuple-field">Unauthorized</textarea>
+  ...
+
+And change the configuration:
+
+  >>> mgr.getControl('Keep entries').value = '10'
+  >>> mgr.getControl(name='form.widgets.copy_to_zlog:list').value = ['true']
+  >>> mgr.getControl('Ignore exceptions').value = 'UserError'
+  >>> mgr.getControl('Apply').click()
+
+Now go to the edit.html page and check the values again.
+
+  >>> mgr.open(rootURL + '/++etc++site/default/RootErrorReportingUtility/edit.html')
+  >>> print mgr.contents
+  <!DOCTYPE ...
+  ...<div class="widget"><input type="text" id="form-widgets-keep_entries"
+                     name="form.widgets.keep_entries"
+                     class="text-widget required int-field" value="10" />
+  ...<label for="form-widgets-copy_to_zlog-1">
+      <input type="radio" id="form-widgets-copy_to_zlog-1"
+             name="form.widgets.copy_to_zlog:list"
+             class="radio-widget required bool-field"
+             value="false" />
+      <span class="label">no</span>
+  ...<div class="widget"><textarea id="form-widgets-ignored_exceptions"
+            name="form.widgets.ignored_exceptions"
+            class="textarea-widget required tuple-field">UserError</textarea>
+  ...

Modified: zamplugin.error/trunk/src/zamplugin/error/browser.py
===================================================================
--- zamplugin.error/trunk/src/zamplugin/error/browser.py	2008-06-10 14:42:45 UTC (rev 87286)
+++ zamplugin.error/trunk/src/zamplugin/error/browser.py	2008-06-10 14:46:16 UTC (rev 87287)
@@ -22,48 +22,27 @@
 import zope.i18nmessageid
 _ = zope.i18nmessageid.MessageFactory('zam')
 
-from z3c.form import form
+from z3c.formui import form
 from z3c.form import field
 from z3c.form import button
-from z3c.formui import layout
 from z3c.pagelet import browser
 
 from zamplugin.error import interfaces
 from zamplugin.error import widget
 
 
-class EditErrorLog(layout.FormLayoutSupport, form.Form):
+class EditErrorLog(form.EditForm):
 
     zope.interface.implements(interfaces.IErrorReportingUtilityPage)
 
     formErrorsMessage = _('There were some errors.')
     successMessage = _('Data successfully updated.')
-    ignoreContext = True
 
     fields = field.Fields(interfaces.IErrorReportingUtilityManager)
 
     fields['ignored_exceptions'].widgetFactory = widget.TextLinesFieldWidget
 
-    def updateProperties(self, keep_entries, copy_to_zlog=None,
-                         ignored_exceptions=None):
-        if copy_to_zlog is None:
-            copy_to_zlog = 0
-        self.context.setProperties(keep_entries, copy_to_zlog,
-            ignored_exceptions)
 
-    @button.buttonAndHandler(_('Apply'), name='apply')
-    def handleApply(self, action):
-        data, errors = self.extractData()
-        if errors:
-            self.status = self.formErrorsMessage
-            return
-        keep_entries = data['keep_entries']
-        copy_to_zlog = data['copy_to_zlog']
-        ignored_exceptions = data['ignored_exceptions']
-        self.updateProperties(keep_entries, copy_to_zlog, ignored_exceptions)
-        self.status = self.successMessage
-
-
 class Errors(browser.BrowserPagelet):
     """Error listing page."""
 

Modified: zamplugin.error/trunk/src/zamplugin/error/manager.py
===================================================================
--- zamplugin.error/trunk/src/zamplugin/error/manager.py	2008-06-10 14:42:45 UTC (rev 87286)
+++ zamplugin.error/trunk/src/zamplugin/error/manager.py	2008-06-10 14:46:16 UTC (rev 87287)
@@ -44,7 +44,8 @@
             keep_entries = value
             copy_to_zlog = data['copy_to_zlog']
             ignored_exceptions = data['ignored_exceptions']
-            setProperties(keep_entries, copy_to_zlog, ignored_exceptions)
+            self.context.setProperties(keep_entries, copy_to_zlog,
+                ignored_exceptions)
         return property(get, set)
 
     @apply

Modified: zamplugin.error/trunk/src/zamplugin/error/widget.py
===================================================================
--- zamplugin.error/trunk/src/zamplugin/error/widget.py	2008-06-10 14:42:45 UTC (rev 87286)
+++ zamplugin.error/trunk/src/zamplugin/error/widget.py	2008-06-10 14:46:16 UTC (rev 87287)
@@ -47,7 +47,7 @@
 
 
 class TextLinesConverter(converter.BaseDataConverter):
-    """Data converter for IOfficeIdsWidget."""
+    """Data converter for ITextLinesWidget."""
 
     zope.component.adapts(
         zope.schema.interfaces.ITuple, interfaces.ITextLinesWidget)



More information about the Checkins mailing list