[Checkins] SVN: zope.app.authentication/trunk/ try to lift the dependency on zope.app.form. z.a.form still is an indirect test dependency though.

Jan-Wijbrand Kolman janwijbrand at gmail.com
Tue Oct 12 10:42:31 EDT 2010


Log message for revision 117475:
  try to lift the dependency on zope.app.form. z.a.form still is an indirect test dependency though.

Changed:
  U   zope.app.authentication/trunk/CHANGES.txt
  U   zope.app.authentication/trunk/buildout.cfg
  U   zope.app.authentication/trunk/setup.py
  U   zope.app.authentication/trunk/src/zope/app/authentication/browser/granting.py
  U   zope.app.authentication/trunk/src/zope/app/authentication/browser/granting.txt
  U   zope.app.authentication/trunk/src/zope/app/authentication/browser/schemasearch.py
  U   zope.app.authentication/trunk/src/zope/app/authentication/browser/schemasearch.txt

-=-
Modified: zope.app.authentication/trunk/CHANGES.txt
===================================================================
--- zope.app.authentication/trunk/CHANGES.txt	2010-10-12 13:45:43 UTC (rev 117474)
+++ zope.app.authentication/trunk/CHANGES.txt	2010-10-12 14:42:30 UTC (rev 117475)
@@ -2,12 +2,12 @@
 Changes
 =======
 
-3.8.1 (unreleased)
-------------------
+3.9 (unreleased)
+----------------
 
-- Nothing changed yet.
+* Use zope.formlib throughout to lift the dependency on zope.app.form. As it
+  turns out, zope.app.form is still a indirect test dependency though.
 
-
 3.8.0 (2010-09-25)
 ------------------
 
@@ -23,14 +23,12 @@
   - ``@@RolePermissions.html``
   - ``@@RolesWithPermission.html``
 
-
 3.7.1 (2010-02-11)
 ------------------
 
 * Using the new `principalfactories.zcml` file, from ``zope.pluggableauth``,
   to avoid duplication errors, in the adapters registration.
 
-
 3.7.0 (2010-02-08)
 ------------------
 
@@ -39,13 +37,11 @@
   new package, providing backward compatibility imports to assure a
   smooth transition.
 
-
 3.6.2 (2010-01-05)
 ------------------
 
 * Fix tests by using zope.login, and require new zope.publisher 3.12.
 
-
 3.6.1 (2009-10-07)
 ------------------
 
@@ -73,7 +69,6 @@
 
 * Remove deprecated code.
 
-
 3.5.0 (2009-03-06)
 ------------------
 

Modified: zope.app.authentication/trunk/buildout.cfg
===================================================================
--- zope.app.authentication/trunk/buildout.cfg	2010-10-12 13:45:43 UTC (rev 117474)
+++ zope.app.authentication/trunk/buildout.cfg	2010-10-12 14:42:30 UTC (rev 117475)
@@ -1,4 +1,7 @@
 [buildout]
+extends =
+  http://download.zope.org/zopetoolkit/index/1.0c3/ztk-versions.cfg
+  http://download.zope.org/zopetoolkit/index/1.0c3/zopeapp-versions.cfg
 develop = .
 parts = test
 

Modified: zope.app.authentication/trunk/setup.py
===================================================================
--- zope.app.authentication/trunk/setup.py	2010-10-12 13:45:43 UTC (rev 117474)
+++ zope.app.authentication/trunk/setup.py	2010-10-12 14:42:30 UTC (rev 117475)
@@ -73,27 +73,28 @@
           'zope.login',]),
       namespace_packages=['zope', 'zope.app'],
       install_requires=[
+          'setuptools',
           'ZODB3',
-          'setuptools',
-          'zope.app.form',# needed by browser code
-          'zope.app.container', # needed for browser code
-          'zope.app.component', # needed for browser code
           'zope.authentication',
           'zope.component',
           'zope.container',
           'zope.dublincore',
           'zope.event',
           'zope.exceptions',
-          'zope.formlib',
+          'zope.formlib >= 4.0.2',
           'zope.i18n',
           'zope.i18nmessageid',
           'zope.interface',
           'zope.location',
-          'zope.password>=3.5.1',
-          'zope.pluggableauth>=1.0.1',
+          'zope.password >= 3.5.1',
+          'zope.pluggableauth >= 1.0.1',
           'zope.schema',
           'zope.security',
           'zope.traversing',
+
+          # Needed for browser code.
+          'zope.app.container',
+          'zope.app.component',
           ],
       include_package_data = True,
       zip_safe = False,

Modified: zope.app.authentication/trunk/src/zope/app/authentication/browser/granting.py
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/browser/granting.py	2010-10-12 13:45:43 UTC (rev 117474)
+++ zope.app.authentication/trunk/src/zope/app/authentication/browser/granting.py	2010-10-12 14:42:30 UTC (rev 117475)
@@ -28,11 +28,11 @@
 from zope.securitypolicy.vocabulary import GrantVocabulary
 
 from zope.authentication.principal import PrincipalSource
-from zope.app.form.utility import setUpWidget
-from zope.app.form.browser import RadioWidget
-from zope.app.form.browser.widget import renderElement
-from zope.app.form.interfaces import MissingInputError
-from zope.app.form.interfaces import IInputWidget
+from zope.formlib.interfaces import IInputWidget
+from zope.formlib.interfaces import MissingInputError
+from zope.formlib.utility import setUpWidget
+from zope.formlib.widget import renderElement
+from zope.formlib.widgets import RadioWidget
 from zope.security.interfaces import IPermission
 
 
@@ -68,7 +68,7 @@
 
 
     def renderItem(self, index, text, value, name, cssClass):
-        """Render an item of the list. 
+        """Render an item of the list.
 
         Revert the order of label and text. Added field id to the lable
         attribute.
