Hash: SHA1

Dieter Maurer wrote:
> Thomas Lotze wrote at 2008-10-16 20:57 +0200:
>> Christian Theune <[EMAIL PROTECTED]> wrote:
>>> Arguably, the check for an attribute would be sufficient if it checked
>>> whether an attribute implementation is around -- either by a simple
>>> attribute value or a descriptor providing that.
>> At this point, I guess the outcome of the discussion depends on whether
>> it is considered legal or abuse to implement a data descriptor in such
>> a way that it hides an attribute defined on a base class by raising an
>> AttributeError.
> That is only one extreme case.
> Instead, the discussion outcome depends on whether an attribute
> is considered to be there when the descriptor raises an exception.
> As the attribute is not accessible in this case, I argue that
> it is not there: in this case, it does not have the wrong value, it
> has no value at all...

+1.  A descriptor which raises AttributeError *denies* the existence of
the attribute, period:  if the contract / interface requires that the
attribute exist, then such a descriptor violates the contract (under
whatever circumstances it raises the error).

The choice then becomes:

 - Satisfy the contract, e.g. by updating the descriptor to return some
   appropriate default in the cases where it now raises AttributeError.

 - Relax the contract by removing the attribute from the interface.

In either case, 'verifyClass' and 'verifyObject' will behave as
expected, without changes.

- --
Tres Seaver          +1 540-429-0999          [EMAIL PROTECTED]
Palladion Software   "Excellence by Design"    http://palladion.com
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to