On Wed, Jan 7, 2009 at 1:05 PM, mk <[email protected]> wrote: > > Hello everyone, > > I'm really new to Pylons, so could someone please help me clear some of > the confusion with the following stuff? > > I'm trying to access global h variable in Pylons 0.9.7, mainly for sake > of getting at url_for function. > > But h var seems to be available only in Mako templates and not the > controller code (at least in 0.9.7). > > http://wiki.pylonshq.com/display/pylonscookbook/Routes+for+people+in+a+hurry > contains example of using h variable without quoting the context, but it > may look like controller code (or routing.py). > > So my question is, what is h variable mainly for? Should I use it in > (mainly or only in) templates or are there uses for it in controller > code? If so, how to access it there?
h stands for helpers, and it's a couple of functions provided by pylons, webhelpers and your own /lib/helpers.py file. as for using them (helpers, not h) on the controller what I do is simply import it, either from webhelpers or your lib/helpers.py As for url_for I think you are breaking MVC a little here, why will you want the URL for another part of your site in the controller? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
