Shane, I considered 'default_factory' myself.... It seems good, but it complicates the logic internally. For one thing, logically, we'd have to also have 'missing_value_default' (unless we decree that missing values have to be not-non-immutable, ah... immutable).
A further thought on where to put "filling in of defaults code" -- this should probably be a separate routine in zope.schema: setDefaults(instance)", which would set defaults (and validate? -- or maybe call it "setDefaultsAndValidate"). - Shaun PS anyone have idea or best practice on how to best through attributes, avoiding shadowed ones? Seems like this is generally useful for introspection of metadata. -----Original Message----- From: Shane Hathaway [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 24, 2006 12:39 PM To: Shaun Cutts Cc: zope3-dev@zope.org Subject: Re: [Zope3-dev] zope.schema: defaults for non-immutables... questions 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