iain duncan wrote: > > Why would make so great that the form was defined inside "index"? > > Keep in mind that the form would have to be initialized on every > > request instead of just once on "compile" time... If you need to > > reuse fields for similar but different forms you can define common > > fields in a WidgetsLists (or a plain ol' python list) and concatenate > > them as needed. > > I put my forms and my custom validators for them in a separate file so > they can be imported from my controller file. This keeps the controllers > short and clean with nothing but controller logic in them without a lot > of clutter in the controller file, and puts all the related info for the > forms, what they have, where they go, how they should be validated, in > one file. If you put python executable code in that module, it will be > executed on import in case of any special initialization needs, and your > forms are in a convenient file for reuse in other projects. > > If I'm off base on that approach I'd like to know though! > Iain
You're perfectly "on the rails" with that approach :) Even more, if the widget is of enough common-use (like the inexisting "star-rater" which was discussed a few days ago ;)) you can pack it along with it's related javascript, css, valiators, etc... into an egg and easily reuse it in any TG app. BTW, widgets have been refactored out from TG into TGWidgets (http://tgwidgets.toscat.net) and will not ship with FirstClass (TG 1.1) anymore. This means that a widget written for TGWidgets could be reused in *any* WSGI compliant python web-app :) Alberto --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---

