[Checkins] SVN: z3ext.layoutform/tags/1.4.0/ release tag
Nikolay Kim
fafhrd91 at gmail.com
Fri May 22 07:48:13 EDT 2009
Log message for revision 100227:
release tag
Changed:
A z3ext.layoutform/tags/1.4.0/
D z3ext.layoutform/tags/1.4.0/CHANGES.txt
A z3ext.layoutform/tags/1.4.0/CHANGES.txt
U z3ext.layoutform/tags/1.4.0/setup.py
D z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/form.py
A z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/form.py
D z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/interfaces.py
A z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/interfaces.py
D z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/tests/form.txt
A z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/tests/form.txt
-=-
Deleted: z3ext.layoutform/tags/1.4.0/CHANGES.txt
===================================================================
--- z3ext.layoutform/trunk/CHANGES.txt 2009-05-22 00:40:23 UTC (rev 100223)
+++ z3ext.layoutform/tags/1.4.0/CHANGES.txt 2009-05-22 11:48:13 UTC (rev 100227)
@@ -1,172 +0,0 @@
-=======
-CHANGES
-=======
-
-
-- Convert 'forms','groups','subforms','views' to tuple
-
-
-1.3.5 (2009-04-15)
-------------------
-
-- Added 'formErrorMessage' to base class
-
-- Do not use z3c.autoinclude
-
-
-1.3.4 (2009-04-03)
-------------------
-
-- Added changed attributes descriptions to ObjectModifiedEvent for subform
-
-
-1.3.3 (2009-03-11)
-------------------
-
-- Added a patched sequence converters that don't raise a LookupError
- when dealing with values that are removed from the terms. This
- is fixed in z3c.form's 2.0.0, so it's only needed when using z3c.form
- 1.9.x and below. Include the ``converter.zcml`` file with the
- ``includeOverrides`` directive, if you need it.
-
-- Added applyChanges method to subform
-
-- Do not insert <form> html tag if form wrapped with other <form>
-
-
-1.3.2 (2009-01-22)
-------------------
-
-- Added missing security declarations
-
-
-1.3.1 (2008-12-25)
-------------------
-
-- Fixed subform initialization
-
-- Fixed IPagelet contract implementation
-
-
-1.3.0 (2008-12-22)
-------------------
-
-- Added subforms based on new z3ext.layout pagelet api
-
-- Fixed 'formError' status message
-
-- Use button.handler instead of buttonAndHandler
-
-- Use new pagelet api for rendering widgets
-
-
-1.2.8 (2008-11-21)
-------------------
-
-- Fixed 'formError' status message
-
-
-1.2.7 (2008-11-20)
-------------------
-
-- Use new z3ext.statusmessage api
-
-
-1.2.6 (2008-11-06)
-------------------
-
-- Use updated pagelet api for nameless pagelets
-
-
-1.2.5 (2008-10-22)
-------------------
-
-- Update translations
-
-
-1.2.4 (2008-10-20)
-------------------
-
-- Added support of display form
-
-- Added tranlsations: nl, ru
-
-
-1.2.3 (2008-10-14)
-------------------
-
-- Groups support restored
-
-- Use IPageletType for views
-
-
-1.2.2 (2008-10-08)
-------------------
-
-- Added extra views for form
-
-
-1.2.1 (2008-10-08)
-------------------
-
-- Show all form errors
-
-
-1.2.0 (2008-10-06)
-------------------
-
-- Added default css styles
-
-- Removed z3c packages dependencies
-
-- Use pagelets instead of macros
-
-
-1.1.2 (2008-09-26)
-------------------
-
-- Added group support
-
-- Return added object in createAndAdd method
-
-
-1.1.1 (2008-08-05)
-------------------
-
-- Fixed wrong `for` in label tag
-
-
-1.1.0 (2008-07-22)
-------------------
-
-- Remove cancel button from edit form
-
-
-1.0.1 (2008-06-02)
-------------------
-
-- Redirect to nextURL after success 'apply'
-
-
-1.0.0 (2008-05-13)
-------------------
-
-- Use `includeDependencies` instead `autoinclude`
-
-
-0.2.0 (2008-??-??)
-------------------
-
-- Use z3c.autoinclude
-
-
-0.1.1 (2008-01-22)
-------------------
-
-- Fixed missing import in add.py
-
-
-0.1 (2008-01-19)
-----------------
-
-- Initial release
Copied: z3ext.layoutform/tags/1.4.0/CHANGES.txt (from rev 100226, z3ext.layoutform/trunk/CHANGES.txt)
===================================================================
--- z3ext.layoutform/tags/1.4.0/CHANGES.txt (rev 0)
+++ z3ext.layoutform/tags/1.4.0/CHANGES.txt 2009-05-22 11:48:13 UTC (rev 100227)
@@ -0,0 +1,175 @@
+=======
+CHANGES
+=======
+
+
+1.4.0 (2009-05-22)
+------------------
+
+- Use SelectionManager for form subforms,groups,view
+
+
+1.3.5 (2009-04-15)
+------------------
+
+- Added 'formErrorMessage' to base class
+
+- Do not use z3c.autoinclude
+
+
+1.3.4 (2009-04-03)
+------------------
+
+- Added changed attributes descriptions to ObjectModifiedEvent for subform
+
+
+1.3.3 (2009-03-11)
+------------------
+
+- Added a patched sequence converters that don't raise a LookupError
+ when dealing with values that are removed from the terms. This
+ is fixed in z3c.form's 2.0.0, so it's only needed when using z3c.form
+ 1.9.x and below. Include the ``converter.zcml`` file with the
+ ``includeOverrides`` directive, if you need it.
+
+- Added applyChanges method to subform
+
+- Do not insert <form> html tag if form wrapped with other <form>
+
+
+1.3.2 (2009-01-22)
+------------------
+
+- Added missing security declarations
+
+
+1.3.1 (2008-12-25)
+------------------
+
+- Fixed subform initialization
+
+- Fixed IPagelet contract implementation
+
+
+1.3.0 (2008-12-22)
+------------------
+
+- Added subforms based on new z3ext.layout pagelet api
+
+- Fixed 'formError' status message
+
+- Use button.handler instead of buttonAndHandler
+
+- Use new pagelet api for rendering widgets
+
+
+1.2.8 (2008-11-21)
+------------------
+
+- Fixed 'formError' status message
+
+
+1.2.7 (2008-11-20)
+------------------
+
+- Use new z3ext.statusmessage api
+
+
+1.2.6 (2008-11-06)
+------------------
+
+- Use updated pagelet api for nameless pagelets
+
+
+1.2.5 (2008-10-22)
+------------------
+
+- Update translations
+
+
+1.2.4 (2008-10-20)
+------------------
+
+- Added support of display form
+
+- Added tranlsations: nl, ru
+
+
+1.2.3 (2008-10-14)
+------------------
+
+- Groups support restored
+
+- Use IPageletType for views
+
+
+1.2.2 (2008-10-08)
+------------------
+
+- Added extra views for form
+
+
+1.2.1 (2008-10-08)
+------------------
+
+- Show all form errors
+
+
+1.2.0 (2008-10-06)
+------------------
+
+- Added default css styles
+
+- Removed z3c packages dependencies
+
+- Use pagelets instead of macros
+
+
+1.1.2 (2008-09-26)
+------------------
+
+- Added group support
+
+- Return added object in createAndAdd method
+
+
+1.1.1 (2008-08-05)
+------------------
+
+- Fixed wrong `for` in label tag
+
+
+1.1.0 (2008-07-22)
+------------------
+
+- Remove cancel button from edit form
+
+
+1.0.1 (2008-06-02)
+------------------
+
+- Redirect to nextURL after success 'apply'
+
+
+1.0.0 (2008-05-13)
+------------------
+
+- Use `includeDependencies` instead `autoinclude`
+
+
+0.2.0 (2008-??-??)
+------------------
+
+- Use z3c.autoinclude
+
+
+0.1.1 (2008-01-22)
+------------------
+
+- Fixed missing import in add.py
+
+
+0.1 (2008-01-19)
+----------------
+
+- Initial release
Modified: z3ext.layoutform/tags/1.4.0/setup.py
===================================================================
--- z3ext.layoutform/trunk/setup.py 2009-05-22 00:40:23 UTC (rev 100223)
+++ z3ext.layoutform/tags/1.4.0/setup.py 2009-05-22 11:48:13 UTC (rev 100227)
@@ -21,7 +21,7 @@
def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
-version='1.3.6dev'
+version='1.4.0'
setup(name='z3ext.layoutform',
Deleted: z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/form.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/form.py 2009-05-22 00:40:23 UTC (rev 100223)
+++ z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/form.py 2009-05-22 11:48:13 UTC (rev 100227)
@@ -1,154 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 Zope Foundation 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.
-#
-##############################################################################
-"""Support for Layout Templates
-
-$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 IForm, IGroup, ISubForm
-
-from z3ext.layout.interfaces import IPagelet
-from z3ext.layout.pagelet import BrowserPagelet
-
-from interfaces import _
-from interfaces import IFormWrapper
-from interfaces import IPageletForm, IPageletSubform
-from interfaces import IPageletDisplayForm, IPageletFormView
-
-
-class PageletBaseForm(form.BaseForm, BrowserPagelet):
-
- __call__ = BrowserPagelet.__call__
-
- def render(self):
- if self.template is not None:
- return self.template()
- else:
- view = queryMultiAdapter((self, self.request), IPageletFormView)
- if view is not None:
- view.update()
- return view.render()
-
- raise LookupError("Can't find IPageletFormView view for this form.")
-
-
-class PageletForm(form.Form, PageletBaseForm):
- interface.implements(IPageletForm)
-
- label = u''
- description = u''
-
- forms = ()
- groups = ()
- subforms = ()
- views = ()
-
- render = PageletBaseForm.render
- __call__ = PageletBaseForm.__call__
-
- formErrorsMessage = _(u'Please fix indicated errors.')
-
- def extractData(self):
- data, errors = super(PageletForm, self).extractData()
- for form in self.groups:
- formData, formErrors = form.extractData()
- data.update(formData)
- if formErrors:
- errors += formErrors
-
- for form in self.subforms:
- formData, formErrors = form.extractData()
- if formErrors:
- errors += formErrors
-
- return data, errors
-
- def _loadSubforms(self):
- return [form for name, form in
- getAdapters((self.context, self, self.request), IPageletSubform)]
-
- def updateForms(self):
- wrapped = IFormWrapper.providedBy(self)
-
- forms = []
- groups = []
- subforms = []
- views = []
- for form in self._loadSubforms():
- form.update()
- if not form.isAvailable():
- continue
-
- if IGroup.providedBy(form):
- groups.append((form.weight, form.__name__, form))
- elif ISubForm.providedBy(form):
- subforms.append((form.weight, form.__name__, form))
- elif IPageletForm.providedBy(form):
- if wrapped:
- interface.alsoProvides(form, IFormWrapper)
- forms.append((form.weight, form.__name__, form))
- else:
- views.append((form.weight, form.__name__, form))
-
- groups.sort()
- self.groups = tuple([form for weight, name, form in groups])
-
- subforms.sort()
- self.subforms = tuple([form for weight, name, form in subforms])
-
- forms.sort()
- self.forms = tuple([form for weight, name, form in forms])
-
- views.sort()
- self.views = tuple([view for weight, name, view in views])
-
- def update(self):
- self.updateWidgets()
- self.updateActions()
- self.updateForms()
-
- if not IPageletSubform.providedBy(self):
- self.actions.execute()
-
- for form in self.groups:
- form.postUpdate()
- for form in self.subforms:
- form.postUpdate()
- for form in self.forms:
- form.postUpdate()
-
- def isAvailable(self):
- return True
-
- def postUpdate(self):
- for form in self.groups:
- form.postUpdate()
- for form in self.subforms:
- form.postUpdate()
- for form in self.forms:
- form.postUpdate()
-
- self.actions.execute()
-
-
-class PageletDisplayForm(PageletForm, form.DisplayForm):
- interface.implements(IPageletDisplayForm)
-
- render = PageletForm.render
- __call__ = PageletForm.__call__
Copied: z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/form.py (from rev 100226, z3ext.layoutform/trunk/src/z3ext/layoutform/form.py)
===================================================================
--- z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/form.py (rev 0)
+++ z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/form.py 2009-05-22 11:48:13 UTC (rev 100227)
@@ -0,0 +1,170 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation 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.
+#
+##############################################################################
+"""Support for Layout Templates
+
+$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, util
+from z3c.form.interfaces import IForm, IGroup, ISubForm
+
+from z3ext.layout.interfaces import IPagelet
+from z3ext.layout.pagelet import BrowserPagelet
+
+from interfaces import _
+from interfaces import IFormWrapper, IForms
+from interfaces import IPageletForm, IPageletSubform
+from interfaces import IPageletDisplayForm, IPageletFormView
+
+
+class Views(util.SelectionManager):
+ """Forms manager."""
+ interface.implements(IForms)
+ managerInterface = IForms
+
+ def __init__(self, *args, **kw):
+ super(Views, self).__init__()
+ for view in args:
+ self._data_values.append(view)
+ self._data_keys.append(view.__name__)
+ self._data[view.__name__] = view
+
+ def __iter__(self):
+ return iter(self._data_values)
+
+class PageletBaseForm(form.BaseForm, BrowserPagelet):
+
+ __call__ = BrowserPagelet.__call__
+
+ def render(self):
+ if self.template is not None:
+ return self.template()
+ else:
+ view = queryMultiAdapter((self, self.request), IPageletFormView)
+ if view is not None:
+ view.update()
+ return view.render()
+
+ raise LookupError("Can't find IPageletFormView view for this form.")
+
+
+class PageletForm(form.Form, PageletBaseForm):
+ interface.implements(IPageletForm)
+
+ label = u''
+ description = u''
+
+ forms = ()
+ groups = ()
+ subforms = ()
+ views = ()
+
+ render = PageletBaseForm.render
+ __call__ = PageletBaseForm.__call__
+
+ formErrorsMessage = _(u'Please fix indicated errors.')
+
+ def extractData(self):
+ data, errors = super(PageletForm, self).extractData()
+ for form in self.groups:
+ formData, formErrors = form.extractData()
+ data.update(formData)
+ if formErrors:
+ errors += formErrors
+
+ for form in self.subforms:
+ formData, formErrors = form.extractData()
+ if formErrors:
+ errors += formErrors
+
+ return data, errors
+
+ def _loadSubforms(self):
+ return [(name, form) for name, form in
+ getAdapters((self.context, self, self.request), IPageletSubform)]
+
+ def updateForms(self):
+ wrapped = IFormWrapper.providedBy(self)
+
+ forms = []
+ groups = []
+ subforms = []
+ views = []
+ for name, form in self._loadSubforms():
+ form.__name__ = name
+ form.update()
+ if not form.isAvailable():
+ continue
+
+ if IGroup.providedBy(form):
+ groups.append((form.weight, form.__name__, form))
+ elif ISubForm.providedBy(form):
+ subforms.append((form.weight, form.__name__, form))
+ elif IPageletForm.providedBy(form):
+ if wrapped:
+ interface.alsoProvides(form, IFormWrapper)
+ forms.append((form.weight, form.__name__, form))
+ else:
+ views.append((form.weight, form.__name__, form))
+
+ groups.sort()
+ self.groups = Views(*[form for weight, name, form in groups])
+
+ subforms.sort()
+ self.subforms = Views(*[form for weight, name, form in subforms])
+
+ forms.sort()
+ self.forms = Views(*[form for weight, name, form in forms])
+
+ views.sort()
+ self.views = Views(*[view for weight, name, view in views])
+
+ def update(self):
+ self.updateWidgets()
+ self.updateActions()
+ self.updateForms()
+
+ if not IPageletSubform.providedBy(self):
+ self.actions.execute()
+
+ for form in self.groups:
+ form.postUpdate()
+ for form in self.subforms:
+ form.postUpdate()
+ for form in self.forms:
+ form.postUpdate()
+
+ def isAvailable(self):
+ return True
+
+ def postUpdate(self):
+ for form in self.groups:
+ form.postUpdate()
+ for form in self.subforms:
+ form.postUpdate()
+ for form in self.forms:
+ form.postUpdate()
+
+ self.actions.execute()
+
+
+class PageletDisplayForm(PageletForm, form.DisplayForm):
+ interface.implements(IPageletDisplayForm)
+
+ render = PageletForm.render
+ __call__ = PageletForm.__call__
Deleted: z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/interfaces.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py 2009-05-22 00:40:23 UTC (rev 100223)
+++ z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/interfaces.py 2009-05-22 11:48:13 UTC (rev 100227)
@@ -1,129 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-""" z3ext.layoutform interfaces
-
-$Id$
-"""
-from zope import interface, schema
-from zope.i18nmessageid import MessageFactory
-from z3c.form.interfaces import IFormLayer
-from z3ext.layout.interfaces import IPagelet
-
-_ = MessageFactory('z3ext.layoutform')
-
-
-class IAddAction(interface.Interface):
- """ add action """
-
-
-class ISaveAction(interface.Interface):
- """ save action """
-
-
-class ICancelAction(interface.Interface):
- """ cancel action """
-
-
-class ILayoutFormLayer(IFormLayer):
- """ browser layer """
-
-
-class IPageletFormView(interface.Interface):
- """ pagelet form view """
-
-
-class IPageletBaseForm(IPagelet):
- """ Base interface for pagelet forms """
-
-
-class IPageletForm(IPageletBaseForm):
- """Form mixin for pagelet implementation."""
-
- label = interface.Attribute('Form label')
- description = interface.Attribute('Form label')
-
- forms = interface.Attribute('Ordered list of managed forms')
- groups = interface.Attribute('Ordered list of managed groups')
- subforms = interface.Attribute('Ordered list of managed subforms')
- views = interface.Attribute('Ordered list of managed views')
-
- formErrorsMessage = interface.Attribute('Error message')
-
- def updateForms():
- """Update pagelet subforms."""
-
-
-class IPageletAddForm(IPageletForm):
- """Add form mixin for pagelet implementation."""
-
- formCancelMessage = interface.Attribute('Form cancel message')
-
- def nextURL():
- """ as next url use newly created content url """
-
- def cancelURL():
- """ cancel url """
-
- def nameAllowed():
- """Return whether names can be input by the user."""
-
-
-class IPageletDisplayForm(IPageletBaseForm):
- """ Display form mixin """
-
-
-class IPageletEditForm(IPageletForm):
- """Edit form mixin for pagelet implementation."""
-
- def nextURL():
- """ as next url use newly created content url """
-
-
-class IPageletEditSubForm(IPageletBaseForm):
- """ Sub form mixin for pagelet implementation."""
-
- def executeActions(form):
- """Execute form actions."""
-
-
-class IPageletSubform(interface.Interface):
- """ Subform """
-
- weight = schema.Int(
- title = u'Weight',
- description = u'Weight for order',
- default = 9999,
- required = False)
-
- def isAvailable():
- """If subform available."""
-
- def postUpdate():
- """Update form after manager form updated."""
-
-
-class IAddButton(IAddAction):
- """ add button """
-
-
-class ISaveButton(ISaveAction):
- """ save button """
-
-
-class ICancelButton(ICancelAction):
- """ cancel button """
-
-
-class IFormWrapper(interface.Interface):
- """ """
Copied: z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/interfaces.py (from rev 100226, z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py)
===================================================================
--- z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/interfaces.py (rev 0)
+++ z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/interfaces.py 2009-05-22 11:48:13 UTC (rev 100227)
@@ -0,0 +1,132 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+""" z3ext.layoutform interfaces
+
+$Id$
+"""
+from zope import interface, schema
+from zope.i18nmessageid import MessageFactory
+from z3c.form.interfaces import IFormLayer, ISelectionManager
+from z3ext.layout.interfaces import IPagelet
+
+_ = MessageFactory('z3ext.layoutform')
+
+
+class IAddAction(interface.Interface):
+ """ add action """
+
+
+class ISaveAction(interface.Interface):
+ """ save action """
+
+
+class ICancelAction(interface.Interface):
+ """ cancel action """
+
+
+class ILayoutFormLayer(IFormLayer):
+ """ browser layer """
+
+
+class IPageletFormView(interface.Interface):
+ """ pagelet form view """
+
+
+class IPageletBaseForm(IPagelet):
+ """ Base interface for pagelet forms """
+
+
+class IPageletForm(IPageletBaseForm):
+ """Form mixin for pagelet implementation."""
+
+ label = interface.Attribute('Form label')
+ description = interface.Attribute('Form label')
+
+ forms = interface.Attribute('Ordered list of managed forms')
+ groups = interface.Attribute('Ordered list of managed groups')
+ subforms = interface.Attribute('Ordered list of managed subforms')
+ views = interface.Attribute('Ordered list of managed views')
+
+ formErrorsMessage = interface.Attribute('Error message')
+
+ def updateForms():
+ """Update pagelet subforms."""
+
+
+class IPageletAddForm(IPageletForm):
+ """Add form mixin for pagelet implementation."""
+
+ formCancelMessage = interface.Attribute('Form cancel message')
+
+ def nextURL():
+ """ as next url use newly created content url """
+
+ def cancelURL():
+ """ cancel url """
+
+ def nameAllowed():
+ """Return whether names can be input by the user."""
+
+
+class IPageletDisplayForm(IPageletBaseForm):
+ """ Display form mixin """
+
+
+class IPageletEditForm(IPageletForm):
+ """Edit form mixin for pagelet implementation."""
+
+ def nextURL():
+ """ as next url use newly created content url """
+
+
+class IPageletEditSubForm(IPageletBaseForm):
+ """ Sub form mixin for pagelet implementation."""
+
+ def executeActions(form):
+ """Execute form actions."""
+
+
+class IPageletSubform(interface.Interface):
+ """ Subform """
+
+ weight = schema.Int(
+ title = u'Weight',
+ description = u'Weight for order',
+ default = 9999,
+ required = False)
+
+ def isAvailable():
+ """If subform available."""
+
+ def postUpdate():
+ """Update form after manager form updated."""
+
+
+class IAddButton(IAddAction):
+ """ add button """
+
+
+class ISaveButton(ISaveAction):
+ """ save button """
+
+
+class ICancelButton(ICancelAction):
+ """ cancel button """
+
+
+class IFormWrapper(interface.Interface):
+ """ """
+
+class IForms(ISelectionManager):
+ """ Forms manager """
Deleted: z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/tests/form.txt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/tests/form.txt 2009-05-22 00:40:23 UTC (rev 100223)
+++ z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/tests/form.txt 2009-05-22 11:48:13 UTC (rev 100227)
@@ -1,298 +0,0 @@
-===========
-PageletForm
-===========
-
- >>> from zope import interface, component, schema
- >>> from zope.app.testing.functional import getRootFolder
- >>> root = getRootFolder()
- >>> sm = component.getSiteManager()
-
- >>> class IPerson(interface.Interface):
- ...
- ... name = schema.TextLine(
- ... title=u'Name',
- ... missing_value = u'',
- ... required=True)
- ...
- ... age = schema.Int(
- ... title=u'Age',
- ... description=u"The person's age.",
- ... min=0,
- ... default=20,
- ... required=False)
-
- >>> from z3c.form import group, button
- >>> from z3ext.layoutform import interfaces, subform
- >>> from z3ext.layoutform import Fields, PageletForm
-
- >>> class PersonForm(PageletForm):
- ...
- ... ignoreContext = True
- ... fields = Fields(IPerson)
- ...
- ... @button.buttonAndHandler(u'Save', name='save',
- ... provides=interfaces.ISaveAction)
- ... def handleSave(self, action):
- ... pass
-
-Let's create a request:
-
- >>> from z3c.form.testing import TestRequest
- >>> request = TestRequest()
-
-And support the layout form layer for our request:
-
- >>> from z3ext.layoutform.interfaces import ILayoutFormLayer
- >>> interface.alsoProvides(request, ILayoutFormLayer)
-
-Now create the form:
-
- >>> form = PersonForm(root, request)
-
-Let's now render the page. Note the output doesn't contain the layout template:
-
- >>> form.update()
- >>> print form.render()
- <div class="z-form z-form-standard"><form action="http://127.0.0.1" method="post"
- enctype="multipart/form-data" name="form" id="form">
- <div class="z-form-fieldset">
- <div class="z-form-field">
- <label for="form-widgets-name" title="">Name</label>
- <span class="z-form-fieldRequired"> </span>
- <div class="z-form-help"></div>
- <div><input type="text" id="form-widgets-name"
- name="form.widgets.name"
- class="text-widget required textline-field" value="" />
- </div>
- </div>
- <div class="z-form-field">
- <label for="form-widgets-age" title="The person's age.">Age</label>
- <div class="z-form-help">The person's age.</div>
- <div><input type="text" id="form-widgets-age"
- name="form.widgets.age" class="text-widget int-field"
- value="20" />
- </div>
- </div>
- </div>
- <div class="z-form-controls">
- <span>
- <hr />
- <input type="submit" id="form-buttons-save"
- name="form.buttons.save"
- class="z-form-savebutton button-field" value="Save" />
- </span>
- </div>
- </form>
- </div>
-
-Subforms
-
- >>> class IPersonEducation(interface.Interface):
- ...
- ... education = schema.TextLine(
- ... title = u'Education',
- ... default = u'',
- ... required = False)
-
-Group
-
-
- >>> class PersonEducation(group.Group):
- ... interface.implements(interfaces.IPageletSubform)
- ...
- ... weight = 10
- ... fields = Fields(IPersonEducation)
- ... ignoreContext = True
- ...
- ... def __init__(self, context, form, request):
- ... super(PersonEducation, self).__init__(context, request, form)
- ...
- ... def isAvailable(self):
- ... return True
- ...
- ... def postUpdate(self):
- ... pass
-
- >>> form.groups
- ()
-
- >>> component.getSiteManager().registerAdapter(
- ... PersonEducation, (interface.Interface, PersonForm, interface.Interface),
- ... interfaces.IPageletSubform, name='edu')
-
- >>> form.update()
-
- >>> print form.groups
- (<PersonEducation ...>,)
-
- >>> print form.render()
- <div class="z-form z-form-standard"><form action="http://127.0.0.1" method="post"
- enctype="multipart/form-data" name="form" id="form">
- <div class="z-form-fieldset">
- <div class="z-form-field">
- <label for="form-widgets-name" title="">Name</label>
- <span class="z-form-fieldRequired"> </span>
- <div class="z-form-help"></div>
- <div><input type="text" id="form-widgets-name"
- name="form.widgets.name"
- class="text-widget required textline-field" value="" />
- </div>
- </div>
- <div class="z-form-field">
- <label for="form-widgets-age" title="The person's age.">Age</label>
- <div class="z-form-help">The person's age.</div>
- <div><input type="text" id="form-widgets-age"
- name="form.widgets.age" class="text-widget int-field"
- value="20" />
- </div>
- </div>
- </div>
- <div class="z-form-group">
- <div class="z-form-fieldset">
- <div class="z-form-field">
- <label for="form-widgets-education" title="">Education</label>
- <div class="z-form-help"></div>
- <div><input type="text" id="form-widgets-education"
- name="form.widgets.education"
- class="text-widget textline-field" value="" />
- </div>
- </div>
- </div>
- </div>
- <div class="z-form-controls">
- <span>
- <hr />
- <input type="submit" id="form-buttons-save"
- name="form.buttons.save"
- class="z-form-savebutton button-field" value="Save" />
- </span>
- </div>
- </form>
- </div>
-
-Subform
-
- >>> class IPersonInfo(interface.Interface):
- ...
- ... info = schema.Text(
- ... title=u'Information',
- ... default = u'',
- ... required=False)
-
- >>> class PersonInfo(subform.PageletEditSubForm):
- ... interface.implements(interfaces.IPageletSubform)
- ...
- ... weight = 10
- ... fields = Fields(IPersonInfo)
- ... ignoreContext = True
- ...
- ... def getContent(self):
- ... return {}
-
- >>> form.subforms
- ()
-
- >>> component.getSiteManager().registerAdapter(
- ... PersonInfo, (interface.Interface, PersonForm, interface.Interface),
- ... interfaces.IPageletSubform, name='info')
-
- >>> form.update()
-
- >>> print form.subforms
- (<PersonInfo ...>,)
-
- >>> print form.render()
- <div class="z-form z-form-standard">...
- ...
- <label for="form-widgets-info" title="">Information</label>
- <div class="z-form-help"></div>
- <div><textarea id="form-widgets-info" name="form.widgets.info"
- class="textarea-widget text-field" rows="5"></textarea>
- </div>
- ...
- </div>
-
- >>> request = TestRequest(
- ... form={'form.widgets.name': u'',
- ... 'form.widgets.age': u'50',
- ... 'form.widgets.education': 'University',
- ... 'form.widgets.info': 'info',
- ... 'form.buttons.save': u'Save'})
- >>> interface.alsoProvides(request, ILayoutFormLayer)
-
- >>> form = PersonForm(root, request)
- >>> form.update()
- >>> form.extractData()
- ({'age': 50}, (<ErrorViewSnippet for RequiredMissing>, <ErrorViewSnippet for WrongType>, <ErrorViewSnippet for WrongType>))
-
- >>> request = TestRequest(
- ... form={'form.widgets.name': u'',
- ... 'form.widgets.age': u'50',
- ... 'form.widgets.education': u'University',
- ... 'form.widgets.info': u'info',
- ... 'form.buttons.save': u'Save'})
- >>> interface.alsoProvides(request, ILayoutFormLayer)
-
- >>> form = PersonForm(root, request)
- >>> form.update()
- >>> data = form.extractData()
- >>> print form.render()
- <div class="z-form z-form-standard">...
- ...
- <div class="z-form-field error">
- <label for="form-widgets-name" title="">Name</label>
- <span class="z-form-fieldRequired"> </span>
- <div class="error">Required input is missing.</div>
- <div class="z-form-help"></div>
- <div><input type="text" id="form-widgets-name"
- name="form.widgets.name"
- class="text-widget required textline-field" value="" />
- </div>
- </div>
- ...
- </div>
-
- >>> request = TestRequest(
- ... form={'form.widgets.name': u'Nikolay',
- ... 'form.widgets.age': u'50',
- ... 'form.widgets.education': u'University',
- ... 'form.widgets.info': u'info',
- ... 'form.buttons.save': u'Save'})
- >>> interface.alsoProvides(request, ILayoutFormLayer)
- >>> form = PersonForm(root, request)
- >>> form.update()
- >>> form.extractData()
- ({'age': 50, 'education': u'University', 'name': u'Nikolay'}, ())
-
-
- >>> class IItem(interface.Interface):
- ...
- ... title = schema.TextLine(
- ... title = u'Title',
- ... required = True)
-
-
- >>> class ItemForm(PageletForm):
- ... prefix = 'title.'
- ... fields = Fields(IItem)
- ... ignoreContext = True
- ... weight = 0
-
- >>> component.getSiteManager().registerAdapter(
- ... ItemForm, (interface.Interface, PersonForm, interface.Interface),
- ... interfaces.IPageletSubform, name='item')
-
- >>> request = TestRequest(
- ... form={'form.widgets.name': u'Nikolay',
- ... 'form.widgets.age': u'50',
- ... 'form.widgets.education': u'University',
- ... 'form.widgets.info': u'info',
- ... 'form.buttons.save': u'Save'})
- >>> interface.alsoProvides(request, ILayoutFormLayer)
-
- >>> form = PersonForm(root, request)
- >>> form.update()
-
- >>> form.forms
- (<ItemForm object ...>,)
-
Copied: z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/tests/form.txt (from rev 100226, z3ext.layoutform/trunk/src/z3ext/layoutform/tests/form.txt)
===================================================================
--- z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/tests/form.txt (rev 0)
+++ z3ext.layoutform/tags/1.4.0/src/z3ext/layoutform/tests/form.txt 2009-05-22 11:48:13 UTC (rev 100227)
@@ -0,0 +1,302 @@
+===========
+PageletForm
+===========
+
+ >>> from zope import interface, component, schema
+ >>> from zope.app.testing.functional import getRootFolder
+ >>> root = getRootFolder()
+ >>> sm = component.getSiteManager()
+
+ >>> class IPerson(interface.Interface):
+ ...
+ ... name = schema.TextLine(
+ ... title=u'Name',
+ ... missing_value = u'',
+ ... required=True)
+ ...
+ ... age = schema.Int(
+ ... title=u'Age',
+ ... description=u"The person's age.",
+ ... min=0,
+ ... default=20,
+ ... required=False)
+
+ >>> from z3c.form import group, button
+ >>> from z3ext.layoutform import interfaces, subform
+ >>> from z3ext.layoutform import Fields, PageletForm
+
+ >>> class PersonForm(PageletForm):
+ ...
+ ... ignoreContext = True
+ ... fields = Fields(IPerson)
+ ...
+ ... @button.buttonAndHandler(u'Save', name='save',
+ ... provides=interfaces.ISaveAction)
+ ... def handleSave(self, action):
+ ... pass
+
+Let's create a request:
+
+ >>> from z3c.form.testing import TestRequest
+ >>> request = TestRequest()
+
+And support the layout form layer for our request:
+
+ >>> from z3ext.layoutform.interfaces import ILayoutFormLayer
+ >>> interface.alsoProvides(request, ILayoutFormLayer)
+
+Now create the form:
+
+ >>> form = PersonForm(root, request)
+
+Let's now render the page. Note the output doesn't contain the layout template:
+
+ >>> form.update()
+ >>> print form.render()
+ <div class="z-form z-form-standard"><form action="http://127.0.0.1" method="post"
+ enctype="multipart/form-data" name="form" id="form">
+ <div class="z-form-fieldset">
+ <div class="z-form-field">
+ <label for="form-widgets-name" title="">Name</label>
+ <span class="z-form-fieldRequired"> </span>
+ <div class="z-form-help"></div>
+ <div><input type="text" id="form-widgets-name"
+ name="form.widgets.name"
+ class="text-widget required textline-field" value="" />
+ </div>
+ </div>
+ <div class="z-form-field">
+ <label for="form-widgets-age" title="The person's age.">Age</label>
+ <div class="z-form-help">The person's age.</div>
+ <div><input type="text" id="form-widgets-age"
+ name="form.widgets.age" class="text-widget int-field"
+ value="20" />
+ </div>
+ </div>
+ </div>
+ <div class="z-form-controls">
+ <span>
+ <hr />
+ <input type="submit" id="form-buttons-save"
+ name="form.buttons.save"
+ class="z-form-savebutton button-field" value="Save" />
+ </span>
+ </div>
+ </form>
+ </div>
+
+Subforms
+
+ >>> class IPersonEducation(interface.Interface):
+ ...
+ ... education = schema.TextLine(
+ ... title = u'Education',
+ ... default = u'',
+ ... required = False)
+
+Group
+
+
+ >>> class PersonEducation(group.Group):
+ ... interface.implements(interfaces.IPageletSubform)
+ ...
+ ... weight = 10
+ ... fields = Fields(IPersonEducation)
+ ... ignoreContext = True
+ ...
+ ... def __init__(self, context, form, request):
+ ... super(PersonEducation, self).__init__(context, request, form)
+ ...
+ ... def isAvailable(self):
+ ... return True
+ ...
+ ... def postUpdate(self):
+ ... pass
+
+ >>> tuple(form.groups)
+ ()
+
+ >>> component.getSiteManager().registerAdapter(
+ ... PersonEducation, (interface.Interface, PersonForm, interface.Interface),
+ ... interfaces.IPageletSubform, name='edu')
+
+ >>> form.update()
+
+ >>> print tuple(form.groups)
+ (<PersonEducation ...>,)
+
+ >>> print form.render()
+ <div class="z-form z-form-standard"><form action="http://127.0.0.1" method="post"
+ enctype="multipart/form-data" name="form" id="form">
+ <div class="z-form-fieldset">
+ <div class="z-form-field">
+ <label for="form-widgets-name" title="">Name</label>
+ <span class="z-form-fieldRequired"> </span>
+ <div class="z-form-help"></div>
+ <div><input type="text" id="form-widgets-name"
+ name="form.widgets.name"
+ class="text-widget required textline-field" value="" />
+ </div>
+ </div>
+ <div class="z-form-field">
+ <label for="form-widgets-age" title="The person's age.">Age</label>
+ <div class="z-form-help">The person's age.</div>
+ <div><input type="text" id="form-widgets-age"
+ name="form.widgets.age" class="text-widget int-field"
+ value="20" />
+ </div>
+ </div>
+ </div>
+ <div class="z-form-group">
+ <div class="z-form-fieldset">
+ <div class="z-form-field">
+ <label for="form-widgets-education" title="">Education</label>
+ <div class="z-form-help"></div>
+ <div><input type="text" id="form-widgets-education"
+ name="form.widgets.education"
+ class="text-widget textline-field" value="" />
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="z-form-controls">
+ <span>
+ <hr />
+ <input type="submit" id="form-buttons-save"
+ name="form.buttons.save"
+ class="z-form-savebutton button-field" value="Save" />
+ </span>
+ </div>
+ </form>
+ </div>
+
+Subform
+
+ >>> class IPersonInfo(interface.Interface):
+ ...
+ ... info = schema.Text(
+ ... title=u'Information',
+ ... default = u'',
+ ... required=False)
+
+ >>> class PersonInfo(subform.PageletEditSubForm):
+ ... interface.implements(interfaces.IPageletSubform)
+ ...
+ ... weight = 10
+ ... fields = Fields(IPersonInfo)
+ ... ignoreContext = True
+ ...
+ ... def getContent(self):
+ ... return {}
+
+ >>> tuple(form.subforms)
+ ()
+
+ >>> component.getSiteManager().registerAdapter(
+ ... PersonInfo, (interface.Interface, PersonForm, interface.Interface),
+ ... interfaces.IPageletSubform, name='info')
+
+ >>> form.update()
+
+ >>> print tuple(form.subforms)
+ (<PersonInfo ...>,)
+
+ >>> print form.render()
+ <div class="z-form z-form-standard">...
+ ...
+ <label for="form-widgets-info" title="">Information</label>
+ <div class="z-form-help"></div>
+ <div><textarea id="form-widgets-info" name="form.widgets.info"
+ class="textarea-widget text-field" rows="5"></textarea>
+ </div>
+ ...
+ </div>
+
+ >>> request = TestRequest(
+ ... form={'form.widgets.name': u'',
+ ... 'form.widgets.age': u'50',
+ ... 'form.widgets.education': 'University',
+ ... 'form.widgets.info': 'info',
+ ... 'form.buttons.save': u'Save'})
+ >>> interface.alsoProvides(request, ILayoutFormLayer)
+
+ >>> form = PersonForm(root, request)
+ >>> form.update()
+ >>> form.extractData()
+ ({'age': 50}, (<ErrorViewSnippet for RequiredMissing>, <ErrorViewSnippet for WrongType>, <ErrorViewSnippet for WrongType>))
+
+ >>> request = TestRequest(
+ ... form={'form.widgets.name': u'',
+ ... 'form.widgets.age': u'50',
+ ... 'form.widgets.education': u'University',
+ ... 'form.widgets.info': u'info',
+ ... 'form.buttons.save': u'Save'})
+ >>> interface.alsoProvides(request, ILayoutFormLayer)
+
+ >>> form = PersonForm(root, request)
+ >>> form.update()
+ >>> data = form.extractData()
+ >>> print form.render()
+ <div class="z-form z-form-standard">...
+ ...
+ <div class="z-form-field error">
+ <label for="form-widgets-name" title="">Name</label>
+ <span class="z-form-fieldRequired"> </span>
+ <div class="error">Required input is missing.</div>
+ <div class="z-form-help"></div>
+ <div><input type="text" id="form-widgets-name"
+ name="form.widgets.name"
+ class="text-widget required textline-field" value="" />
+ </div>
+ </div>
+ ...
+ </div>
+
+ >>> request = TestRequest(
+ ... form={'form.widgets.name': u'Nikolay',
+ ... 'form.widgets.age': u'50',
+ ... 'form.widgets.education': u'University',
+ ... 'form.widgets.info': u'info',
+ ... 'form.buttons.save': u'Save'})
+ >>> interface.alsoProvides(request, ILayoutFormLayer)
+ >>> form = PersonForm(root, request)
+ >>> form.update()
+ >>> form.extractData()
+ ({'age': 50, 'education': u'University', 'name': u'Nikolay'}, ())
+
+
+ >>> class IItem(interface.Interface):
+ ...
+ ... title = schema.TextLine(
+ ... title = u'Title',
+ ... required = True)
+
+
+ >>> class ItemForm(PageletForm):
+ ... prefix = 'title.'
+ ... fields = Fields(IItem)
+ ... ignoreContext = True
+ ... weight = 0
+
+ >>> component.getSiteManager().registerAdapter(
+ ... ItemForm, (interface.Interface, PersonForm, interface.Interface),
+ ... interfaces.IPageletSubform, name='item')
+
+ >>> request = TestRequest(
+ ... form={'form.widgets.name': u'Nikolay',
+ ... 'form.widgets.age': u'50',
+ ... 'form.widgets.education': u'University',
+ ... 'form.widgets.info': u'info',
+ ... 'form.buttons.save': u'Save'})
+ >>> interface.alsoProvides(request, ILayoutFormLayer)
+
+ >>> form = PersonForm(root, request)
+ >>> form.update()
+
+ >>> tuple(form.forms)
+ (<ItemForm object ...>,)
+
+We can get forms, subforms, groups by name
+
+ >>> form.forms['item']
+ <ItemForm object ...>
More information about the Checkins
mailing list