On Tuesday 18 August 2009 10:07:31 [email protected] wrote: > hi diez, > > thanks for your consideration. > > On Tue, Aug 18, 2009 at 09:58, Diez B. Roggisch<[email protected]> wrote: > > [email protected] schrieb: > >> hello friends, > >> > >> i am building a form based on the parameters to the controller, and i > >> need to also call the same controller as an error_handler. > >> how could the error_handler receive parameters based on the submitted > >> form values? > >> of course, reading the form values would be enough (instead of receiving > >> them as parameters). > > > > I'm not entirely sure what you mean here - building a form on the fly > > isn't to great of an idea with current TW, as that is going to produce > > memleaks. > > i'd like of course to learn about these mem leaks, to know how to avoid > them. i'm building a widgetlist on the fly, with widgets of types and > quantity determined by data.
THe problem ist with the so-called request-values. These are used to store the form-input-values for validation. To fix a bug that caused overlapping namespaces for more than one form per page to collide, I had to introduce a segmentation based on id of the widget - *unfortunately* not the TW-widget-id, but the "real" object id. As a consequence, creating new widgets all the time will create entries in this thread-local storage. I will definitly put some work into this very soon, as I consider it a wart - but until then, be warned. You can fix that yourself though, by cleaning the request-local storage yourself on request-ingress via a middleware. So there is a fix available if this really brings you troubles. > > However, what you can do is you can pass an object with a > > validate()-method to the @validate-decorator. Then in there, you can > > access tg.request.params to build the same form for validation. > > so you suggest tg.request.params has the params of the request. are they > passed to the error_handler method? how else does it populate the fields? No, you can access the request through from tg import request Then you should be just invoking validate on the created form. = > > now for the question i didn't ask, though i should have: > can the @validate form be built on the fly too? i was previously thinking > to build a form with all possible fields, that's a definitely suboptimal > solution. Well, of course it can, if your building is parametrized by things you can pass through hidden form-fields. Diez --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

