Stephan Richter wrote:
> In addition there is the FieldProperty class, which can be used to enforce a
> value. I have recently started to use it all the time. I really like it too.
It also sets the attributes to the default values inside the tests,
taking them from the interface definition instead of the class definition..
class MyObject:
implements(IMyObject)
what = 42
vs.
class IMyObject(Interface):
what = Int(title=u"Whatever",default=42)
class MyObject:
"""
>>> from zope.interface.verify import verifyClass
>>> verifyClass(IMyObject, MyObject)
True
Try changing the attributes:
>>> obj = MyObject()
>>> obj.what
42
>>> obj.what=56
>>> obj.what
56
"""
implements(IMyObject)
what = FieldProperty(IMyObject['what'])
_______________________________________________
Zope3-users mailing list
[email protected]
http://mail.zope.org/mailman/listinfo/zope3-users