[Zope-Checkins] SVN: Zope/trunk/ Moved zope.formlib / zope.app.form integration into a separate package called five.formlib.

Hanno Schlichting hannosch at hannosch.eu
Sat Dec 26 18:10:43 EST 2009


Log message for revision 107134:
  Moved zope.formlib / zope.app.form integration into a separate package called five.formlib.
  

Changed:
  U   Zope/trunk/ZOPE_APP_DEPENDENCIES.rst
  U   Zope/trunk/buildout.cfg
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/setup.py
  U   Zope/trunk/src/Products/Five/TODO.txt
  U   Zope/trunk/src/Products/Five/browser/tests/pages.txt
  U   Zope/trunk/src/Products/Five/browser/tests/pages.zcml
  U   Zope/trunk/src/Products/Five/browser/tests/pages_ftest.txt
  D   Zope/trunk/src/Products/Five/doc/formlib.txt
  U   Zope/trunk/src/Products/Five/form/__init__.py
  D   Zope/trunk/src/Products/Five/form/add.pt
  U   Zope/trunk/src/Products/Five/form/configure.zcml
  D   Zope/trunk/src/Products/Five/form/edit.pt
  U   Zope/trunk/src/Products/Five/form/macros.py
  U   Zope/trunk/src/Products/Five/form/meta.zcml
  U   Zope/trunk/src/Products/Five/form/metaconfigure.py
  D   Zope/trunk/src/Products/Five/form/objectwidget.pt
  U   Zope/trunk/src/Products/Five/form/objectwidget.py
  D   Zope/trunk/src/Products/Five/form/tests/
  U   Zope/trunk/src/Products/Five/formlib/__init__.py
  U   Zope/trunk/src/Products/Five/formlib/configure.zcml
  U   Zope/trunk/src/Products/Five/formlib/formbase.py
  D   Zope/trunk/src/Products/Five/formlib/tests/

-=-
Modified: Zope/trunk/ZOPE_APP_DEPENDENCIES.rst
===================================================================
--- Zope/trunk/ZOPE_APP_DEPENDENCIES.rst	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/ZOPE_APP_DEPENDENCIES.rst	2009-12-26 23:10:42 UTC (rev 107134)
@@ -15,8 +15,8 @@
       * Products.Five.browser.metaconfigure
       * Products/Five/browser/doc/products/ViewsTutorial/configure.zcml
 
-- [_] zope.app.form
-      o Products.Five.form.* (should be factored out into a separate
+- [X] zope.app.form
+      x Products.Five.form.* (should be factored out into a separate
         package, maybe ``five.formlib``)
 
 - [X] zope.app.pagetemplate 

Modified: Zope/trunk/buildout.cfg
===================================================================
--- Zope/trunk/buildout.cfg	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/buildout.cfg	2009-12-26 23:10:42 UTC (rev 107134)
@@ -45,6 +45,7 @@
     ExtensionClass
     Persistence
     RestrictedPython
+    five.formlib
     tempstorage
     zope.browser
     zope.browsermenu
@@ -58,7 +59,6 @@
     zope.deferredimport
     zope.event
     zope.exceptions
-    zope.formlib [test]
     zope.i18n [compile]
     zope.i18nmessageid
     zope.interface

Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/doc/CHANGES.rst	2009-12-26 23:10:42 UTC (rev 107134)
@@ -11,6 +11,9 @@
 Restructuring
 +++++++++++++
 
+- Moved zope.formlib / zope.app.form integration into a separate package
+  called five.formlib.
+
 - We no longer depend on the ``zope-functional-testing`` extra of
   zope.testbrowser.
 

Modified: Zope/trunk/setup.py
===================================================================
--- Zope/trunk/setup.py	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/setup.py	2009-12-26 23:10:42 UTC (rev 107134)
@@ -94,6 +94,7 @@
       'ZConfig',
       'ZODB3',
       'docutils',
+      'five.formlib',
       'pytz',
       'setuptools',
       'tempstorage',
@@ -111,7 +112,6 @@
       'zope.deferredimport',
       'zope.event',
       'zope.exceptions',
-      'zope.formlib',
       'zope.i18n [zcml]',
       'zope.i18nmessageid',
       'zope.interface',
@@ -135,7 +135,6 @@
       'zope.testing',
       'zope.traversing',
       'zope.viewlet',
-      'zope.app.form',
     ],
 
     include_package_data=True,

Modified: Zope/trunk/src/Products/Five/TODO.txt
===================================================================
--- Zope/trunk/src/Products/Five/TODO.txt	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/TODO.txt	2009-12-26 23:10:42 UTC (rev 107134)
@@ -32,8 +32,6 @@
 v1.4
 ----
 
-- namedtemplate in Five.formlib?
-
 - l10n (philikon)
 
 - Figure out where add-view redirects should go.

