[Zope3-Users] Automatic schema field sanitation?

Christian Klinger cklinger at novareto.de
Tue Dec 2 09:02:49 EST 2008


Hi Dennis,

i think you can try to add a new Field and a corresponding Widget for
your needs.

I think this could be a good starting poing.

http://wiki.zope.org/zope3/fieldsandwidgets.html

If you have further questions - please ask.

Hope this helps.

- Christian


> Hi,
> 
> I would like to define a custom type inheriting from
> zope.schema.TextLine, which in addition to having a built-in constraint
> method also sanitizes the input.
> 
> For example suppose you need to store codes of the kind: 3 letters,
> space, 3 numbers.
> 
> The constraint uses a regexp, and this works fine.
> 
> However it would be nice if I could also automatically capitalize the
> letters, such that "abc 123" is stored as "ABC 123" which is the
> presentation that should be used everywhere. Being able to do this
> automatically, just like the validation, would completely remove the
> need to remember to sanitize on input/output throughout the rest of the
> system.
> 
> What would be the best way to implement this, ideally without needing to
> modify any of the standard zope.interface/zope.schema code?
> 
> Thanks for any suggestions,
> Cheers,
> Dennis



More information about the Zope3-users mailing list