[z3-five] Attribute gives: security declaration for nonexistent method
Tres Seaver
tseaver at palladion.com
Wed Apr 18 17:43:09 CEST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Maurits van Rees wrote:
> Hi,
>
> In an interface I have an Attribute:
>
> bookinglist = Attribute("List of individual Bookings")
>
> Now when starting Zope, I get a warning:
>
> WARNING Init Class Products.Five.metaclass.BookingListView \
> has a security declaration for nonexistent method 'bookinglist'
>
> Everything works as expected as far as I can see, so it does not look
> like a real problem. But is there a way to get rid of this warning?
>
> Ah, the warning gets throws at the end of lib/python/App/class_init.py
> as it can't find an attribute with the name 'bookinglist' in that
> class. And that is correct as I set that in the __init__.py of the
> view class, so at Zope startup time it is not known.
>
> So: should all Attributes of a browser view be set in the class
> definition outside of the __init__()? Well, all Attributes that are
> indicated by the Interface at least. Correct?
>
> It gets rid of the warning anyway and looks like good practice.
It also makes it possible to verify the conformance of the class to the
interface::
>>> from zope.interface.verify import verifyClass
>>> from mypackage.interfaces import IFoo
>>> from mypackage.foo import Foo
>>> verifyClass(IFoo, Foo) # doesn't raise
An added benefit is that setting defaults at the class level seems more
readable than setting them in the __init__,
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
iD8DBQFGJjyN+gerLs4ltQ4RAmV4AJ9fByNoslrbb3/5o0MsiMzgQ03KqQCg2M8B
rhvFt/vswMsOHp2hmmmjKI8=
=IMWq
-----END PGP SIGNATURE-----
More information about the z3-five
mailing list