Almost there but no cigar. I am having a small problem seeing the
Invalid message being fired:

class ValidateDates(formencode.FancyValidator):
    messages = dict(invalid="Bad date")
    def validate_python(self,field_dict,state):
        print "%s" % field_dict['combomonth']
        print "%s" % field_dict['comboday']
        month=field_dict['combomonth']
        day=field_dict['comboday']
        msg = self.message('invalid',state)
        raise formencode.Invalid(msg,field_dict,state,
                                        error_dict=dict(month=msg))

class ValidateCompleteOrder(formencode.Schema):
    allow_extra_fields = True
    filter_extra_fields = True

    combomonth= formencode.validators.String(not_empty=True)
    comboday= formencode.validators.String(not_empty=True)

    print "source id is %s" % id

    chained_validators =[ValidateDates()]

    @restrict('POST')
    @validate(schema=ValidateCompleteOrder(),form='order')
    def completeOrder(self,id):
         mon= request.params.get("combomonth")
         day= request.params.get("comboday")

I see that within the FancyValidator Class that its getting the
correct values. I am trying to force the Invalid Message
to be issued. Instead I see:

I am seeing NotImplementedError: Action 'order' is not implemented.

Much appreciated,
Garyc

Any ideas on what I could be doing wrong here?
On Feb 5, 10:21 am, gazza <[email protected]> wrote:
> Marvelous, Extremely happy using my own bespoke validators, oh boy
> this is great. There is some fine black magic stuff
> happening with that fancyValidator. Cool. Yes I had to use a
> chained_validator.
>
> Utter Glee.
>
> Cheers,
> Garyc
>
> On Feb 4, 5:32 pm, Ian Wilson <[email protected]> wrote:
>
> > I think this is what you are looking for.  Two values are pulled from
> > the field_dict.
>
> >http://bitbucket.org/gjhiggins/shabti/src/tip/shabti/templates/authpl...
>
> > You might need to put this validator in chained_validators.
>
> > On Thu, Feb 4, 2010 at 3:09 PM, gazza <[email protected]> wrote:
> > > Hello,
>
> > > I guess what I am trying to say is how do you pass multiple values
> > > from a form at the same time to a FancyValidator class?
>
> > > Essentially I would like to pass two values that entered in the form
> > > and both are required for validation.
>
> > > Any help on this would be appreciated. I see good example on single
> > > fields, just dont see how the multiple fields are dealt with.
>
> > > Much appreciated,
> > > Garyc
>
> > > On Feb 4, 12:22 pm, gazza <[email protected]> wrote:
> > >> Hello,
>
> > >> I am having a problem understanding how I can pass multiple values at
> > >> once to the fancy validator i.e month and day
>
> > >> class fooFancyValidator(formencode.FancyValidator):
> > >>         messages = {
> > >>                   'invaliddate' : _("Please select a valid date")
> > >>           }
>
> > >>          def _to_python(self,value,state):
> > >>                if (not value):
> > >>                   raise Invalid(self.message('invaliddate', state),
> > >> value, state)
> > >>                print "enter _to_python %s" value
>
> > >> class ValidateDate(formencode.schema):
> > >>          allow_extra_fields = True
> > >>          filter_extra_fields = True
>
> > >>          month = fooFancyValidator()
>
> > >> I need multiple values to be validated at the same  time? i.e month
> > >> +day=fooFancyValidator,maybe a chained_validator? Not sure.
>
> > >> Thanks,
> > >> Garyc
>
> > >> On Feb 4, 10:05 am, Graham Higgins <[email protected]> wrote:
>
> > >> > -----BEGIN PGP SIGNED MESSAGE-----
> > >> > Hash: SHA1
>
> > >> > On 4 Feb 2010, at 15:41, gazza wrote:
>
> > >> > > I am trying to find a simple example to create a bespoke validator.
> > >> > > Could you somebody be so kind and point me to an article to 
> > >> > > accomplish
> > >> > > this in pylons?
>
> > >> > Not an article but a few examples, FWTW (some shamelessly stolen from
> > >> > Ben Bangert's code for Kai, the Pylons app that runs PylonsHQ):
>
> > >> >http://bitbucket.org/gjhiggins/shabti/src/tip/shabti/templates/authpl...
>
> > >> > Cheers,
>
> > >> > Graham
>
> > >> >http://www.linkedin.com/in/ghiggins
>
> > >> > -----BEGIN PGP SIGNATURE-----
>
> > >> > iEYEARECAAYFAktq8EsACgkQOsmLt1NhivyGBACeKuycOBuKBdYR9PIne5JXW7mO
> > >> > WykAnAn8sJJK+YUs/x1dorRCwS9WhmkbiQCVAgUBS2rwS1nrWVZ7aXD1AQIWzAQA
> > >> > sa2/CzpUSwSNypR2ipXf8+iP34Kl7dwHF1CfCPoZRdqNcESo8mtN7KPCuZiYkkyN
> > >> > lY3WM+CZQ3pWtuPX/wl8w86M0rOgheXxxvRI6D88IUzpj8B6BvB9Jdt1JrCK9GyX
> > >> > /KhHmqAxzFkFQo73WGP54KZ6GtdaFFD82yHcYuYqiAs=
> > >> > =Lyu3
> > >> > -----END PGP SIGNATURE------ Hide quoted text -
>
> > >> - Show quoted text -
>
> > > --
> > > 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 
> > > athttp://groups.google.com/group/pylons-discuss?hl=en.-Hide quoted text -
>
> > - Show quoted text -

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