[Zope-dev] zope.interface: verifyObject vs properties
Tres Seaver
tseaver at palladion.com
Fri Oct 17 14:50:23 EDT 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dieter Maurer wrote:
> Thomas Lotze wrote at 2008-10-16 20:57 +0200:
>> Christian Theune <ct at gocept.com> 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.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver at palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFI+N5v+gerLs4ltQ4RAqqEAJ440ALN/9seugX+jiayKhv6htLFRQCgvw06
nyzQaM/HA/m8j7Mxd0FmXTM=
=rgCs
-----END PGP SIGNATURE-----
More information about the Zope-Dev
mailing list