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)


Zope3-dev mailing list

Reply via email to