@@ -89,7 +89,7 @@
         return self._tdTemplate % (tdClass, id, text, elem)
 
     def renderSelectedItem(self, index, text, value, name, cssClass):
-        """Render a selected item of the list. 
+        """Render a selected item of the list.
 
         Revert the order of label and text. Added field id to the lable
         attribute.

Modified: zope.app.authentication/trunk/src/zope/app/authentication/browser/granting.txt
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/browser/granting.txt	2010-10-12 13:45:43 UTC (rev 117474)
+++ zope.app.authentication/trunk/src/zope/app/authentication/browser/granting.txt	2010-10-12 14:42:30 UTC (rev 117475)
@@ -71,13 +71,13 @@
   - Vocabulary Choice Widgets
 
     >>> from zope.schema.interfaces import IChoice
-    >>> from zope.app.form.browser import ChoiceInputWidget
-    >>> from zope.app.form.interfaces import IInputWidget
+    >>> from zope.formlib.interfaces import IInputWidget
+    >>> from zope.formlib.widgets import ChoiceInputWidget
     >>> ztapi.browserViewProviding(IChoice, ChoiceInputWidget, IInputWidget)
 
     >>> from zope.schema.interfaces import IVocabularyTokenized
     >>> from zope.publisher.interfaces.browser import IBrowserRequest
-    >>> from zope.app.form.browser import DropdownWidget
+    >>> from zope.formlib.widgets import DropdownWidget
     >>> ztapi.provideMultiView((IChoice, IVocabularyTokenized),
     ...                        IBrowserRequest, IInputWidget, '',
     ...                        DropdownWidget)
@@ -90,14 +90,14 @@
     >>> ztapi.browserViewProviding(IPrincipalSource, PrincipalTerms, ITerms)
 
     >>> from zope.app.security.browser.auth import AuthUtilitySearchView
-    >>> from zope.app.form.browser.interfaces import ISourceQueryView
+    >>> from zope.formlib.interfaces import ISourceQueryView
     >>> ztapi.browserViewProviding(IAuthentication,
     ...                            AuthUtilitySearchView,
     ...                            ISourceQueryView)
 
 
     >>> from zope.schema.interfaces import ISource
-    >>> from zope.app.form.browser.source import SourceInputWidget
+    >>> from zope.formlib.source import SourceInputWidget
     >>> ztapi.provideMultiView((IChoice, ISource), IBrowserRequest,
     ...                        IInputWidget, '', SourceInputWidget)
 

Modified: zope.app.authentication/trunk/src/zope/app/authentication/browser/schemasearch.py
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/browser/schemasearch.py	2010-10-12 13:45:43 UTC (rev 117474)
+++ zope.app.authentication/trunk/src/zope/app/authentication/browser/schemasearch.py	2010-10-12 14:42:30 UTC (rev 117475)
@@ -18,9 +18,10 @@
 __docformat__ = "reStructuredText"
 
 from zope.app.authentication.i18n import ZopeMessageFactory as _
-from zope.app.form.browser.interfaces import ISourceQueryView
-from zope.app.form.utility import setUpWidgets, getWidgetsData
-from zope.formlib.interfaces import IInputWidget
+from zope.formlib.interfaces import IInputWidget, InputErrors
+from zope.formlib.interfaces import ISourceQueryView
+from zope.formlib.interfaces import WidgetsError, MissingInputError
+from zope.formlib.utility import setUpWidgets
 from zope.i18n import translate
 from zope.interface import implements
 from zope.schema import getFieldsInOrder
@@ -106,5 +107,21 @@
             return None
         schema = self.context.schema
         setUpWidgets(self, schema, IInputWidget, prefix=name+'.field')
-        data = getWidgetsData(self, schema)
+        # XXX inline the original getWidgetsData call in
+        # zope.app.form.utility to lift the dependency on zope.app.form.
+        data = {}
+        errors = []
+        for name, field in getFieldsInOrder(schema):
+            widget = getattr(self, name + '_widget')
+            if IInputWidget.providedBy(widget):
+                if widget.hasInput():
+                    try:
+                        data[name] = widget.getInputValue()
+                    except InputErrors, error:
+                        errors.append(error)
+                elif field.required:
+                    errors.append(MissingInputError(
+                        name, widget.label, 'the field is required'))
+        if errors:
+            raise WidgetsError(errors, widgetsData=data)
         return self.context.search(data)

Modified: zope.app.authentication/trunk/src/zope/app/authentication/browser/schemasearch.txt
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/browser/schemasearch.txt	2010-10-12 13:45:43 UTC (rev 117474)
+++ zope.app.authentication/trunk/src/zope/app/authentication/browser/schemasearch.txt	2010-10-12 14:42:30 UTC (rev 117475)
@@ -6,8 +6,8 @@
   >>> from zope.component import provideAdapter
   >>> from zope.schema.interfaces import ITextLine
   >>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
-  >>> from zope.app.form.browser import TextWidget
-  >>> from zope.app.form.interfaces import IInputWidget
+  >>> from zope.formlib.interfaces import IInputWidget
+  >>> from zope.formlib.widgets import TextWidget
   >>> from zope.app.testing.setup import placefulSetUp, placefulTearDown
   >>> site = placefulSetUp(True)
   >>> provideAdapter(TextWidget, (ITextLine, IDefaultBrowserLayer),
@@ -46,7 +46,7 @@
 then we can get a view::
 
   >>> from zope.app.authentication.browser.schemasearch \
-  ...     import QuerySchemaSearchView 
+  ...     import QuerySchemaSearchView
   >>> from zope.publisher.browser import TestRequest
   >>> request = TestRequest()
   >>> view = QuerySchemaSearchView(MySearchPlugin(), request)



More information about the checkins mailing list