Skip to content

Commit

Permalink
Adapt to changes in zope.configuration 4.4. (#9)
Browse files Browse the repository at this point in the history
* Adapt to changes in `zope.configuration 4.4`.

The refactoring of exception nesting there breaks the wrongly imported ConfigurationError here.

* Restore ConfigurationError.

This has nothing to do with XML.
  • Loading branch information
sallner committed May 22, 2020
1 parent 3c34a53 commit 106f751
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -9,6 +9,8 @@ CHANGES

- Drop support for Python 3.4.

- Adapt to changes in ``zope.configuration >= 4.4``.


5.1.0 (2018-10-22)
==================
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -87,7 +87,7 @@ def read(*rnames):
"zope.browserpage >= 3.10.1",
"zope.browsermenu",
"zope.component",
"zope.configuration >= 4.1.0",
"zope.configuration >= 4.4.0",
"zope.datetime",
"zope.exceptions",
"zope.i18n",
Expand Down
10 changes: 5 additions & 5 deletions src/zope/app/form/browser/form.rst
Expand Up @@ -177,8 +177,7 @@ Now, if I do not specify my own template, and my class does not overwrite the

>>> sys.modules['form'].NewDataHandler = NewDataHandler

>>> try:
... xmlconfig.string('''
>>> xmlconfig.string('''
... <configure
... xmlns:browser="http://namespaces.zope.org/browser"
... i18n_domain="zope">
Expand All @@ -194,10 +193,11 @@ Now, if I do not specify my own template, and my class does not overwrite the
...
... </configure>
... ''', context)
... except xmlconfig.ConfigurationError as e:
... print(e)
You must specify a class that implements `getData()` and `setData()`, if you do not overwrite `update()`.
Traceback (most recent call last):
...
ZopeXMLConfigurationError: You must specify a class that implements `getData()` and `setData()`, if you do not overwrite `update()`.
File "<string>", line 6.6
zope.configuration.exceptions.ConfigurationError

Now we need to clean up afterwards.

Expand Down
6 changes: 4 additions & 2 deletions src/zope/app/form/browser/metaconfigure.py
Expand Up @@ -23,6 +23,7 @@
from zope.security.checker import CheckerPublic
from zope.interface import implementedBy
from zope.configuration.exceptions import ConfigurationError
from zope.configuration.xmlconfig import ZopeXMLConfigurationError

from zope.browser.interfaces import IAdding
from zope.schema import getFieldNamesInOrder
Expand Down Expand Up @@ -286,9 +287,10 @@ def __init__(self, _context, **kwargs):
attrs = self.class_.__dict__.keys()
if 'template' not in kwargs.keys() and 'update' not in attrs and \
('getData' not in attrs or 'setData' not in attrs):
raise ConfigurationError(
raise ZopeXMLConfigurationError(
"You must specify a class that implements `getData()` "
"and `setData()`, if you do not overwrite `update()`.")
"and `setData()`, if you do not overwrite `update()`.",
ConfigurationError())


class SubeditFormDirective(EditFormDirectiveBase):
Expand Down
5 changes: 2 additions & 3 deletions src/zope/app/form/browser/tests/test_form.py
Expand Up @@ -33,8 +33,6 @@
checker = renormalizing.RENormalizing([
(re.compile("u('.*?')"), r"\1"),
(re.compile('u(".*?")'), r"\1"),
# Python 3 adds module name to exceptions.
(re.compile('zope.configuration.xmlconfig.ZopeXMLConfigurationError'), 'ZopeXMLConfigurationError'),
])


Expand All @@ -47,7 +45,8 @@ def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite('../form.rst',
setUp=setUp, tearDown=testing.tearDown,
optionflags=doctest.NORMALIZE_WHITESPACE),
optionflags=doctest.NORMALIZE_WHITESPACE
| doctest.IGNORE_EXCEPTION_DETAIL),
))

if __name__ == '__main__':
Expand Down

0 comments on commit 106f751

Please sign in to comment.