On Sun, May 30, 2010 at 10:38 PM, Krishnakant Mane <krm...@gmail.com> wrote:
> On Monday 31 May 2010 02:30 AM, Ben Bangert wrote:
>>
>> On May 30, 2010, at 12:09 PM, Wyatt Baldwin wrote:
>>
>>
>>>
>>> Pylons injects a few things into the template context for you along
>>> with `h`, including (off the top of my head) `url`, `config`,
>>> `request`, and `response`. You don't need to prefix any of those with
>>> `h.`.
>>>
>
> Thanks Ben.
> I always used h. prefix so was confused if the same is needed in version 1.0
> like it was in 0.9.7

'url' is a different thing than 'url_for'.  'url_for' was imported
from Routes into helpers.py, while 'url' is provided by Pylons. That's
why it's in a different location. You can import 'url' into helpers.py
and then it will be under 'h', but it's not necessary to do that, and
not particularly desirable.

As Ben said, 'url_for' depended on a global singleton in Routes.
'url' is initialized a different way. The RoutesMiddleware parses the
request and puts the routing variables in the environ, and it also
creates a URLGenerator instance which it puts in the environ. Pylons
picks up the URLGenerator instance and puts it onto 'pylons.url'.

Regarding your other questions, I wonder if you're thinking back to
the 0.9.6 -> 0.9.7 upgrade.  The "some change in the way we call the
web helpers" was in 0.9.7. In 0.9.6, the rails helpers were imported
into helpers.py by default.  In 0.9.7, you had to explicitly import
whichever helpers you wanted into helpers.py.  This is unchanged in
1.0.  Some helpers have moved in WebHelpers 1.0rc1 compared to
WebHelpers 0.6.4, but this would have already affected your 0.9.7
application if you've upgraded WebHelpers recently.

"Some imports are also additional in the controllers" was another
major change in 0.9.7.  In 0.9.6, all the controller defaults were in
base.py, and imported in the controllers with "import *".  In 0.9.7,
things are imported into the controllers directly. This is also
unchanged in 1.0.  However, a few specific names have changed: g ->
app_globals, c -> tmpl_context, the new variable 'url', redirect_to ->
redirect, etc.

-- 
Mike Orr <sluggos...@gmail.com>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-disc...@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to