[Zope-dev] zope.interface: verifyObject vs properties
Christian Theune
ct at gocept.com
Thu Oct 16 14:27:08 EDT 2008
Hi,
On Thu, 2008-10-16 at 18:45 +0200, Dieter Maurer wrote:
> I do not follow your argumentation: An attribute it not there because
> there is a descriptor, it is only there when the descriptor provides
> a value: I have seen descriptors in Zope3 that are only there to
> remove
> an attribute that might otherwise be inherited -- by unconditionally
> raising
> "AttributeError". In this case, the existance of the particular
> descriptor precisely means that the attribute is missing.
>
> Moreover, when an attribut is implemented by a descriptor, I am
> very much interested that its "__get__" does not raise an exception.
> If this is not the case, I would like to be warned early; if possible
> even by a unit test.
Then again, verifyObject is a *very* light way to spot simple errors.
IMHO attributes and methods aren't that different in Python, as "using"
both may result in exceptions.
However, implementing a method of an interface doesn't check whether the
method actually executes correctly -- only whether an implementation is
present.
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.
There's another method: verifyClass. This definitely only checks the
presence of an implementation.
Thomas: There is an issue that we regularly see with verifyClass that
makes us instanciated the objects and then use verifyObject. I don't
remember what it was right now. Do you?
Christian
--
Christian Theune · ct at gocept.com
gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 7 · fax +49 345 1229889 1
Zope and Plone consulting and development
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/zope-dev/attachments/20081016/8ac40258/attachment.bin
More information about the Zope-Dev
mailing list