views:

444

answers:

1

I'm working in pylons with mako, and I'd like to create forms and validations with FormEncode for several parts of my application. I can't seem to find any good examples of the whole process. My question is twofold:

Technical

  • FancyValidators and Schemas - Their relationship and syntax
  • Pylons controllers and mako templates - how to collect, handle, and validate the data

Stylistic

  • Best practices for controller methods
  • Easing the reuse of forms (for update vs create, for example)

So if you know of any complete examples, it would be much appreciated. I would think this would be a common combination with more examples/tutorials out there.

+1  A: 

I don't know if you've gone through the pylons book, but I found chapter 6 to be very thorough in regards to forms.

As far as best practices go, I'm not exactly sure what you are looking for. A controller method maps to a url and needs to return a string-like object. How you arrive at that is largely application specific and you are free to choose how you structure the application.

For form reuse, I don't know if it would be considered a best practice but tw.forms I find pretty useful for just that (and toscawidgets for general html snippet reuse). If you anticipate having to reuse fields in forms, you may have some success with fieldsets.

If you are looking for complete examples, I would consider turbogears2 a good resource. It's built on top of pylons so any information on tg2 is equally applicable to pylons.

You can also look at the reddit source code

And finally, someone will suggest django. :)

Tom Willis