On Sun, Mar 7, 2010 at 6:36 AM, Mark <[email protected]> wrote: > I'm sorry guys, maybe it's just me, but I'm having tons of problems > with my forms: > > I have a new() and create() just like what the book says. My new() > action basically just renders my form. My create() action is as such: > > @validate(schema=NewClassForm(), form='new', post_only=True, > on_get=True, auto_error_formatter=custom_formatter)
Try it with just the 'schema' and 'form' arguments first and see if that works. > def create(self): > """ > Add a new class with sessions and save it to the database > """ > > My Schema is the following: > > class NewClassForm(formencode.Schema): > allow_extra_fields = True This allows the input to contain fields not mentioned in the schema. (Otherwise it would be a validation error.) > filter_extra_fields = True 'False' copies the extra fields to 'self.form_result'. 'True' suppresses the extra fields (does not copy them to 'self.form_result'). > pdb.set_trace() I don't know how this behaves in a Pylons controller or validator. If you have a custom validator (maybe make a dummy pre_validator using FancyValidator), you can put 'raise RuntimeError' in it, which will hopefully give you an interactive traceback. That will prove the validator is being run (and thus that the route routed to the 'create' method). You can't put it in the 'create' method itself because we're still in the decorator code. To debug routes, add the following to your INI file: [loggers] keys = root, routes, ... [logger_routes] level = DEBUG handlers = qualname = routes.middleware # "level = DEBUG" logs the route matched and routing variables. I have the following in my INI too, I don't remember why: [logger_decorators] level = WARN handlers = qualname = pylons.decorators Setting that to DEBUG may show something useful. -- Mike Orr <[email protected]> -- 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.
