On Jul 29, 2006, at 11:40 PM, Jason Chu wrote: > On Sat, 29 Jul 2006 12:29:13 +0200 > Alberto Valverde <[EMAIL PROTECTED]> wrote: > >> 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 > > It's only the case where options are a callable that things are > ambiguous. If I create a SelectField with a list of ints as the > options, I'm pretty sure I want the validator to be for a list of > ints. Is that really ambiguous? > > It's only because callables are automatically executed that we run > into > this problem.
Ok, I'm attaching a patch to avoid guessing when "options" is a callable for review (as I have a recent history of bumping into test- case's blinds spots... hope I don't break anything... someone please try it in a real app ;) ) Basically it'll make SelectionFields bark if no validator is explicitly declared when "options" is a callable. However, I'd prefer to avoid guessing altogether because I feel that the widget should be agnostic as to wether the params are being provided "as-is" or freshly fetched by a callable, now the ParamDescriptor elegantly hides that fact IMO. However, I have no problem in adopting a solution like the one in the patch :) 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 -~----------~----~----~----~------~----~------~--~---
no_guessing_4_callables.diff.gz
Description: GNU Zip compressed data
