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

I would probably drop it in the session variable , or add an object to
your request property that you stash multiple values in.

- The request object tends to have a lot of attributes on it that are
critical to Pyramid.  Being a bit aggressive about safety and
collisions, I personally prefer to create an private namespace on it,
and then stash everything in there.   So instead of request.inbox , I
would prefer request.antonios_app.inbox -- and then have that nice
private space for anything else my app needs.

- myconf.set_request_property and myconf.add_subscriber are
essentially two execution hooks you can use to handle the logic/
calculation.  IIRC , you could use the add_subscriber to manipulate
the session object ( you can definitely use it to manipulate the
request object ).

- if you're using class-based Pyramid views, you could also have a
base class do the work on __init__ (
http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/views.html?awesome#defining-a-view-callable-as-a-class
)


Personally, I would probably opt for the an event_subscriber or
__init__ to manipulate the beaker session -- and only because I'd want
to store this information in the session, along with a timestamp, and
have it cached for 5-10 seconds.  In a dev environment, all of your
files ( static included ) will be served by Pyramid, so calculating
this nonstop would make testing a bit annoying.  In production, you'll
probably run into this being a bottleneck... and offering some ability
to cache could offset needing to scale hardware a bit.

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

Reply via email to