On Jun 29, 2006, at 3:05 AM, samuraisam wrote:

>
> I have a validator:
>
> class Blog(validators.FancyValidator):
>     def validate_python(self, value, state):
>         value = int(value)
>         if not value:
>             raise validators.Invalid(self.message('blogNotExists',
> state),
>                                      value, state)
>         blogs = _get_user_blogs()
>         if not blogs:
>             raise validators.Invalid(self.message('noBlogsYet',  
> state),
> value,
>                                      state)
>         elif value not in blogs:
>             raise validators.Invalid(self.message('notYourBlog',
> state),
>                                      value, state)
>         return value
>
> Here is the relevant form widget:
>
> blog = widgets.SingleSelectField(label="Blog", options=get_blogs,
> validator=sbvalidators.Blog(), default=_get_blog_id)
>
> The validator was working yesterday. I am not sure what it was, but  
> all
> of the suddon it sipmly _stopped_ working. It gets called when I start
> the server, but never during validation. It seems to not only be this
> validator, either. I have created ones that do nothing but raise an
> exception and they still do not work, what-so-ever. I have tried
> putting them in _to_python, _from_python, validate_python, etc (pretty
> much every hook in the formencode documentation). Does someone have
> experience with this problem? Can anyone suggest I try anything?

Damn Heissenbugs ;) I can only suggest to try what usually do to  
create my validators, that is, overriding to_python and calling super  
cooperatively before my own validation:

def to_python(self, value, state=None):
        value = super(MyValidator, self).to_python(value, state)
        .....

Not sure if it's the best approach but "Works For Me ®" :)

Alberto

P.S. Just to know what we're looking at: which version of TG are you  
using?
--~--~---------~--~----~------------~-------~--~----~
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