[Grok-dev] it is really necessary to use __new__?
Philipp von Weitershausen
philipp at weitershausen.de
Thu Oct 19 11:21:43 EDT 2006
Christian Theune wrote:
>
> Philipp von Weitershausen wrote:
>> Martijn Faassen wrote:
>>> Hi there,
>>>
>>> I think it'd be a valuable if we could keep grok base classes as free
>>> of magic as we can. Instead, our magic should be done during grokking.
>>> Therefore I'm asking whether it's really necessary to add a __new__ to
>>> grok.Model? Couldn't it pull out the fields during grok time?
>> It's not setting fields, it's setting default values (None) on the
>> instance. Apart from the question whether something could be done at
>> grok time or not, I wonder why it does that. It's not necessary for
>> instances to have the attributes that are edited in an EditForm.
>
> It's not? I always encountered formlib to fail on editforms if the
> instance doesn't have the attributes. And so did Wolfgang.
Hmm, could be that I'm remembering something wrongly here. However, I
think that behaviour is stupid. I'm pretty sure it didn't exist with the
old style zope.app.form forms.
Of course, it would also be possible to set those values as class
attributes during grok time. I think I'd slgihtly prefer that over the
__new__ magic.
Philipp
More information about the Grok-dev
mailing list