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
--
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.