El 02/07/12 17:17, Chris McDonough escribió:
On 07/02/2012 11:13 AM, Antonio Beamud Montero wrote:
Hi all:
I want to have the inbox messages number associated with a user always
available.
What's the best way to do this?. As I can read in documentation, I can
accomplish this with:
- adding a property to the request with 'set_request_property', like:
myconf.set_request_property(calculate_user_inbox, 'inbox')
- Using an event suscriber:
myconf.add_subscriber('myapp.calculate_user_inbox_suscriber',
'pyramid.events.NewRequest')
- Using the beaker session.
What's the pros and the cons?
You haven't described what's wrong with just calling
"calculate_user_inbox" from view code without involving any of the
above things. I doubt there can be any reasonable discussion of pros
and cons without understanding why you're trying to involve framework
machinery in the first place.
- C
The inbox number is shown in the header of the site. This header is
defined in a template which is inherited by the other templates.
I'm using pyramid_handlers to group the views. Then, to make this method
accesible to the header template, I need to pass in all view methods,
and this is ugly.
Then if I can access as a request property (via suscriber or property),
like
<a href='...'>Inbox (${request.inbox_number})</a)
can be the cleanest way...
Thanks and pardon my ignorance.
--
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.