[Checkins] SVN: z3c.form/branches/adamg-z3c-pt-optional/ trying to make z3c.pt optional... no luck yet
Adam Groszer
agroszer at gmail.com
Mon May 11 14:27:40 EDT 2009
Log message for revision 99854:
trying to make z3c.pt optional... no luck yet
Changed:
U z3c.form/branches/adamg-z3c-pt-optional/buildout.cfg
U z3c.form/branches/adamg-z3c-pt-optional/setup.py
U z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/__init__.py
U z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/adding.txt
U z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/error.py
U z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/error.txt
U z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/form.py
U z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/form.txt
U z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/group.txt
U z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/object.py
U z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/subform.txt
U z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/testing.py
U z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/tests/test_doc.py
U z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/widget.py
U z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/zcml.txt
-=-
Modified: z3c.form/branches/adamg-z3c-pt-optional/buildout.cfg
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/buildout.cfg 2009-05-11 17:35:59 UTC (rev 99853)
+++ z3c.form/branches/adamg-z3c-pt-optional/buildout.cfg 2009-05-11 18:27:40 UTC (rev 99854)
@@ -1,7 +1,18 @@
[buildout]
develop = . benchmark
-parts = test checker coverage-test coverage-report docs i18n benchmark python
+parts = test checker coverage-test coverage-report docs i18n python
+#####################################################
+# REMOVE THIS BEFORE MERGE!
+extends = http://download.zope.org/zope3.4/3.4.0/versions.cfg
+versions = versions
+
+[versions]
+z3c.form=
+lxml = 2.1.1
+#
+#####################################################
+
[test-environment]
CHAMELEON_DEBUG = False
CHAMELEON_CACHE = False
Modified: z3c.form/branches/adamg-z3c-pt-optional/setup.py
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/setup.py 2009-05-11 17:35:59 UTC (rev 99853)
+++ z3c.form/branches/adamg-z3c-pt-optional/setup.py 2009-05-11 18:27:40 UTC (rev 99854)
@@ -75,6 +75,10 @@
package_dir = {'':'src'},
namespace_packages = ['z3c'],
extras_require = dict(
+ extra = [
+ 'z3c.pt >= 1.0b4',
+ 'z3c.ptcompat',
+ ],
test = [
'zope.app.testing',
'zope.app.container',
@@ -83,9 +87,8 @@
'zope.testing',
'z3c.coverage',
'z3c.template',
- 'z3c.pt >= 1.0b4',
'zc.sourcefactory',
- 'lxml >= 2.1.1',
+ 'lxml',
],
adding = ['zope.app.container'],
docs = ['z3c.recipe.sphinxdoc'],
@@ -107,7 +110,6 @@
'zope.security',
'zope.site',
'zope.traversing',
- 'z3c.ptcompat',
],
zip_safe = False,
)
Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/__init__.py
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/__init__.py 2009-05-11 17:35:59 UTC (rev 99853)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/__init__.py 2009-05-11 18:27:40 UTC (rev 99854)
@@ -1 +1,6 @@
# Make a package.
+
+# Apply compatibility layer
+from z3c.form import compatibility
+compatibility.apply()
+del compatibility
\ No newline at end of file
Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/adding.txt
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/adding.txt 2009-05-11 17:35:59 UTC (rev 99853)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/adding.txt 2009-05-11 18:27:40 UTC (rev 99854)
@@ -52,7 +52,7 @@
for it now:
>>> import os
- >>> from z3c import ptcompat as viewpagetemplatefile
+ >>> from z3c.form import ptcompat as viewpagetemplatefile
>>> from z3c.form import tests, field
>>> from z3c.form.adding import AddForm
Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/error.py
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/error.py 2009-05-11 17:35:59 UTC (rev 99853)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/error.py 2009-05-11 18:27:40 UTC (rev 99854)
@@ -20,11 +20,12 @@
import zope.component
import zope.interface
import zope.schema
-from z3c import ptcompat
+#from z3c import ptcompat
from zope.pagetemplate.interfaces import IPageTemplate
import z3c.form
from z3c.form import interfaces, util, value
+from z3c.form import ptcompat
from z3c.form.i18n import MessageFactory as _
ErrorViewMessage = value.StaticValueCreator(
@@ -127,7 +128,8 @@
template = None
def __init__(self, filename, contentType='text/html'):
- self.template = ptcompat.ViewPageTemplateFile(filename, content_type=contentType)
+ self.template = ptcompat.ViewPageTemplateFile(
+ filename, content_type=contentType)
def __call__(self, errorView, request):
return self.template
Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/error.txt
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/error.txt 2009-05-11 17:35:59 UTC (rev 99853)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/error.txt 2009-05-11 18:27:40 UTC (rev 99854)
@@ -99,7 +99,7 @@
needs, sometimes one wishes to register a custom view to have more complex
views. In this example we wish to register a custom error message:
- >>> from z3c import ptcompat as viewpagetemplatefile
+ >>> from z3c.form import ptcompat as viewpagetemplatefile
>>> from z3c.form import tests
>>> class NegativeAgeView(error.ErrorViewSnippet):
Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/form.py
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/form.py 2009-05-11 17:35:59 UTC (rev 99853)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/form.py 2009-05-11 18:27:40 UTC (rev 99854)
@@ -21,13 +21,14 @@
import zope.component
import zope.event
import zope.lifecycleevent
-from z3c import ptcompat
+#from z3c import ptcompat
from zope.publisher import browser
from zope.pagetemplate.interfaces import IPageTemplate
from zope.schema.fieldproperty import FieldProperty
from z3c.form import button, field, interfaces, util
from z3c.form.i18n import MessageFactory as _
+from z3c.form import ptcompat
def applyChanges(form, content, data):
Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/form.txt
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/form.txt 2009-05-11 17:35:59 UTC (rev 99853)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/form.txt 2009-05-11 18:27:40 UTC (rev 99854)
@@ -289,7 +289,7 @@
very simple template as part of this example:
>>> import os
- >>> from z3c import ptcompat as viewpagetemplatefile
+ >>> from z3c.form import ptcompat as viewpagetemplatefile
>>> from z3c.form import tests
>>> def addTemplate(form):
... form.template = viewpagetemplatefile.bind_template(
@@ -563,7 +563,7 @@
>>> addForm.name
'form'
-The template can then use those attributes, if it likes to.
+The template can then use those attributes, if it likes to.
In the examples previously we set the template manually. If no
template is specified, the system tries to find an adapter. Without
@@ -648,8 +648,8 @@
<input class="text-widget required textline-field"
id="form-widgets-name" name="form.widgets.name" type="text" value="">
</div>
-
+
Adding a "Cancel" button
------------------------
@@ -1476,7 +1476,7 @@
... self.refreshActions = True
First, let's illustrate simple cases, when no button is pressed.
-The button will be available when context is not empty.
+The button will be available when context is not empty.
>>> context = [1, 2, 3, 4]
>>> request = TestRequest()
Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/group.txt
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/group.txt 2009-05-11 17:35:59 UTC (rev 99853)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/group.txt 2009-05-11 18:27:40 UTC (rev 99854)
@@ -60,7 +60,7 @@
one of the base classes. The groups are specified in a simple tuple:
>>> import os
- >>> from z3c import ptcompat as viewpagetemplatefile
+ >>> from z3c.form.ptcompat import ViewPageTemplateFile
>>> from z3c.form import form, tests
>>> class RegistrationAddForm(group.GroupForm, form.AddForm):
@@ -68,7 +68,7 @@
... 'firstName', 'lastName')
... groups = (LicenseGroup, CarGroup)
...
- ... template = viewpagetemplatefile.ViewPageTemplateFile(
+ ... template = ViewPageTemplateFile(
... 'simple_groupedit.pt', os.path.dirname(tests.__file__))
...
... def create(self, data):
@@ -281,7 +281,7 @@
... 'firstName', 'lastName')
... groups = (LicenseGroup, CarGroup)
...
- ... template = viewpagetemplatefile.ViewPageTemplateFile(
+ ... template = ViewPageTemplateFile(
... 'simple_groupedit.pt', os.path.dirname(tests.__file__))
>>> request = testing.TestRequest()
Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/object.py
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/object.py 2009-05-11 17:35:59 UTC (rev 99853)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/object.py 2009-05-11 18:27:40 UTC (rev 99854)
@@ -24,12 +24,13 @@
from zope.security.proxy import removeSecurityProxy
from zope.pagetemplate.interfaces import IPageTemplate
-from z3c import ptcompat as viewpagetemplatefile
+#from z3c import ptcompat as viewpagetemplatefile
from z3c.form.converter import BaseDataConverter
from z3c.form import form, interfaces, util, widget
from z3c.form.field import Fields
from z3c.form.error import MultipleErrors
+from z3c.form.ptcompat import ViewPageTemplateFile
def getIfName(iface):
return iface.__module__+'.'+iface.__name__
@@ -316,7 +317,7 @@
def __init__(self, filename, contentType='text/html',
context=None, request=None, view=None,
field=None, widget=None, schema=None):
- self.template = viewpagetemplatefile.ViewPageTemplateFile(
+ self.template = ViewPageTemplateFile(
filename, content_type=contentType)
zope.component.adapter(
util.getSpecification(context),
Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/subform.txt
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/subform.txt 2009-05-11 17:35:59 UTC (rev 99853)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/subform.txt 2009-05-11 18:27:40 UTC (rev 99854)
@@ -68,13 +68,13 @@
is the template, which should not render a form-tag:
>>> import os
- >>> from z3c import ptcompat as viewpagetemplatefile
+ >>> from z3c.form.ptcompat import ViewPageTemplateFile
>>> from z3c.form import form, field, tests
>>> templatePath = os.path.dirname(tests.__file__)
>>> class OwnerForm(form.EditForm):
- ... template = viewpagetemplatefile.ViewPageTemplateFile(
+ ... template = ViewPageTemplateFile(
... 'simple_owneredit.pt', templatePath)
... fields = field.Fields(IOwner)
... prefix = 'owner'
@@ -87,7 +87,7 @@
>>> class CarForm(form.EditForm):
... fields = field.Fields(ICar).select('model', 'make')
- ... template = viewpagetemplatefile.ViewPageTemplateFile(
+ ... template = ViewPageTemplateFile(
... 'simple_caredit.pt', templatePath)
... prefix = 'car'
... def update(self):
@@ -267,7 +267,7 @@
>>> from z3c.form import subform
>>> class OwnerForm(subform.EditSubForm):
- ... template = viewpagetemplatefile.ViewPageTemplateFile(
+ ... template = ViewPageTemplateFile(
... 'simple_subedit.pt', templatePath)
... fields = field.Fields(IOwner)
... prefix = 'owner'
@@ -277,7 +277,7 @@
>>> class CarForm(form.EditForm):
... fields = field.Fields(ICar).select('model', 'make')
- ... template = viewpagetemplatefile.ViewPageTemplateFile(
+ ... template = ViewPageTemplateFile(
... 'simple_caredit.pt', templatePath)
... prefix = 'car'
...
@@ -467,7 +467,7 @@
>>> print carForm.render() # doctest: +NOPARSE_MARKUP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
+ <html xmlns="http://www.w3.org/1999/xhtml">
...
<fieldset>
<legend>Owner</legend>
@@ -482,7 +482,7 @@
</fieldset>
...
</html>
-
+
If the data did not change, it is also locally reported:
>>> request = TestRequest(form={
@@ -525,7 +525,7 @@
>>> from z3c.form.interfaces import IWidgets
>>> class OwnerAddForm(form.EditForm):
- ... template = viewpagetemplatefile.ViewPageTemplateFile(
+ ... template = ViewPageTemplateFile(
... 'simple_owneredit.pt', templatePath)
... fields = field.Fields(IOwner)
... prefix = 'owner'
@@ -540,7 +540,7 @@
>>> class CarAddForm(form.EditForm):
... fields = field.Fields(ICar).select('model', 'make')
- ... template = viewpagetemplatefile.ViewPageTemplateFile(
+ ... template = ViewPageTemplateFile(
... 'simple_caredit.pt', templatePath)
... prefix = 'car'
...
Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/testing.py
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/testing.py 2009-05-11 17:35:59 UTC (rev 99853)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/testing.py 2009-05-11 18:27:40 UTC (rev 99854)
@@ -37,11 +37,11 @@
from z3c.form.browser import radio, select, text, textarea
from z3c.form.browser import file as fileWidget
+from z3c.form.ptcompat import AVAILABLE
+
from z3c.ptcompat.testing import render
from z3c.ptcompat.testing import OutputChecker
-import z3c.ptcompat
-
import lxml.html
import lxml.doctestcompare
@@ -189,10 +189,13 @@
test.globs = {'root': setup.placefulSetUp(True)}
def setUpZPT(suite):
- z3c.ptcompat.config.disable()
+ if AVAILABLE:
+ import z3c.ptcompat
+ z3c.ptcompat.config.disable()
setUp(suite)
def setUpZ3CPT(suite):
+ import z3c.ptcompat
z3c.ptcompat.config.enable()
setUp(suite)
zope.configuration.xmlconfig.XMLConfig('configure.zcml', z3c.pt)()
Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/tests/test_doc.py
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/tests/test_doc.py 2009-05-11 17:35:59 UTC (rev 99853)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/tests/test_doc.py 2009-05-11 18:27:40 UTC (rev 99854)
@@ -24,10 +24,16 @@
from zope.app.testing import placelesssetup
from z3c.form import testing
+from z3c.form.ptcompat import AVAILABLE
def test_suite():
checker = testing.OutputChecker(doctest)
+ if AVAILABLE:
+ setups = (testing.setUpZPT, testing.setUpZ3CPT)
+ else:
+ setups = (testing.setUpZPT,)
+
tests = ((
doctest.DocFileSuite(
'../action.txt',
@@ -144,6 +150,6 @@
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
checker=checker,
))
- for setUp in (testing.setUpZPT, testing.setUpZ3CPT))
+ for setUp in setups)
return unittest.TestSuite(itertools.chain(*tests))
Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/widget.py
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/widget.py 2009-05-11 17:35:59 UTC (rev 99853)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/widget.py 2009-05-11 18:27:40 UTC (rev 99854)
@@ -22,11 +22,12 @@
import zope.location
import zope.schema.interfaces
from zope.pagetemplate.interfaces import IPageTemplate
-from z3c import ptcompat as viewpagetemplatefile
+#from z3c import ptcompat as viewpagetemplatefile
from zope.i18n import translate
from zope.schema.fieldproperty import FieldProperty
from z3c.form import interfaces, util, value
+from z3c.form import ptcompat as viewpagetemplatefile
PLACEHOLDER = object()
Modified: z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/zcml.txt
===================================================================
--- z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/zcml.txt 2009-05-11 17:35:59 UTC (rev 99853)
+++ z3c.form/branches/adamg-z3c-pt-optional/src/z3c/form/zcml.txt 2009-05-11 18:27:40 UTC (rev 99854)
@@ -74,8 +74,8 @@
and check it:
- >>> from z3c import ptcompat
- >>> isinstance(template, ptcompat.ViewPageTemplateFile)
+ >>> from z3c.form.ptcompat import ViewPageTemplateFile
+ >>> isinstance(template, ViewPageTemplateFile)
True
Let's use the template within the widget.
@@ -178,7 +178,7 @@
and check it:
- >>> isinstance(template, ptcompat.ViewPageTemplateFile)
+ >>> isinstance(template, ViewPageTemplateFile)
True
Let's use the template within the widget.
More information about the Checkins
mailing list