W dniu poniedziałek, 2 września 2013 13:57:24 UTC+2 użytkownik Paul Everitt 
napisał:

> On 9/2/13 6:51 AM, Marek Szwałkiewicz wrote: 
> > Hi all, 
> > 
> > in current project I need to include 2 form objects (flatland forms) in 
> > context of almost every template. 
> > 
> > Those 2 objects are used in master template (that is inherited 
> everywhere) 
> > and need to be available in almost all cases. 
> > What is a best way to include those objects (except from manually 
> including 
> > it in every view return dictionary)? 
>
> Arrange for a callable, available in your templates, that will return 
> the forms to you. Two classic ways to do this: 
>
> 1) BeforeRender event. Write something that subscribes to the 
> BeforeRender event and, on each request, assigns something to the request. 
>
>
> http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/hooks.html#using-the-before-render-event
>  
>
> 2) Request method. Grab the configuration and add a method to the 
> request. The method could return a callable, a mapping, whatever. 
>
> Here is an example of adding a custom request.get_user request method 
> that could be called from your template. 
>
>
> http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/auth/user_object.html
>  
>
> --Paul 
>

I'm using request method now as a temporary measure, in the end I don't 
want to access some forms from request and some from context, as it may be 
confusing to other people when they read my code. I Think that 
pyramid-layout that tonthon mentioned will be ideal fix for my problem, 
more explicit then packing something in request.

Thanks for suggestions,
best regards,
Mark

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to