-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Respect permission value for utility factory registrations #55
Conversation
That seemed like a curious omission, so I wondered why. In the earliest version of the code in the repository (3.4.0), a zope.component/src/zope/component/zcml.py Lines 403 to 406 in 40e438c
Later, in response to https://bugs.launchpad.net/zope3/+bug/240631, version 3.5 added the ability to save the This PR wraps the original factory that gets passed to First, I think this may break the original use case of detecting identical factories. (From the bug report: " For tools like GenericSetup that need to round-trip utility registration information that is critical.") Second, because the >>> import pickle
>>> def wrap(obj):
... def wrapper():
... return obj
... return wrapper
...
>>> wrapper = wrap('abc')
>>> pickle.dumps(wrapper)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: Can't pickle local object 'wrap.<locals>.wrapper' |
I was just trying to apply what I had seen elsewhere in the code, that's all. You know this code a lot more, so I may very well have produced a complete dud. Feel free to close or suggest a different implementation if there is one. |
Concern (2) isn't really a practical problem. While it's possible to arrange to execute ZCML against a non-global SiteManager (through z3c.baseregistry IIRC), it's rare-to-nonexistant to do so, I think, with a persistent SiteManager. (I don't know that for sure, but things like adapter registrations with permissions would already be broken). Concern (1) is the main issue, I suspect. I know nothing about the Zope2/4/5/Plone Other than that, I would suggest this is a fairly substantial change that might break some things so it would need to increment the version to at least 4.7.0. |
Thank you for taking all that time. I can't judge the potential for breakage well, I'm trying to stay away from GenericSetup. It worries me and makes me wonder if the best course would be to drop this change and also drop any documentation that claims you can use a utility registration that specifies a factory and permissions. Basically, permissions is only usable if you register a utility and pass a component. Obviously no one has ever noticed or complained in all those years, except for one person who sent email to the Plone folks. |
Starting from scratch, wrapping the factory with the permission factory seems like it should be the right thing to do. What if we take this change, and call the version that releases it 5.0? That should give plenty of notice that there might be breakage, and Actually, with #53, I'd like to be able to call it 5.0. That way, we can bump the zope.interface dependency (currently on 4.something) to the latest zope.interface 5.3 as well (generally semver specifies that if you bump a semver dependency you must also bump your version at the same level). That way I can drop the caveats about "well, this only works if you have the latest zope.interface". We could also drop some of the least useful, previously deprecated, things in this package, such as BWC imports. |
I don't mind cleaning out things that have a |
Off the top of my head, I know at least one place that does. I feel sure that other places are at least docs-deprecated, but I haven't gone looking in more detail. zope.component/src/zope/component/interfaces.py Lines 25 to 29 in 72d0664
|
From my POV this is ready for merging. I have bumped the version number to 5.0 and ran the following tests in conjunction with this branch:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Fixes #54