Sounds good. I have created ticket #1314 http://trac.turbogears.org/ticket/1314 with an attached patch (which also contains a test case) that does not break any of the existing tests. (I had to tweak it slightly to handle MultipleSelectFields, but it seems to work now.)
Thanks again for helping me think through this. -Rick On Mar 5, 8:48 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > On Monday 05 March 2007 14:40, Rick wrote: > > > First off, thanks for the insights into the design philosophy of TG > > widgets. OK, let me see if I can recap what you are saying. The > > current implementation of _is_option_selected assumes that the "value" > > in the options list [(value,desc,options)] is a Python value, but the > > current implementation of the select field templates do not correctly > > render that value into the template using the decorator's from_python > > method, making it difficult to impossible to pass complex Python > > values in the options list. > > Yes, that sounds correct to me. > > > > > In that case, let me suggest that the SelectionField.update_params() > > method be updated to actually use the validator's from_python method > > to render the values into the template. I have included below a > > version of the method which does just that. Unfortunately, this alone > > does not fix the problem. Now, when update_params calls > > is_option_selected, it is comparing two Python values (one from the > > list, one from the value passed into the form). So in this case, it > > seems that is_option_selected should skip the conversion step, since > > it is comparing two Python values. > > > I have included monkey-patched versions of these two methods that seem > > to give the desired behavior (passing Python values in the options > > parameter, correctly rendering python values to the form using > > from_python, and correctly determining which one is selected when > > displaying/rendering the template). I've also included a fixed > > version of my test controller method that works with these patches > > fine. Do you see any problem with applying patches (real ones, > > obviously, not these monkey-patches) to turbogears/widgets/forms.py? > > It does sound reasonable, yet I'm pretty sure it will break existing code. > Which would disqualify it for anything but a new release, one or even a few > versions from now. > > I suggest you try and get one of the core developers to comment on this - > either explicitly, or via submitting a bug. > > 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 -~----------~----~----~----~------~----~------~--~---

