[DM] Provide safe 'hasattr_unacquired' and 'safe_hasattr' for trusted and untrusted code.

Bug #375321 reported by Andreas Jung
6
This bug affects 1 person
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(obj.aq_inner.aq_explicit, attr) -- as one can easily see: only something for insiders.

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 ;-)

Revision history for this message
Andreas Jung (ajung) wrote :
Changed in zope2:
status: New → Confirmed
Revision history for this message
Colin Watson (cjwatson) wrote :

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/zopefoundation/zope2.

Changed in zope2:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.