[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form/tests - test_add.py:1.20

Philipp von Weitershausen philikon at philikon.de
Mon Aug 4 11:52:54 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/browser/form/tests
In directory cvs.zope.org:/tmp/cvs-serv18707/tests

Modified Files:
	test_add.py 
Log Message:
Refactored ZCML directive handlers for zope.app.browser.form. Since they
share a lot of funcationality, it only made sense to bundle this in one
way or another.

I've chosen to put this into base classes and let the handlers be classes
subclassing them. While clarity is somewhat subjective to each person, this
refactoring definitely makes it more extensible.


=== Zope3/src/zope/app/browser/form/tests/test_add.py 1.19 => 1.20 ===
--- Zope3/src/zope/app/browser/form/tests/test_add.py:1.19	Sat Aug  2 22:13:07 2003
+++ Zope3/src/zope/app/browser/form/tests/test_add.py	Mon Aug  4 10:52:49 2003
@@ -16,20 +16,21 @@
 $Id$
 """
 
-import sys
 import unittest
 
-from zope.app.browser.form.add import add, AddViewFactory, AddView
 from zope.interface import Interface, implements
+from zope.publisher.interfaces.browser import IBrowserPresentation
+from zope.publisher.browser import TestRequest
 from zope.schema import TextLine, accessors
+from zope.component import getView
+from zope.component.adapter import provideAdapter
+
+from zope.app.browser.form.add import AddViewFactory, AddView
+from zope.app.browser.form.metaconfigure import AddFormDirective
 from zope.app.interfaces.container import IAdding
-from zope.publisher.interfaces.browser import IBrowserPresentation
 from zope.app.form.widget import CustomWidget
 from zope.app.browser.form.widget import TextWidget as Text
-from zope.publisher.browser import TestRequest
 from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.component import getView
-from zope.component.adapter import provideAdapter
 from zope.app.browser.form.submit import Update
 # Foo needs to be imported as globals() are checked
 from zope.app.browser.form.tests.test_editview import IFoo, IBar, Foo
@@ -100,19 +101,19 @@
                     set_before_add=['getfoo'], set_after_add=['extra1'],
                     fields=None):
         """ Call the 'add' factory to process arguments into 'args'."""
-        return add(self._context,
-                   schema=schema,
-                   name=name,
-                   permission=permission,
-                   label=label,
-                   content_factory=content_factory,
-                   class_=class_,
-                   arguments=arguments,
-                   keyword_arguments=keyword_arguments,
-                   set_before_add=set_before_add,
-                   set_after_add=set_after_add,
-                   fields=fields
-                   )
+        AddFormDirective(self._context,
+                         schema=schema,
+                         name=name,
+                         permission=permission,
+                         label=label,
+                         content_factory=content_factory,
+                         class_=class_,
+                         arguments=arguments,
+                         keyword_arguments=keyword_arguments,
+                         set_before_add=set_before_add,
+                         set_after_add=set_after_add,
+                         fields=fields
+                         )()
 
     def test_add_no_fields(self):
         _context = self._context




More information about the Zope3-Checkins mailing list