[Grok-dev] class-level versus instance-level attributes for schema

Martijn Faassen faassen at infrae.com
Fri Oct 20 04:02:31 EDT 2006

Hi there,

I see now that the __new__ in the schema support is gone. Reading the 
code, I see that the attributes for the fields are added on class-level 
instead of on instance-level. I wonder whether we can or should change this.

The current approach has the benefit of:

* no __init__ necessary, so you can write your own

An instance-level approach has the benefit of:

* instance-level attributes are more inline with normal Python 
approaches. class-level attributes are relatively rare.

* we could hook in an __init__ that takes the schema names as (optional) 

But we'd need to poke in a custom __init__ into the class during 
grok-time, which could be considered icky (then again, poking in 
class-level attributes could be considered as icky as well).



More information about the Grok-dev mailing list