[DM] Provide safe 'hasattr_unacquired' and 'safe_hasattr' for trusted and untrusted code.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 2 |
Invalid
|
Wishlist
|
Unassigned |
Bug Description
2. Introduction
Formerly, Zope did not have a safe way to determine in untrusted code whether an object has a given unacquired attribute. We (at Haufe) therefore implemented an hasattr_unacquired for this function. The implementation had been donated to the Zope community (via a feature+solution collector entry) but was never added to the core.
Meanwhile, Zope allows untrusted code to safely check for unacquired attributes. It looks like hasattr(
3. Feature
Define safe hasattr_unacquired and safe_hasattr and make them available for trusted and untrusted code.
4. Example Use Cases
This feature is no longer vital for us. We could rewrite all occurrences of hasattr_unacquired by the horrible expression from the introduction (which is a bit unsafe, due to hasattr peculiarities).
safe_hasattr can be emulated by means of getattr with default and a comparison against the default.
But hasattr_unacquired and safe_hasattr are a lot better to understand ;-)
Changed in zope2: | |
status: | New → Confirmed |
The zope2 project on Launchpad has been archived at the request of the Zope developers (see https:/ /answers. launchpad. net/launchpad/ +question/ 683589 and https:/ /answers. launchpad. net/launchpad/ +question/ 685285). If this bug is still relevant, please refile it at https:/ /github. com/zopefoundat ion/zope2.