With chameleon I don't think the subscriber is as useful just because of
how it works versus the more "automatic" inheritance of mako.

I mentioned the BeforeRender subscriber as a way to do stuff you might've
done in your view callable with the user object. The advantage of the
subscriber is that it's called every time a view is rendered, so if you
have to repeat some code in each of your views it might belong there. For
example if you needed a URL to your home page in your base template, you
could inject that url into the template globals from the subscriber and not
have to worry about it.

On Tue, Nov 29, 2011 at 10:36 AM, Mark Erbaugh <m...@microenh.com> wrote:

> Michael,
>
> Thanks. I'd forgotten that the request object is available, so I don't
> need to pass my user object.  I've been working with Pyramid for several
> months now and I'm finding that stuff is "still sinking in" and I'm able to
> simplify things. This is yet another <g>.
>
> I don't understand the purpose of the BeforeRender subscriber if the
> template can already get the user object from the request object.
>
> Mark
>
> On Nov 29, 2011, at 10:46 AM, Michael Merickel wrote:
>
> The request object is already available in the template so you don't need
> to pass it in at all. Personally I'd say the only reason to pass things in
> explicitly from the view dict would be if you wanted to do some
> pre-processing on any of the object fields. For something like a user
> object that's probably being used in your global template it may be useful
> to use a BeforeRender subscriber to inject those values "all the time".
>
> On Tue, Nov 29, 2011 at 9:31 AM, Mark Erbaugh <m...@microenh.com> wrote:
>
>> I've followed one of the recipies in the Pyramid cookbook to include a
>> user object in the request object. The application uses the user object to
>> store persistent information about the current user. The application uses
>> Chameleon templates and those templates use fields from the user object to
>> complete the template.  Should I extract the fields needed from the user
>> object in my view callable and pass those in the dict to the renderer or
>> just pass the user object itself and let the template extract the needed
>> fields?  I prefer the later as it gives me more flexibility in changing the
>> template without having to change my view callable, but I wonder if there
>> is a significant performance penalty?
>>
>> Thanks,
>> Mark
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "pylons-discuss" group.
>> To post to this group, send email to pylons-discuss@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.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To post to this group, send email to pylons-discuss@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.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To post to this group, send email to pylons-discuss@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.
>



-- 

Michael

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@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