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

Christian Theune ct at gocept.com
Fri Oct 20 04:06:47 EDT 2006



Martijn Faassen wrote:
> 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)
> arguments.
> 
> 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).

Another option might be to change formlib's behaviour and allow editing
instances which don't have the attribute set yet (and use the default
instead). This requires further input from zope3-dev though.

Christian


-- 
gocept gmbh & co. kg - forsterstraße 29 - 06112 halle/saale - germany
www.gocept.com - ct at gocept.com - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20061020/936cc979/signature-0001.bin


More information about the Grok-dev mailing list