Shaun Cutts wrote:
It would seem that the current default mechanism is poorly suited to providing default values for non-immutables. For example:

"Mutable" is a better way to say "non-immutable". :-)

class IBar( Interface ):

    a = Object( schema = IFoo, default = Foo() )

But if a “Foo” is not immutable this doesn’t make sense. (In my case, I want “a” to be a collection providing IFoo, which defaults to an empty collection. Each Bar implementing IBar should have its own instance of Foo.)

I've run into this myself.  How about:

a = Object(schema=IFoo, default_factory=Foo)

?

Shane
_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to