I have a dict-like field which I store as a string in my model and I want this field to appear as a FieldSet in my form. The string->dict conversion is a one-liner in regular python, so it should be easy to do it in Turbogears. Or so I thought.
The obvious thought was to try to stick a from_python() in the field's validator in order to convert it from string to the dict expected by the FieldSet. To make a long story short, this didn't work. After digging in the internals, it turns out that CompoundInputWidgets call a magic undocumented dictify_value() function which is supposed to know how to turn a value into a dict, before from_python() has any chance to look at it. So the quick & dirty workaround that eventually worked was to subclass FieldSet and override dictify_value() to do what from_python() is supposed to do. I hope there is a more obvious solution, or at least an update in the docs if that's the right (or only) way to do it. George <rant>Considering the frustration and the overall time I've spent reading the docs, trying to do the simplest tasks or figuring out WTF is wrong every time, I almost regret not going with plain cherrypy +genshi; hell, even PHP looks more appealing. Sure, less DRY and more stuff to write on your own, but at least you don't waste days trying to grok all the magic metaclasses, decorators, generic methods and the rest mumbo jumbo under the hood when things don't work. </rant> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

