[Checkins] SVN: z3ext.layoutform/trunk/src/z3ext/layoutform/

Nikolay Kim fafhrd at datacom.kz
Thu Dec 4 07:48:14 EST 2008


Log message for revision 93611:
  

Changed:
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/configure.zcml
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/subform.py
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/utils.py

-=-
Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/configure.zcml
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/configure.zcml	2008-12-04 10:39:19 UTC (rev 93610)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/configure.zcml	2008-12-04 12:48:13 UTC (rev 93611)
@@ -10,6 +10,7 @@
      name="formError"
      factory=".error.FormErrorStatusMessage" />
 
+  <!-- form -->
   <interface
      name="form"
      type="z3ext.layout.interfaces.IPageletType"

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py	2008-12-04 10:39:19 UTC (rev 93610)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py	2008-12-04 12:48:13 UTC (rev 93611)
@@ -15,9 +15,9 @@
 
 $Id$
 """
-from zope import interface
+from zope import interface, schema
 from zope.i18nmessageid import MessageFactory
-from z3c.form.interfaces import IFormLayer
+from z3c.form.interfaces import IFormLayer, IButton
 from z3ext.layout.interfaces import IPagelet
 
 _ = MessageFactory('z3ext.layoutform')
@@ -69,13 +69,17 @@
     """ Sub form mixin for pagelet implementation."""
 
 
-class IAddButton(interface.Interface):
+class IAddButton(IButton):
     """ add button """
 
 
-class ISaveButton(interface.Interface):
+class ISaveButton(IButton):
     """ save button """
 
 
-class ICancelButton(interface.Interface):
+class ICancelButton(IButton):
     """ cancel button """
+
+
+class IBackButton(IButton):
+    """A button that returns to some previous state or screen."""

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/subform.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/subform.py	2008-12-04 10:39:19 UTC (rev 93610)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/subform.py	2008-12-04 12:48:13 UTC (rev 93611)
@@ -23,6 +23,7 @@
 from z3ext.statusmessage.interfaces import IStatusMessage
 
 from form import PageletForm
+from utils import applyChanges
 from interfaces import _, IPageletEditSubForm, ISaveButton
 
 
@@ -41,7 +42,7 @@
                 (self.formErrorsMessage,) + errors, 'formError')
         else:
             content = self.getContent()
-            changed = form.applyChanges(self, content, data)
+            changed = applyChanges(self, content, data)
             if changed:
                 event.notify(ObjectModifiedEvent(content))
                 IStatusMessage(self.request).add(self.successMessage)

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/utils.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/utils.py	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/utils.py	2008-12-04 12:48:13 UTC (rev 93611)
@@ -0,0 +1,35 @@
+##############################################################################
+#
+# Copyright (c) 2008 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.
+#
+##############################################################################
+""" 
+
+$Id:  2007-12-12 12:27:02Z fafhrd $
+"""
+from zope.component import getMultiAdapter
+from z3c.form.interfaces import IDataManager
+
+
+def applyChanges(form, content, data):
+    changes = {}
+    for name, field in form.fields.items():
+        # If the field is not in the data, then go on to the next one
+        if name not in data:
+            continue
+        # Get the datamanager and get the original value
+        dm = getMultiAdapter((content, field.field), IDataManager)
+        # Only update the data, if it is different
+        if dm.query() != data[name]:
+            dm.set(data[name])
+            # Record the change using information required later
+            changes.setdefault(dm.field.interface, []).append(name)
+    return changes



More information about the Checkins mailing list