Zope
Zope copied to clipboard
Undocumented name space / import issues between Zope 2 and 4
Hi,
with Zope 2 some symbols were readily available for use - even without importing them.
I recall DateTime
and maybe others. (test
?)
While this always confused me, and I am happy they are gone, could we please add a note to the upgrade instruction from Zope 2 to 4 / 5??
https://zope.readthedocs.io/en/latest/migrations/zope4/index.html
Maybe somebody knows what has changed exactly or where to look for.
I just stumbled over a NameError: name 'DateTime' is not defined
in one untested and rarely used template of my app.
Thank you!
P.S.: Now, this is crazy.
I just created a test to reproduce the issue and the test works - with no modification for Python 3, but for Python 2 it fails with the same NameError
.
The namespace stuff itself is a really nice thing but "it fly's a bit under radar". I thought always it would be a nice idea to add an Adapter to modifiy/include stuff in the namespace. Think on the principal or a library to format values...
tal:content="principal.id" tal:content="format.to_german(item.price)" etc...
Jürgen Gmach wrote at 2020-4-1 05:58 -0700:
with Zope 2 some symbols were readily available for use - even without importing them.
I recall
DateTime
and maybe others. (test
?)While this always confused me, and I am happy they are gone, could we please add a note to the upgrade instruction from Zope 2 to 4 / 5??
https://zope.readthedocs.io/en/latest/migrations/zope4/index.html
Maybe somebody knows what has changed exactly or where to look for.
I believe that those symbols have been injected by the DTML implementation.
RestrictedPython
has a base notion of
what is safe to use. In the Zope
world, AccessControl
imports
the corresponding variable (as safe_builtins
, or similarly spelled)
and significantly adapts/extends it.
Formerly, the DTML implementation has added its own symbols as well,
among them test
.