[Grok-dev] Re: Interaction between schema fields and properties

Martijn Faassen faassen at startifact.com
Thu Jul 5 10:12:20 EDT 2007

Luciano Ramalho wrote:
> The Kirbi Book class has a field for the ISBN. I'd like to accept user
> input in either ISBN-10 or ISBN-13 format, but always store it
> internally as an ISBN-13.
> My Book class uses the Grok fields inner class idiom. I tried to
> create a property with the same name as the ISBN field, so that a
> setter method would be invoked to do the ISBN-10 to ISBN-13
> conversion, but the setter method is not being invoked (I suppose the
> fields declaration overwrote my property).
> How can I define a custom setter for a field using the fields inner
> class approach?

I think the grok 'fields' inner class idiom is deprecated. It was an 
early approach but I see too many things wrong with it - subclassing 
doesn't work for instance. I'm not sure what goes wrong here, but this 
is more evidence for them being too magic and too limited.

I haven't been using the inner 'fields' class, and we should perhaps 
decide to take it out entirely (and definitely not document it). What 
are people's opinions about this?

If you use a separate schema you can simply use a normal Python property.



More information about the Grok-dev mailing list