Modified: Zope/trunk/src/Products/Five/browser/tests/pages.txt
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/pages.txt	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/browser/tests/pages.txt	2009-12-26 23:10:42 UTC (rev 107134)
@@ -258,7 +258,7 @@
 
   >>> protected_view_names = [
   ...     'eagle.txt', 'falcon.html', 'owl.html', 'flamingo.html',
-  ...     'condor.html', 'protectededitform.html']
+  ...     'condor.html']
   >>> 
   >>> public_view_names = [
   ...     'public_attribute_page',

Modified: Zope/trunk/src/Products/Five/browser/tests/pages.zcml
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/pages.zcml	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/browser/tests/pages.zcml	2009-12-26 23:10:42 UTC (rev 107134)
@@ -232,16 +232,7 @@
       class=".pages.SimpleView"
       permission="zope2.Public"
       />
-      
-  <!-- XXX this should really be in Five.form.tests -->
 
-  <!-- protected edit form for permission check -->
-  <browser:editform
-      schema="Products.Five.tests.testing.simplecontent.ISimpleContent"
-      name="protectededitform.html"
-      permission="zope2.ViewManagementScreens"
-      />
-
   <!-- stuff that we'll override in overrides.zcml -->
   <browser:page
       for="Products.Five.tests.testing.simplecontent.ISimpleContent"

Modified: Zope/trunk/src/Products/Five/browser/tests/pages_ftest.txt
===================================================================
--- Zope/trunk/src/Products/Five/browser/tests/pages_ftest.txt	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/browser/tests/pages_ftest.txt	2009-12-26 23:10:42 UTC (rev 107134)
@@ -60,7 +60,7 @@
 
   >>> protected_view_names = [
   ...     'eagle.txt', 'falcon.html', 'owl.html', 'flamingo.html',
-  ...     'condor.html', 'protectededitform.html']
+  ...     'condor.html']
   >>> 
   >>> public_view_names = [
   ...     'public_attribute_page',

Deleted: Zope/trunk/src/Products/Five/doc/formlib.txt
===================================================================
--- Zope/trunk/src/Products/Five/doc/formlib.txt	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/doc/formlib.txt	2009-12-26 23:10:42 UTC (rev 107134)
@@ -1,18 +0,0 @@
-============================
-zope.formlib support in Five
-============================
-
-Five supports zope.formlib, an alternative for constructing add, edit, and
-other forms based on schema. See zope/formlib/form.txt for a thorough
-description of the functionality provided by formlib.
-
-Formlib forms are normal view classes, registered as browser pages. Where
-in a pure Zope-3 context you would derive from one of the zope.formlib.form
-baseclasses, you now need to derive from one of the baseclasses provided by
-Products.Five.formlib.formbase.
-
-In almost all cases you need to import from zope.formlib.from as well -
-e.g. Fields and Actions in order to define and select fields and to add
-actions to your form.
-
-See Products.Five.formlib.tests for a minimal example.

Modified: Zope/trunk/src/Products/Five/form/__init__.py
===================================================================
--- Zope/trunk/src/Products/Five/form/__init__.py	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/form/__init__.py	2009-12-26 23:10:42 UTC (rev 107134)
@@ -1,231 +1,3 @@
-##############################################################################
-#
-# Copyright (c) 2004, 2005 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.
-#
-##############################################################################
-"""Add and edit views
-
-$Id$
-"""
-import sys
-from datetime import datetime
-
-import transaction
-from zope.event import notify
-from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
-from zope.lifecycleevent import Attributes
-from zope.location.interfaces import ILocation
-from zope.location import LocationProxy
-from zope.schema.interfaces import ValidationError
-from zope.i18nmessageid import MessageFactory
-_ = MessageFactory('zope')
-
-from zope.app.form.browser.submit import Update
-from zope.app.form.interfaces import IInputWidget
-from zope.app.form.interfaces import WidgetsError
-from zope.app.form.utility import setUpEditWidgets, applyWidgetsChanges
-from zope.app.form.utility import setUpWidgets, getWidgetsData
-
-from Products.Five.browser import BrowserView
-from Products.Five.browser.decode import processInputs, setPageEncoding
-from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
-
-class EditView(BrowserView):
-    """Simple edit-view base class
-
-    Subclasses should provide a schema attribute defining the schema
-    to be edited.
-    """
-
-    errors = ()
-    update_status = None
-    label = ''
-    charsets = None
-
-    # Fall-back field names computes from schema
-    fieldNames = property(lambda self: getFieldNamesInOrder(self.schema))
-    # Fall-back template
-    generated_form = ZopeTwoPageTemplateFile('edit.pt')
-
-    def __init__(self, context, request):
-        BrowserView.__init__(self, context, request)
-        processInputs(self.request, self.charsets)
-        setPageEncoding(self.request)
-        self._setUpWidgets()
-
-    def _setUpWidgets(self):
-        adapted = self.schema(self.context)
-        if adapted is not self.context:
-            if not ILocation.providedBy(adapted):
-                adapted = LocationProxy(adapted)
-            adapted.__parent__ = self.context
-        self.adapted = adapted
-        setUpEditWidgets(self, self.schema, source=self.adapted,
-                         names=self.fieldNames)
-
-    def setPrefix(self, prefix):
-        for widget in self.widgets():
-            widget.setPrefix(prefix)
-
-    def widgets(self):
-        return [getattr(self, name+'_widget')
-                for name in self.fieldNames]
-
-    def changed(self):
-        # This method is overridden to execute logic *after* changes
-        # have been made.
-        pass
-
-    def update(self):
-        if self.update_status is not None:
-            # We've been called before. Just return the status we previously
-            # computed.
-            return self.update_status
-
-        status = ''
-
-        content = self.adapted
-
-        if Update in self.request.form.keys():
-            changed = False
-            try:
-                changed = applyWidgetsChanges(self, self.schema,
-                    target=content, names=self.fieldNames)
-                # We should not generate events when an adapter is used.
-                # That's the adapter's job.  We need to unwrap the objects to
-                # compare them, as they are wrapped differently.
-                # Additionally, we can't use Acquisition.aq_base() because
-                # it strangely returns different objects for these two even
-                # when they are identical.  In particular
-                # aq_base(self.adapted) != self.adapted.aq_base :-(
-                if changed and getattr(self.context, 'aq_base', self.context)\
-                            is getattr(self.adapted, 'aq_base', self.adapted):
-                    description = Attributes(self.schema, *self.fieldNames)
-                    notify(ObjectModifiedEvent(content, description))
-            except WidgetsError, errors:
-                self.errors = errors
-                status = _("An error occurred.")
-                transaction.abort()
-            else:
-                setUpEditWidgets(self, self.schema, source=self.adapted,
-                                 ignoreStickyValues=True,
-                                 names=self.fieldNames)
-                if changed:
-                    self.changed()
-                    formatter = self.request.locale.dates.getFormatter(
-                       'dateTime', 'medium')
-                    status = _("Updated on ${date_time}",
-                              mapping={'date_time':
-                                       formatter.format(datetime.utcnow())})
-
-        self.update_status = status
-        return status
-
-class AddView(EditView):
-    """Simple edit-view base class.
-
-    Subclasses should provide a schema attribute defining the schema
-    to be edited.
-    """
-
-    def _setUpWidgets(self):
-        setUpWidgets(self, self.schema, IInputWidget, names=self.fieldNames)
-
-    def update(self):
-        if self.update_status is not None:
-            # We've been called before. Just return the previous result.
-            return self.update_status
-
-        if self.request.form.has_key(Update):
-
-            self.update_status = ''
-            try:
-                data = getWidgetsData(self, self.schema, names=self.fieldNames)
-                self.createAndAdd(data)
-            except WidgetsError, errors:
-                self.errors = errors
-                self.update_status = _("An error occurred.")
-                return self.update_status
-
-            self.request.response.redirect(self.nextURL())
-
-        return self.update_status
-
-    def create(self, *args, **kw):
-        """Do the actual instantiation."""
-        # hack to please typical Zope 2 factories, which expect id and title
-        # Any sane schema will use a unicode title, and may fail on a
-        # non-unicode one.
-        args = ('tmp_id', u'Temporary title') + args
-        return self._factory(*args, **kw)
-
-    def createAndAdd(self, data):
-        """Add the desired object using the data in the data argument.
-
-        The data argument is a dictionary with the data entered in the form.
-        """
-
-        args = []
-        if self._arguments:
-            for name in self._arguments:
-                args.append(data[name])
-
-        kw = {}
-        if self._keyword_arguments:
-            for name in self._keyword_arguments:
-                if name in data:
-                    kw[str(name)] = data[name]
-
-        content = self.create(*args, **kw)
-        adapted = self.schema(content)
-
-        errors = []
-
-        if self._set_before_add:
-            for name in self._set_before_add:
-                if name in data:
-                    field = self.schema[name]
-                    try:
-                        field.set(adapted, data[name])
-                    except ValidationError:
-                        errors.append(sys.exc_info()[1])
-
-        if errors:
-            raise WidgetsError(*errors)
-
-        notify(ObjectCreatedEvent(content))
-
-        content = self.add(content)
-        adapted = self.schema(content)
-
-        if self._set_after_add:
-            for name in self._set_after_add:
-                if name in data:
-                    field = self.schema[name]
-                    try:
-                        field.set(adapted, data[name])
-                    except ValidationError:
-                        errors.append(sys.exc_info()[1])
-            # We have modified the object, so we need to publish an
-            # object-modified event:
-            description = Attributes(self.schema, *self._set_after_add)
-            notify(ObjectModifiedEvent(content, description))
-
-        if errors:
-            raise WidgetsError(*errors)
-
-        return content
-
-    def add(self, content):
-        return self.context.add(content)
-
-    def nextURL(self):
-        return self.context.nextURL()
+# BBB
+from five.formlib import AddView
+from five.formlib import EditView

Deleted: Zope/trunk/src/Products/Five/form/add.pt
===================================================================
--- Zope/trunk/src/Products/Five/form/add.pt	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/form/add.pt	2009-12-26 23:10:42 UTC (rev 107134)
@@ -1,74 +0,0 @@
-<html metal:use-macro="context/@@standard_macros/page"
-    i18n:domain="zope">
-  <body>
-  <div metal:fill-slot="body">
-
-  <div metal:define-macro="addform">
-
-    <form action="." tal:attributes="action request/URL" method="post"
-          enctype="multipart/form-data">
-
-      <div metal:define-macro="formbody">
-
-        <h3 tal:condition="view/label"
-            tal:content="view/label"
-            metal:define-slot="heading"
-            >Add something</h3>
-
-        <p tal:define="status view/update"
-           tal:condition="status"
-           tal:content="status" />
-
-        <p tal:condition="view/errors" i18n:translate="">
-          There are <strong tal:content="python:len(view.errors)"
-                            i18n:name="num_errors">6</strong> input errors.
-        </p>
-
-        <div metal:define-slot="extra_info" tal:replace="nothing">
-        </div>
-
-        <div class="row" metal:define-slot="extra_top" tal:replace="nothing">
-            <div class="label">Extra top</div>
-            <div class="label"><input type="text" style="width:100%" /></div>
-        </div>
-
-        <div metal:use-macro="context/@@form_macros/widget_rows" />
-
-        <div class="separator"></div>
-
-        <div class="row"
-            metal:define-slot="extra_bottom" tal:replace="nothing">
-          <div class="label">Extra bottom</div>
-          <div class="field"><input type="text" style="width:100%" /></div>
-        </div>
-
-        <div class="separator"></div>
-
-      </div>
-      <br/><br/>
-      <div class="row">
-        <div class="controls"><hr />
-          <input type='submit' value='Refresh'
-                 i18n:attributes='value refresh-button' />
-          <input type='submit' value='Add' name='UPDATE_SUBMIT'
-                 i18n:attributes='value add-button' />
-          <span tal:condition="context/nameAllowed|nothing" tal:omit-tag="">
-               &nbsp;&nbsp;<b i18n:translate="">Object Name</b>&nbsp;&nbsp;
-              <input type='text' name='add_input_name'
-                     tal:attributes="value context/contentName" />
-          </span>
-        </div>
-      </div>
-
-      <div class="row" metal:define-slot="extra_buttons" tal:replace="nothing">
-      </div>
-
-      <div class="separator"></div>
-    </form>
-  </div>
-
-  </div>
-  </body>
-
-</html>
-

Modified: Zope/trunk/src/Products/Five/form/configure.zcml
===================================================================
--- Zope/trunk/src/Products/Five/form/configure.zcml	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/form/configure.zcml	2009-12-26 23:10:42 UTC (rev 107134)
@@ -1,14 +1,5 @@
-<configure xmlns="http://namespaces.zope.org/zope"
-           xmlns:browser="http://namespaces.zope.org/browser">
+<configure xmlns="http://namespaces.zope.org/zope">
 
-  <include package="zope.app.form.browser" />
+  <include package="five.formlib" />
 
-  <browser:page
-      for="*"
-      name="form_macros"
-      permission="zope2.View"
-      class=".macros.FormMacros"
-      allowed_interface="zope.interface.common.mapping.IItemMapping"
-      />
-
 </configure>
\ No newline at end of file

Deleted: Zope/trunk/src/Products/Five/form/edit.pt
===================================================================
--- Zope/trunk/src/Products/Five/form/edit.pt	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/form/edit.pt	2009-12-26 23:10:42 UTC (rev 107134)
@@ -1,69 +0,0 @@
-<tal:tag condition="view/update"/>
-<html metal:use-macro="context/@@standard_macros/view"
-    i18n:domain="zope">
-  <body>
-  <div metal:fill-slot="body">
-
-  <div metal:define-macro="body">
-
-    <form action="." tal:attributes="action request/URL" method="POST"
-          enctype="multipart/form-data">
-
-      <div metal:define-macro="formbody">
-
-        <h3 tal:condition="view/label"
-            tal:content="view/label"
-            metal:define-slot="heading"
-            >Edit something</h3>
-
-        <p tal:define="status view/update"
-           tal:condition="status"
-           tal:content="status" />
-
-        <p tal:condition="view/errors" i18n:translate="">
-          There are <strong tal:content="python:len(view.errors)"
-                            i18n:name="num_errors">6</strong> input errors.
-        </p>
-
-        <div metal:define-slot="extra_info" tal:replace="nothing">
-        </div>
-
-        <div class="row"
-             metal:define-slot="extra_top" tal:replace="nothing">
-          <div class="label">Extra top</div>
-          <div class="field"><input type="text" style="width:100%" /></div>
-        </div>
-        
-        <div metal:use-macro="context/@@form_macros/widget_rows" />
-        
-        <div class="separator"></div>
-        
-        <div class="row"
-             metal:define-slot="extra_bottom" tal:replace="nothing">
-          <div class="label">Extra bottom</div>
-          <div class="field"><input type="text" style="width:100%" /></div>
-        </div>
-        <div class="separator"></div>
-      </div>
-
-      <div class="row">
-        <div class="controls">
-          <input type="submit" value="Refresh" 
-              i18n:attributes="value refresh-button" />
-          <input type="submit" name="UPDATE_SUBMIT" value="Change" 
-              i18n:attributes="value submit-button"/>
-        </div>
-      </div>
-      <div class="row" metal:define-slot="extra_buttons" tal:replace="nothing">
-      </div>
-
-      <div class="separator"></div>
-
-    </form>
-
-  </div>
-
-  </div>
-  </body>
-
-</html>

Modified: Zope/trunk/src/Products/Five/form/macros.py
===================================================================
--- Zope/trunk/src/Products/Five/form/macros.py	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/form/macros.py	2009-12-26 23:10:42 UTC (rev 107134)
@@ -1,22 +1,2 @@
-##############################################################################
-#
-# Copyright (c) 2004, 2005 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.
-#
-##############################################################################
-"""Form macros
-
-$Id$
-"""
-from Products.Five.skin.standardmacros import StandardMacros
-
-# copy of zope.app.form.browser.macros.FormMacros
-class FormMacros(StandardMacros):    
-    macro_pages = ('widget_macros', 'addform_macros')
+# BBB
+from five.formlib.macros import FormMacros

Modified: Zope/trunk/src/Products/Five/form/meta.zcml
===================================================================
--- Zope/trunk/src/Products/Five/form/meta.zcml	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/form/meta.zcml	2009-12-26 23:10:42 UTC (rev 107134)
@@ -1,35 +1,5 @@
-<configure
-    xmlns="http://namespaces.zope.org/zope"
-    xmlns:meta="http://namespaces.zope.org/meta">
+<configure xmlns="http://namespaces.zope.org/zope">
 
-  <meta:directives namespace="http://namespaces.zope.org/browser">
+  <include package="five.formlib" file="meta.zcml" />
 
-    <meta:complexDirective
-        name="editform"
-        schema="zope.app.form.browser.metadirectives.IEditFormDirective"
-        handler=".metaconfigure.EditFormDirective"
-        >
-
-      <meta:subdirective
-          name="widget"
-          schema="zope.app.form.browser.metadirectives.IWidgetSubdirective"
-          />
-
-    </meta:complexDirective>
-
-    <meta:complexDirective
-        name="addform"
-        schema="zope.app.form.browser.metadirectives.IAddFormDirective"
-        handler=".metaconfigure.AddFormDirective"
-        >
-
-      <meta:subdirective
-          name="widget"
-          schema="zope.app.form.browser.metadirectives.IWidgetSubdirective"
-          />
-
-    </meta:complexDirective>
-
-  </meta:directives>
-
 </configure>

Modified: Zope/trunk/src/Products/Five/form/metaconfigure.py
===================================================================
--- Zope/trunk/src/Products/Five/form/metaconfigure.py	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/form/metaconfigure.py	2009-12-26 23:10:42 UTC (rev 107134)
@@ -1,220 +1,6 @@
-##############################################################################
-#
-# Copyright (c) 2004, 2005 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.
-#
-##############################################################################
-"""Edit form directives
-
-$Id$
-"""
-from App.class_init import InitializeClass
-from ExtensionClass import Base
-
-import zope.component
-from zope.interface import Interface
-from zope.i18nmessageid import MessageFactory
-_ = MessageFactory('zope')
-
-from zope.browsermenu.metaconfigure import menuItemDirective
-from zope.app.form.browser.metaconfigure import BaseFormDirective
-from zope.browser.interfaces import IAdding
-from zope.publisher.interfaces.browser import IDefaultBrowserLayer
-
-from AccessControl.security import protectClass
-
-from Products.Five.form import EditView, AddView
-from Products.Five.metaclass import makeClass
-from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
-from Products.Five.browser.metaconfigure import makeClassForTemplate
-
-def EditViewFactory(name, schema, label, permission, layer,
-                    template, default_template, bases, for_, fields,
-                    fulledit_path=None, fulledit_label=None, menu=u''):
-    class_ = makeClassForTemplate(template, globals(), used_for=schema,
-                                  bases=bases)
-    class_.schema = schema
-    class_.label = label
-    class_.fieldNames = fields
-
-    class_.fulledit_path = fulledit_path
-    if fulledit_path and (fulledit_label is None):
-        fulledit_label = "Full edit"
-
-    class_.fulledit_label = fulledit_label
-
-    class_.generated_form = ZopeTwoPageTemplateFile(default_template)
-
-    if layer is None:
-        layer = IDefaultBrowserLayer
-
-    s = zope.component.getGlobalSiteManager()
-    s.registerAdapter(class_, (for_, layer), Interface, name)
-
-    # Reminder: the permission we got has already been processed by
-    # BaseFormDirective, that means that zope.Public has been
-    # translated to the CheckerPublic object
-    protectClass(class_, permission)
-    InitializeClass(class_)
-
-class FiveFormDirective(BaseFormDirective):
-
-    def _processWidgets(self):
-        if self._widgets:
-            customWidgetsObject = makeClass(
-                'CustomWidgetsMixin', (Base,), self._widgets)
-            self.bases = self.bases + (customWidgetsObject,)
-
-class EditFormDirective(FiveFormDirective):
-
-    view = EditView
-    default_template = 'edit.pt'
-    title = _('Edit')
-
-    def _handle_menu(self):
-        if self.menu:
-            menuItemDirective(
-                self._context, self.menu, self.for_ or self.schema,
-                '@@' + self.name, self.title, permission=self.permission,
-                layer=self.layer)
-
-    def __call__(self):
-        self._processWidgets()
-        self._handle_menu()
-        self._context.action(
-            discriminator=self._discriminator(),
-            callable=EditViewFactory,
-            args=self._args(),
-            kw={'menu': self.menu},
-        )
-
-
-def AddViewFactory(name, schema, label, permission, layer,
-                   template, default_template, bases, for_,
-                   fields, content_factory, arguments,
-                   keyword_arguments, set_before_add, set_after_add,
-                   menu=u''):
-    class_ = makeClassForTemplate(template, globals(), used_for=schema,
-                                  bases=bases)
-
-    class_.schema = schema
-    class_.label = label
-    class_.fieldNames = fields
-    class_._factory = content_factory
-    class_._arguments = arguments
-    class_._keyword_arguments = keyword_arguments
-    class_._set_before_add = set_before_add
-    class_._set_after_add = set_after_add
-
-    class_.generated_form = ZopeTwoPageTemplateFile(default_template)
-
-    if layer is None:
-        layer = IDefaultBrowserLayer
-
-    s = zope.component.getGlobalSiteManager()
-    s.registerAdapter(class_, (for_, layer), Interface, name)
-
-    # Reminder: the permission we got has already been processed by
-    # BaseFormDirective, that means that zope.Public has been
-    # translated to the CheckerPublic object
-    protectClass(class_, permission)
-    InitializeClass(class_)
-
-class AddFormDirective(FiveFormDirective):
-
-    view = AddView
-    default_template = 'add.pt'
-    for_ = IAdding
-
-    # default add form information
-    description = None
-    content_factory = None
-    arguments = None
-    keyword_arguments = None
-    set_before_add = None
-    set_after_add = None
-
-    def _handle_menu(self):
-        if self.menu or self.title:
-            if (not self.menu) or (not self.title):
-                raise ValueError("If either menu or title are specified, "
-                                 "they must both be specified")
-            # Add forms are really for IAdding components, so do not use
-            # for=self.schema.
-            menuItemDirective(
-                self._context, self.menu, self.for_, '@@' + self.name,
-                self.title, permission=self.permission, layer=self.layer,
-                description=self.description)
-
-    def _handle_arguments(self, leftover=None):
-        schema = self.schema
-        fields = self.fields
-        arguments = self.arguments
-        keyword_arguments = self.keyword_arguments
-        set_before_add = self.set_before_add
-        set_after_add = self.set_after_add
-
-        if leftover is None:
-            leftover = fields
-
-        if arguments:
-            missing = [n for n in arguments if n not in fields]
-            if missing:
-                raise ValueError("Some arguments are not included in the form",
-                                 missing)
-            optional = [n for n in arguments if not schema[n].required]
-            if optional:
-                raise ValueError("Some arguments are optional, use"
-                                 " keyword_arguments for them",
-                                 optional)
-            leftover = [n for n in leftover if n not in arguments]
-
-        if keyword_arguments:
-            missing = [n for n in keyword_arguments if n not in fields]
-            if missing:
-                raise ValueError(
-                    "Some keyword_arguments are not included in the form",
-                    missing)
-            leftover = [n for n in leftover if n not in keyword_arguments]
-
-        if set_before_add:
-            missing = [n for n in set_before_add if n not in fields]
-            if missing:
-                raise ValueError(
-                    "Some set_before_add are not included in the form",
-                    missing)
-            leftover = [n for n in leftover if n not in set_before_add]
-
-        if set_after_add:
-            missing = [n for n in set_after_add if n not in fields]
-            if missing:
-                raise ValueError(
-                    "Some set_after_add are not included in the form",
-                    missing)
-            leftover = [n for n in leftover if n not in set_after_add]
-
-            self.set_after_add += leftover
-
-        else:
-            self.set_after_add = leftover
-
-    def __call__(self):
-        self._processWidgets()
-        self._handle_menu()
-        self._handle_arguments()
-
-        self._context.action(
-            discriminator=self._discriminator(),
-            callable=AddViewFactory,
-            args=self._args()+(self.content_factory, self.arguments,
-                                 self.keyword_arguments,
-                                 self.set_before_add, self.set_after_add),
-            kw={'menu': self.menu},
-            )
+# BBB
+from five.formlib.metaconfigure import EditViewFactory
+from five.formlib.metaconfigure import FiveFormDirective
+from five.formlib.metaconfigure import EditFormDirective
+from five.formlib.metaconfigure import AddViewFactory
+from five.formlib.metaconfigure import AddFormDirective

Deleted: Zope/trunk/src/Products/Five/form/objectwidget.pt
===================================================================
--- Zope/trunk/src/Products/Five/form/objectwidget.pt	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/form/objectwidget.pt	2009-12-26 23:10:42 UTC (rev 107134)
@@ -1,15 +0,0 @@
-<fieldset>
-  <legend tal:content="context/legendTitle"
-        i18n:translate="">The Legend</legend>
-  <div class="row" tal:repeat="widget context/subwidgets">
-    <tal:comment condition="nothing">
-      This is why we have to duplicate this template: we want to look
-      up the @@form_macros browser page from something that's
-      definitely five:traversable (it doesn't really matter where we
-      look it up, just *that* we look it up); we know the object we're
-      editing is five:traversable, so we just use that.  Yes, three
-      times context.  Weird, eh?
-    </tal:comment>
-    <metal:block use-macro="context/context/context/@@form_macros/widget_row" />
-  </div>
-</fieldset>

Modified: Zope/trunk/src/Products/Five/form/objectwidget.py
===================================================================
--- Zope/trunk/src/Products/Five/form/objectwidget.py	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/form/objectwidget.py	2009-12-26 23:10:42 UTC (rev 107134)
@@ -1,53 +1,4 @@
-##############################################################################
-#
-# Copyright (c) 2005 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.
-#
-##############################################################################
-"""Five-compatible version of ObjectWidget
-
-This is needed because ObjectWidget uses ViewPageTemplateFile whose
-macro definition is unfortunately incompatible with ZopeTwoPageTemplateFile.
-So this subclass uses ZopeTwoPageTemplateFile for the template that renders
-the widget's sub-editform.
-
-$Id$
-"""
-from AccessControl.SecurityInfo import ClassSecurityInfo
-from App.class_init import InitializeClass
-from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
-from zope.app.form.browser.objectwidget import ObjectWidget as OWBase
-from zope.app.form.browser.objectwidget import ObjectWidgetView as OWVBase
-
-class ObjectWidgetView(OWVBase):
-    security = ClassSecurityInfo()
-    security.declareObjectPublic()
-
-    template = ViewPageTemplateFile('objectwidget.pt')
-
-InitializeClass(ObjectWidgetView)
-
-class ObjectWidgetClass(OWBase):
-
-    def setRenderedValue(self, value):
-        """Slightly more robust re-implementation this method."""
-        # re-call setupwidgets with the content
-        self._setUpEditWidgets()
-        for name in self.names:
-            val = getattr(value, name, None)
-            if val is None:
-                # this is where we are more robust than Zope 3.2's
-                # object widget: we supply subwidgets with the default
-                # from the schema, not None (Zope 3.2's list widget
-                # breaks when the rendered value is None)
-                val = self.context.schema[name].default
-            self.getSubWidget(name).setRenderedValue(val)
-
-ObjectWidget = ObjectWidgetClass
+# BBB
+from five.formlib.objectwidget import ObjectWidgetView
+from five.formlib.objectwidget import ObjectWidget
+from five.formlib.objectwidget import ObjectWidgetClass

Modified: Zope/trunk/src/Products/Five/formlib/__init__.py
===================================================================
--- Zope/trunk/src/Products/Five/formlib/__init__.py	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/formlib/__init__.py	2009-12-26 23:10:42 UTC (rev 107134)
@@ -1 +1 @@
-# package
\ No newline at end of file
+# BBB
\ No newline at end of file

Modified: Zope/trunk/src/Products/Five/formlib/configure.zcml
===================================================================
--- Zope/trunk/src/Products/Five/formlib/configure.zcml	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/formlib/configure.zcml	2009-12-26 23:10:42 UTC (rev 107134)
@@ -1,19 +1,5 @@
-<configure
-    package="zope.formlib"
-    xmlns="http://namespaces.zope.org/zope"
-    i18n_domain="zope">
+<configure xmlns="http://namespaces.zope.org/zope">
 
-  <adapter
-      factory=".form.render_submit_button"
-      name="render"
-      />
+  <include package="five.formlib" />
 
-  <!-- Error view for 'Invalid' -->
-  <adapter
-      for="zope.interface.Invalid
-           zope.publisher.interfaces.browser.IBrowserRequest"
-      factory=".errors.InvalidErrorView"
-      permission="zope.Public"
-      />
-
 </configure>

Modified: Zope/trunk/src/Products/Five/formlib/formbase.py
===================================================================
--- Zope/trunk/src/Products/Five/formlib/formbase.py	2009-12-26 22:36:18 UTC (rev 107133)
+++ Zope/trunk/src/Products/Five/formlib/formbase.py	2009-12-26 23:10:42 UTC (rev 107134)
@@ -1,117 +1,20 @@
-##############################################################################
-#
-# Copyright (c) 2006 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.
-#
-##############################################################################
-"""Five baseclasses for zope.formlib.form
-
-$Id$
-"""
-import os.path
-
-import zope.event
-import zope.formlib
-import zope.lifecycleevent
-from zope import interface
-from zope.formlib import interfaces, form
-from zope.i18nmessageid import MessageFactory
-_ = MessageFactory("zope")
-
-from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
-from Products.Five.browser.decode import processInputs, setPageEncoding
-
-_FORMLIB_DIR = os.path.dirname(zope.formlib.__file__)
-_PAGEFORM_PATH = os.path.join(_FORMLIB_DIR, 'pageform.pt')
-_SUBPAGEFORM_PATH = os.path.join(_FORMLIB_DIR, 'subpageform.pt')
-
-
-class FiveFormlibMixin(object):
-
-    # Overrides the formlib.form.FormBase.template attributes implemented 
-    # using NamedTemplates. NamedTemplates using ViewPageTemplateFile (like
-    # formlib does by default) cannot work in Zope2.
-
-    # XXX Maybe we need to have Five-compatible NamedTemplates?
-
-    template = ViewPageTemplateFile(_PAGEFORM_PATH)
-
-    # Overrides formlib.form.FormBase.update. Make sure user input is
-    # decoded first and the page encoding is set before proceeding.
-
-    def update(self):
-        processInputs(self.request)
-        setPageEncoding(self.request)
-        super(FiveFormlibMixin, self).update()
-
-
-class FormBase(FiveFormlibMixin, form.FormBase):
-    pass
-
-
-class EditFormBase(FiveFormlibMixin, form.EditFormBase):
-    pass
-
-
-class DisplayFormBase(FiveFormlibMixin, form.DisplayFormBase):
-    pass
-
-
-class AddFormBase(FiveFormlibMixin, form.AddFormBase):
-    pass
-
-
-class PageForm(FormBase):
-
-    interface.implements(interfaces.IPageForm)
-
-Form = PageForm
-
-
-class PageEditForm(EditFormBase):
-
-    interface.implements(interfaces.IPageForm)
-
-EditForm = PageEditForm
-
-
-class PageDisplayForm(DisplayFormBase):
-
-    interface.implements(interfaces.IPageForm)
-
-DisplayForm = PageDisplayForm
-
-
-class PageAddForm(AddFormBase):
-
-    interface.implements(interfaces.IPageForm)
-
-AddForm = PageAddForm
-
-
-class SubPageForm(FormBase):
-
-    template = ViewPageTemplateFile(_SUBPAGEFORM_PATH)
-
-    interface.implements(interfaces.ISubPageForm)
-
-
-class SubPageEditForm(EditFormBase):
-
-    template = ViewPageTemplateFile(_SUBPAGEFORM_PATH)
-
-    interface.implements(interfaces.ISubPageForm)
-
-
-class SubPageDisplayForm(DisplayFormBase):
-
-    template = ViewPageTemplateFile(_SUBPAGEFORM_PATH)
-
-    interface.implements(interfaces.ISubPageForm)
+# BBB
+from five.formlib.formbase import _FORMLIB_DIR
+from five.formlib.formbase import _PAGEFORM_PATH
+from five.formlib.formbase import _SUBPAGEFORM_PATH
+from five.formlib.formbase import FiveFormlibMixin
+from five.formlib.formbase import FormBase
+from five.formlib.formbase import EditFormBase
+from five.formlib.formbase import DisplayFormBase
+from five.formlib.formbase import AddFormBase
+from five.formlib.formbase import PageForm
+from five.formlib.formbase import Form
+from five.formlib.formbase import PageEditForm
+from five.formlib.formbase import EditForm
+from five.formlib.formbase import PageDisplayForm
+from five.formlib.formbase import DisplayForm
+from five.formlib.formbase import PageAddForm
+from five.formlib.formbase import AddForm
+from five.formlib.formbase import SubPageForm
+from five.formlib.formbase import SubPageEditForm
+from five.formlib.formbase import SubPageDisplayForm



More information about the Zope-Checkins mailing list