[Checkins] SVN: plone.z3cform/trunk/ Don't display an apply changes if you don't define an update_schema.

Sylvain Viollon sylvain at infrae.com
Tue Dec 2 09:02:04 EST 2008


Log message for revision 93543:
  Don't display an apply changes if you don't define an update_schema.
  Clean useless whitespaces.
  
  

Changed:
  U   plone.z3cform/trunk/docs/HISTORY.txt
  U   plone.z3cform/trunk/plone/z3cform/crud/crud.py

-=-
Modified: plone.z3cform/trunk/docs/HISTORY.txt
===================================================================
--- plone.z3cform/trunk/docs/HISTORY.txt	2008-12-02 13:50:33 UTC (rev 93542)
+++ plone.z3cform/trunk/docs/HISTORY.txt	2008-12-02 14:02:04 UTC (rev 93543)
@@ -3,6 +3,10 @@
 
 0.5.3 - unreleased
 ------------------
+
+* Don't display an 'Apply changes' button if you don't define an
+  update_schema.
+
 * Declare xmlnamespace into 'layout.pt' and 'subform.pt' templates
 
 * Added support for an editsubform_factory for an EditForm so you can

Modified: plone.z3cform/trunk/plone/z3cform/crud/crud.py
===================================================================
--- plone.z3cform/trunk/plone/z3cform/crud/crud.py	2008-12-02 13:50:33 UTC (rev 93542)
+++ plone.z3cform/trunk/plone/z3cform/crud/crud.py	2008-12-02 14:02:04 UTC (rev 93543)
@@ -75,7 +75,7 @@
 class AbstractCrudForm(object):
     """The AbstractCrudForm is not a form but implements methods
     necessary to comply with the ``ICrudForm`` interface:
-    
+
       >>> from zope.interface.verify import verifyClass
       >>> verifyClass(ICrudForm, AbstractCrudForm)
       True
@@ -136,7 +136,7 @@
                 if not f.__name__.startswith('view_'):
                     f.__name__ = 'view_' + f.__name__
             fields += view_fields
-            
+
         return fields
 
     def getContent(self):
@@ -149,7 +149,7 @@
                              title=_(u'select')))
         select_field.widgetFactory[INPUT_MODE] = singlecheckboxwidget_factory
         return select_field
-        
+
     # XXX: The three following methods, 'getCombinedWidgets',
     # 'getTitleWidgets', and 'getNiceTitles' are hacks to support the
     # page template.  Let's get rid of them.
@@ -170,19 +170,19 @@
                 if widget not in seen:
                     combined.append((widget,))
         return combined
-             
+
     def getTitleWidgets(self):
         combinedWidgets = self.getCombinedWidgets()
         widgetsForTitles = [w[0] for w in combinedWidgets]
         return widgetsForTitles
 
     def getNiceTitles(self):
-        widgetsForTitles = self.getTitleWidgets()        
+        widgetsForTitles = self.getTitleWidgets()
         freakList = []
         for item in widgetsForTitles:
             freakList.append(item.field.title)
         return freakList
-        
+
 class BatchItem(object):
     def __init__(self, label, link=None):
         self.label = label
@@ -218,7 +218,7 @@
 class EditForm(form.Form):
     label = _(u"Edit")
     template = viewpagetemplatefile.ViewPageTemplateFile('crud-table.pt')
-    
+
     #exposes the edit sub form for your own derivatives
     editsubform_factory = EditSubForm
 
@@ -230,7 +230,7 @@
     def update(self):
         self._update_subforms()
         super(EditForm, self).update()
-    
+
     def _update_subforms(self):
         self.subforms = []
         for id, item in self.batch:
@@ -260,7 +260,9 @@
         name = '%spage' % self.prefix
         return int(self.request.get(name, '0'))
 
-    @button.buttonAndHandler(_('Apply changes'), name='edit')
+    @button.buttonAndHandler(_('Apply changes'),
+                             name='edit',
+                             condition=lambda form: form.context.update_schema)
     def handle_edit(self, action):
         success = _(u"Successfully updated")
         partly_success = _(u"Some of your changes could not be applied.")
@@ -313,7 +315,7 @@
                     # unexpected behavior:
                     self.status = _(u'Unable to remove one or more items.')
                     break
-        
+
             # We changed the amount of entries, so we update the subforms again.
             self._update_subforms()
         else:



More information about the Checkins mailing list