[Checkins] SVN: z3c.form/trunk/ - Implemented IDisplayForm interface

Roger Ineichen roger at projekt01.ch
Sat Dec 29 21:01:48 EST 2007


Log message for revision 82559:
  - Implemented IDisplayForm interface
  - Added integration tests for form interfaces. Added default class attribute
    called widgets in form class with default value ?\194?\180?\194?\180None?\194?\180?\194?\180?\194?\180. This helps to 
    pass the integration tests. Now, the widget attribute can also be used as a 
    indicator for updated forms.

Changed:
  U   z3c.form/trunk/CHANGES.txt
  U   z3c.form/trunk/src/z3c/form/form.py
  U   z3c.form/trunk/src/z3c/form/form.txt
  U   z3c.form/trunk/src/z3c/form/interfaces.py

-=-
Modified: z3c.form/trunk/CHANGES.txt
===================================================================
--- z3c.form/trunk/CHANGES.txt	2007-12-30 00:47:49 UTC (rev 82558)
+++ z3c.form/trunk/CHANGES.txt	2007-12-30 02:01:46 UTC (rev 82559)
@@ -6,6 +6,13 @@
 Version 1.7.1dev (unreleased)
 -----------------------------
 
+- Implemented IDisplayForm
+
+- Added integration tests for form interfaces. Added default class attribute
+  widgets in form class with default value ´´None´´´. This helps to pass the
+  integration tests. Now, the widget attribute can also be used as a indicator
+  for updated forms.
+
 - Implemented additional createAndAdd hook in AddForm. This allows you to
   implement create and add in a single method. It also supports gracefull
   abort of a creat and add process if we do not return the new object. Which

Modified: z3c.form/trunk/src/z3c/form/form.py
===================================================================
--- z3c.form/trunk/src/z3c/form/form.py	2007-12-30 00:47:49 UTC (rev 82558)
+++ z3c.form/trunk/src/z3c/form/form.py	2007-12-30 02:01:46 UTC (rev 82559)
@@ -104,6 +104,7 @@
     prefix = 'form.'
     status = ''
     template = None
+    widgets  = None
 
     mode = interfaces.INPUT_MODE
     ignoreContext = False
@@ -144,6 +145,8 @@
 
 class DisplayForm(BaseForm):
 
+    zope.interface.implements(interfaces.IDisplayForm)
+
     mode = interfaces.DISPLAY_MODE
     ignoreRequest = True
 

Modified: z3c.form/trunk/src/z3c/form/form.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/form.txt	2007-12-30 00:47:49 UTC (rev 82558)
+++ z3c.form/trunk/src/z3c/form/form.txt	2007-12-30 02:01:46 UTC (rev 82559)
@@ -1409,3 +1409,108 @@
     >>> event = action.ActionErrorOccurred(cancel, ValueError(3))
 
     >>> form.handleActionError(event)
+
+
+Integration tests
+-----------------
+
+Identify the different forms can be important if it comes to layout template
+lookup. Ensure that we support the right interfaces for the different forms.
+
+
+Form
+~~~~
+
+  >>> from zope.interface.verify import verifyObject
+  >>> from z3c.form import interfaces
+  >>> obj = form.Form(None, None)
+  >>> verifyObject(interfaces.IForm, obj)
+  True
+
+  >>> interfaces.IForm.providedBy(obj)
+  True
+
+  >>> from z3c.form import interfaces
+  >>> interfaces.IDisplayForm.providedBy(obj)
+  False
+
+  >>> from z3c.form import interfaces
+  >>> interfaces.IEditForm.providedBy(obj)
+  False
+
+  >>> from z3c.form import interfaces
+  >>> interfaces.IAddForm.providedBy(obj)
+  False
+
+
+DisplayForm
+~~~~~~~~~~~
+
+  >>> from z3c.form import interfaces
+  >>> obj = form.DisplayForm(None, None)
+  >>> verifyObject(interfaces.IDisplayForm, obj)
+  True
+
+  >>> interfaces.IForm.providedBy(obj)
+  True
+
+  >>> from z3c.form import interfaces
+  >>> interfaces.IDisplayForm.providedBy(obj)
+  True
+
+  >>> from z3c.form import interfaces
+  >>> interfaces.IEditForm.providedBy(obj)
+  False
+
+  >>> from z3c.form import interfaces
+  >>> interfaces.IAddForm.providedBy(obj)
+  False
+
+
+EditForm
+~~~~~~~~
+
+  >>> from z3c.form import interfaces
+  >>> obj = form.EditForm(None, None)
+  >>> verifyObject(interfaces.IEditForm, obj)
+  True
+
+  >>> interfaces.IForm.providedBy(obj)
+  True
+
+  >>> from z3c.form import interfaces
+  >>> interfaces.IDisplayForm.providedBy(obj)
+  False
+
+  >>> from z3c.form import interfaces
+  >>> interfaces.IEditForm.providedBy(obj)
+  True
+
+  >>> from z3c.form import interfaces
+  >>> interfaces.IAddForm.providedBy(obj)
+  False
+
+
+
+AddForm
+~~~~~~~
+
+  >>> from z3c.form import interfaces
+  >>> obj = form.AddForm(None, None)
+  >>> verifyObject(interfaces.IAddForm, obj)
+  True
+
+  >>> interfaces.IForm.providedBy(obj)
+  True
+
+  >>> from z3c.form import interfaces
+  >>> interfaces.IDisplayForm.providedBy(obj)
+  False
+
+  >>> from z3c.form import interfaces
+  >>> interfaces.IEditForm.providedBy(obj)
+  False
+
+  >>> from z3c.form import interfaces
+  >>> interfaces.IAddForm.providedBy(obj)
+  True

Modified: z3c.form/trunk/src/z3c/form/interfaces.py
===================================================================
--- z3c.form/trunk/src/z3c/form/interfaces.py	2007-12-30 00:47:49 UTC (rev 82558)
+++ z3c.form/trunk/src/z3c/form/interfaces.py	2007-12-30 02:01:46 UTC (rev 82559)
@@ -787,6 +787,11 @@
 class ISubForm(IForm):
     """A subform."""
 
+
+class IDisplayForm(IForm):
+    """Mark a form as display form, used for tempaltes."""
+
+
 class IInputForm(zope.interface.Interface):
     """A form that is meant to process the input of the form controls."""
 



More information about the Checkins mailing list