zopefoundation / zope.configuration

Extensible system for supporting various kinds of configurations
https://zopeconfiguration.readthedocs.io
Other
1 stars 6 forks source link

Make GlobalObject only allow dotted names. #29

Closed jamadden closed 5 years ago

jamadden commented 5 years ago

Fixes #6

Also make all fields provide the value and field when they raise an exception.

Based on #24 so tests pass.

jamadden commented 5 years ago

Hmm. There may be an issue here:

>>> from zope.configuration.fields import GlobalObject
>>> go = GlobalObject()
>>> go.fromUnicode('pkg._private')
Traceback ...
InvalidDottedName: foo._abc

Meanwhile, PythonIdentifier allows for underscores in segments:

>>> from zope.configuration.fields import PythonIdentifier
>>> pi = PythonIdentifier()
>>> pi.validate('_abc')
>>>

I would think this is a bug in zope.schema.DottedName. If that's fixed, then PythonIdentifier can be changed to just extend DottedName with min_dots = max_dots = 0

jamadden commented 5 years ago

Rebased on master and updated to use the newer DottedName that fixes the above issue.

jamadden commented 5 years ago

Rebased on master, post #30

jamadden commented 5 years ago

Cool! Thanks!