On 21/06/2006, at 10:20, samuraisam wrote:

>
> I think this:
>
> 1    def _get_sample_option(self):
> 2        if self.options:
> 3            if isinstance(self.options[0][1], list):
> 4                sample = self.options[0][1][0]
> 5            else:
> 6                sample = self.options[0]
> 7            return sample[0]
> 8        else:
> 9            return None
>
> is the culpirt. I'm not super duper knowledgible about TurboGears yet,
> but it looks like it digs into options without checking if it's
> callable first. So, I'm guessing Alberto Valverde was right in  
> pointing
> out the validation guessing. But still, I got the same error as posted
> above with or without specifiying validation. Perhaps it does not  
> check
> elsewhere, too.

This is weird.... A little (very little) investigation shows that  
_get_sample_options is only called from _guess_validator (http:// 
trac.turbogears.org/turbogears/browser/branches/1.0/turbogears/ 
widgets/forms.py#L727)
and _guess_validator is *only* called if bool(widget's validator)  
evaluates to False (http://trac.turbogears.org/turbogears/browser/ 
branches/1.0/turbogears/widgets/forms.py#L710)

Maybe the check "not self.validator" is not enough... can you try to  
provide a validator and change that check to "if self.validator is  
None" see what happens?

I'm sorry but I'm very busy to investigate this myself ATM :( so any  
help would be greatly appreciated :) (maybe send me a the smallest  
chunk of your app that can reproduce the problem?)

> Using turbogears.utils.request_available worked good, though:
>
> def get_blogs():
>     if request_available():
>         return [(blog.id, blog.title)
>                 for blog in
> identity.current.identity().user.authorships]
>

This is a rather hackish solution IMO, callables listed at  
"params" (SingleSelectField's "options", for example) should only be  
called when rendering/displaying a widget. I think it's better we  
solve the root of the problem sooner or later, though I understand  
the fix is good enough to keep you running... :)

Alberto

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to