On Wed, Oct 10, 2012 at 11:41 PM, Craig Small <[email protected]> wrote: > On Sat, Oct 06, 2012 at 12:42:02AM -0700, Mengu wrote: >> afaik url method takes two parameters. one for the url and one for the >> query string. so you can pass all your parameters in a dict. > > Is there also the "other end" function somewhere in turbogears? > Pretty much every page I have uses some common options, for example > start/stop times. > > Rather than having to write this for every page is there a place I can > put it once and every widget on every page knows its been sanity checked > (e.g. stop times are "later" than start times) >
There are various ways to achieve this. Which one to use depends on various conditions :) 1) You can register a before_call/before_render/before_validate hook in config/app_cfg with app_config.register_hook 2) You can add your check into BaseController.__call__ inside lib/base.py, which gets called on each request. 3) You can subclass BaseController, add a _before method and let all your controllers descend from it. _before will be called before calling any exposed method of the subclass. I would suggest going for the third as instead of being called always, gets called only for controllers that inherit from your newly created controller, making it both easy to enable or disable the behavior for each controller. -- 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.

