On Jul 29, 2006, at 11:16 AM, Max Ischenko wrote:
> >> On Jul 28, 2006, at 4:11 PM, Max Ischenko wrote: >>> Looks like I stumbled upon another backward-incompatibility issue >>> in 0.9a8: if options is callable it gets called at ctor time (it >>> was not called before, unless no validator was also given). >> >> This is because it tries to guess a validator if no one is given. >> Maybe this guessing behaviour should be removed? I'm +1 for it. > > Have you read the code? I believe it's for a different reason, > unrelated to validator (hint: it fails in meta.py:ParamDescriptor). Sure, I wrote some of it too ;) Order of events: 1) _guess_validator is called at __init__ (forms.py:712) 2) _get_sample_option is called at _guess_validator (forms.py:732) 3) _get_sample_option tries to access "self.options" which is "guarded" by a ParamDescriptor that does the caling of callabe params to return a fresh value on each access. So yes, it's related to validator guessing ;) (someone was aso bitten my this behaviour about a month precisely by mixing Identity/Options- for-selection-field). I think the best solution for this would be to avoid guessing altogether as it'll will follow the "In the face of ambiguity, avoid the temptation to guess" PyZen principle and make this validator default to a String if no one is given. However, it would break some existing code until it's fixed with an explicit validator. Opinions? Hope I've made it clearer, Alberto --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears Trunk" 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-trunk -~----------~----~----~----~------~----~------~--~---
