[Checkins] SVN: z3c.form/trunk/ - set version to 1.7.1dev

Roger Ineichen roger at projekt01.ch
Fri Dec 28 11:04:49 EST 2007


Log message for revision 82501:
  - set version to 1.7.1dev
  - Implemented additional createAndAdd hook in AddForm. This allows us 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
    means it can also be used as a hook for custom error messages for errors
    happen during create and add.
  - Update CHANGES.txt
  - no additional tests since this method is very well tested in other tests
  - still 100% test coverage, except the compatibility patch

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

-=-
Modified: z3c.form/trunk/CHANGES.txt
===================================================================
--- z3c.form/trunk/CHANGES.txt	2007-12-28 15:49:03 UTC (rev 82500)
+++ z3c.form/trunk/CHANGES.txt	2007-12-28 16:04:49 UTC (rev 82501)
@@ -3,9 +3,15 @@
 =======
 
 
-After Version 1.7.0
--------------------
+Version 1.7.1dev (unreleased)
+-----------------------------
 
+- 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
+  means it can also be used as a hook for custom error messages for errors
+  happen during create and add.
+
 - Feature: Add a hidden widget template for the ``ISelectWidget``.
 
 - Feature: arrows in orderedselect replaced by named entities 

Modified: z3c.form/trunk/setup.py
===================================================================
--- z3c.form/trunk/setup.py	2007-12-28 15:49:03 UTC (rev 82500)
+++ z3c.form/trunk/setup.py	2007-12-28 16:04:49 UTC (rev 82501)
@@ -43,7 +43,7 @@
 
 setup (
     name='z3c.form',
-    version='1.7.0',
+    version='1.7.1dev',
     author = "Stephan Richter, Roger Ineichen and the Zope Community",
     author_email = "zope3-dev at zope.org",
     description = "An advanced form and widget framework for Zope 3",
@@ -74,9 +74,13 @@
     package_dir = {'':'src'},
     namespace_packages = ['z3c'],
     extras_require = dict(
-        test = ['zope.app.container', 'zope.testing',
-                'z3c.coverage', 'z3c.template',
-                'zope.app.i18n', ],
+        test = [
+            'zope.app.container',
+            'zope.testing',
+            'z3c.coverage',
+            'z3c.template',
+            'zope.app.i18n',
+            ],
         adding = ['zope.app.container'],
         ),
     install_requires = [

Modified: z3c.form/trunk/src/z3c/form/form.py
===================================================================
--- z3c.form/trunk/src/z3c/form/form.py	2007-12-28 15:49:03 UTC (rev 82500)
+++ z3c.form/trunk/src/z3c/form/form.py	2007-12-28 16:04:49 UTC (rev 82501)
@@ -203,10 +203,16 @@
         if errors:
             self.status = self.formErrorsMessage
             return
+        obj = self.createAndAdd(data)
+        if obj is not None:
+            # mark only as finished if we get the new object
+            self._finishedAdd = True
+
+    def createAndAdd(self, data):
         obj = self.create(data)
         zope.event.notify(zope.lifecycleevent.ObjectCreatedEvent(obj))
         self.add(obj)
-        self._finishedAdd = True
+        return obj
 
     def create(self, data):
         raise NotImplementedError

Modified: z3c.form/trunk/src/z3c/form/interfaces.py
===================================================================
--- z3c.form/trunk/src/z3c/form/interfaces.py	2007-12-28 15:49:03 UTC (rev 82500)
+++ z3c.form/trunk/src/z3c/form/interfaces.py	2007-12-28 16:04:49 UTC (rev 82501)
@@ -844,7 +844,16 @@
     def add(object):
         """Add the object somewhere."""
 
+    def createAndAdd(data):
+        """Call create and add.
+        
+        This method can be used for keep all attributes internal during create 
+        and add calls. On sucess we return the new created and added object.
+        If something fails, we return None. The default handleAdd method will
+        only set the _finishedAdd marker on sucess.
+        """
 
+
 class IEditForm(IForm):
     """A form to edit data of a component."""
 



More information about the Checkins mailing list