Hi eleith,

How about following using validator instead?

class AtLeastOne(ForEach):
     validator = Int
     def _to_python(self, value, state=None):
         value = super(AtLeastOne, self)._to_python(value, state)
         if len(value) < 1:
             raise Invalid("at least one item must be selected",
value, state)
         return value

I got same error before, and found the following post.
http://groups.google.com/group/toscawidgets-discuss/browse_thread/thread/a5bf406e8d63c739?tvc=2&q=MultipleSelectionMixin&pli=1



On 1月26ζ—₯, 午後7:33, eleith <[email protected]> wrote:
> for my schema, i want to handle
> ----------------------------------------
> delete?id=100
> delete?id=100&id=101&id=102
>
> and throw an error for
>
> delete?
> -----------------------------------------
> my validators look like this:
>
> id = ForEach(Int(), not_empty=True, convert_to_list=True)
>
> however, this passes when even when i don't pass in an 'id'
>
> i've even tried
>
> All(NotEmpty(), ForEach(....))
>
> that doesn't work either. i've ended up writing my own function and
> subclassing into SimpleFormValidator to handle this case for me (i
> just check if the len(values['id']) < 1, and return an error message)
>
> so either i'm going about this the wrong way, or there is an error in
> ForEach and/or All.
>
> any suggestions? (although, i'm happy with my solution, just thought i
> would publish my findings)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to