[Grok-dev] it is really necessary to use __new__?

Wolfgang Schnerring wosc at wosc.de
Fri Oct 20 02:45:43 EDT 2006

* Martijn Faassen <faassen at infrae.com> [2006-10-19 16:57]:
> 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 could. I went the __new__ route because... I don't actually know
why. I think the reasoning somewhere back in my mind went like, "hey,
I'm seriously modifying the class here, that should be done as early
as possible so as not to expose it in an inconsistent state". But
since, actually, using grokked packages without grokking them is not
supported right now anyway, doing this at grok time is way better.

* Philipp von Weitershausen <philipp at weitershausen.de> [2006-10-19 17:11]:
> 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.

Well, Formlib blew up on me big time, so I think it *is* necessary.


More information about the Grok-dev mailing list