[Checkins] SVN: z3ext.layoutform/trunk/ more subform code
Nikolay Kim
fafhrd at datacom.kz
Tue Dec 9 05:12:29 EST 2008
Log message for revision 93802:
more subform code
Changed:
U z3ext.layoutform/trunk/CHANGES.txt
U z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formbuttons.pt
U z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroups.pt
U z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formviewspace.pt
U z3ext.layoutform/trunk/src/z3ext/layoutform/error.py
U z3ext.layoutform/trunk/src/z3ext/layoutform/form.py
U z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py
U z3ext.layoutform/trunk/src/z3ext/layoutform/subform.py
-=-
Modified: z3ext.layoutform/trunk/CHANGES.txt
===================================================================
--- z3ext.layoutform/trunk/CHANGES.txt 2008-12-09 08:17:21 UTC (rev 93801)
+++ z3ext.layoutform/trunk/CHANGES.txt 2008-12-09 10:12:28 UTC (rev 93802)
@@ -2,9 +2,14 @@
CHANGES
=======
-- Added subform support
+1.3.0 (Unreleased)
+------------------
+- Added subforms
+- Fixed 'formError' status message
+
+
1.2.8 (2008-11-21)
------------------
Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formbuttons.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formbuttons.pt 2008-12-09 08:17:21 UTC (rev 93801)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formbuttons.pt 2008-12-09 10:12:28 UTC (rev 93802)
@@ -1,4 +1,4 @@
-<div class="z-form-controls">
+<div class="z-form-controls" tal:condition="context/actions">
<tal:block tal:content="structure
context/@@pagelet/layoutform.buttonsInfo|nothing" />
Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroups.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroups.pt 2008-12-09 08:17:21 UTC (rev 93801)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroups.pt 2008-12-09 10:12:28 UTC (rev 93802)
@@ -1,3 +1,3 @@
<tal:block
- tal:repeat="group context/groups"
- tal:content="structure group/@@pagelet/layoutform.group|nothing" />
+ tal:repeat="form context/forms"
+ tal:content="structure form/@@pagelet/layoutform.form|nothing" />
Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formviewspace.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formviewspace.pt 2008-12-09 08:17:21 UTC (rev 93801)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formviewspace.pt 2008-12-09 10:12:28 UTC (rev 93802)
@@ -11,6 +11,3 @@
<tal:block tal:repeat="widget context/widgets/values"
tal:content="structure widget/@@pagelet/layoutform.widget" />
</div>
-
-<tal:block tal:condition="context/groups|nothing"
- tal:content="structure context/@@pagelet/layoutform.formGroups|nothing" />
Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/error.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/error.py 2008-12-09 08:17:21 UTC (rev 93801)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/error.py 2008-12-09 10:12:28 UTC (rev 93802)
@@ -18,6 +18,7 @@
from zope import interface
from zope.app.pagetemplate import ViewPageTemplateFile
from z3ext.statusmessage.message import Message
+from z3c.form.interfaces import IErrorViewSnippet
class FormErrorStatusMessage(Message):
@@ -30,5 +31,6 @@
def render(self, message):
self.message = message[0]
- self.errors = [err for err in message[1:] if err.widget is None]
+ self.errors = [err for err in message[1:]
+ if IErrorViewSnippet.providedBy(err) and err.widget is None]
return self.index()
Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/form.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/form.py 2008-12-09 08:17:21 UTC (rev 93801)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/form.py 2008-12-09 10:12:28 UTC (rev 93802)
@@ -16,21 +16,40 @@
$Id$
"""
from zope import interface
+from zope.component import getAdapters
from zope.component import getMultiAdapter, queryMultiAdapter
from zope.pagetemplate.interfaces import IPageTemplate
from z3c.form import form
+from z3c.form.interfaces import IGroup
+
from z3ext.layout.interfaces import IPagelet
from z3ext.layout.pagelet import BrowserPagelet
-from interfaces import IPageletForm, IPageletDisplayForm, IPageletFormView
+from interfaces import IPageletForm, IPageletSubform
+from interfaces import IPageletDisplayForm, IPageletFormView
class PageletForm(form.Form, BrowserPagelet):
interface.implements(IPageletForm)
+ forms = ()
+
__call__ = BrowserPagelet.__call__
+ def extractData(self):
+ data, errors = super(PageletForm, self).extractData()
+ for form in self.forms:
+ if IGroup.providedBy(form):
+ formData, formErrors = form.extractData()
+ data.update(formData)
+ if formErrors:
+ if errors:
+ errors += formErrors
+ else:
+ errors = formErrors
+ return data, errors
+
def render(self):
# render content template
if self.template is None:
@@ -44,7 +63,23 @@
return self.template()
+ def updateForms(self):
+ forms = []
+ for name, form in getAdapters(
+ (self.context, self.request, self), IPageletSubform):
+ form.update()
+ forms.append((form.weight, name, form))
+ forms.sort()
+ self.forms = [form for weight, name, form in forms]
+
+ def update(self):
+ self.updateWidgets()
+ self.updateActions()
+ self.updateForms()
+ self.actions.execute()
+
+
class PageletDisplayForm(form.DisplayForm, PageletForm):
interface.implements(IPageletDisplayForm)
Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py 2008-12-09 08:17:21 UTC (rev 93801)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py 2008-12-09 10:12:28 UTC (rev 93802)
@@ -38,7 +38,9 @@
description = interface.Attribute('Form label')
+ forms = interface.Attribute('Ordered list of sub forms')
+
class IPageletAddForm(IPageletForm):
"""Add form mixin for pagelet implementation."""
@@ -69,6 +71,16 @@
""" Sub form mixin for pagelet implementation."""
+class IPageletSubform(IPageletForm):
+ """ Subform """
+
+ weight = schema.Int(
+ title = u'Weight',
+ description = u'Weight for order',
+ default = 9999,
+ required = False)
+
+
class IAddButton(IButton):
""" add button """
@@ -79,7 +91,3 @@
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-09 08:17:21 UTC (rev 93801)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/subform.py 2008-12-09 10:12:28 UTC (rev 93802)
@@ -33,8 +33,7 @@
render = PageletForm.render
__call__ = PageletForm.__call__
- @button.buttonAndHandler(
- _(u'Save'), name='save', provides=ISaveButton)
+ @button.buttonAndHandler(_(u'Save'), name='save', provides=ISaveButton)
def handleApply(self, action):
data, errors = self.extractData()
if errors:
More information about the Checkins
mailing list