multiple beaker sessions under pyramid ?

47 views
Skip to first unread message

Jonathan Vanasco

unread,
Mar 1, 2012, 9:54:49 PM3/1/12
to pylons-discuss
has anyone attempted this yet with pyramid_beaker , or a custom
implementation ?

much like the folks who asked about "multiple beaker sessions under
pylons" [ http://groups.google.com/group/pylons-discuss/browse_thread/thread/62fbd23305db7dcc?fwc=1
] , i'd like to have a beaker session for account stuff (https) and
another for insecure traffic (http).

Jonathan Vanasco

unread,
Mar 5, 2012, 5:54:47 PM3/5/12
to pylons-discuss
I'm close do doing this with a middleware hack.

I looked into extending pyramid and pyramid_beaker to support a
request.session_https option. That is going to add a chunk of code -
so I should ask first... is that something worth doing ?

Michael Merickel

unread,
Mar 5, 2012, 6:21:48 PM3/5/12
to pylons-...@googlegroups.com
On Thu, Mar 1, 2012 at 8:54 PM, Jonathan Vanasco <jona...@findmeon.com> wrote:
has anyone attempted this yet with pyramid_beaker , or a custom
implementation ?

It should absolutely be possible. I would suggest using Pyramid's new (1.3+) config.set_request_property() functionality to add another (lazy) property onto the request which will store the session. Obviously you'll have to roll your own session factory stuff, but Pyramid's session support isn't exactly difficult to figure out.

Using pyramid_beaker you would likely create a new session factory and attach it to your request property. Just make sure you change the cookie name for each session.

Jonathan Vanasco

unread,
Mar 5, 2012, 6:25:46 PM3/5/12
to pylons-discuss
the config.set_request_property sounds like it'll be *perfect*

i'll whip up a distributable based on that -- will be much better than
hacking at pyramid core!

On Mar 5, 6:21 pm, Michael Merickel <mmeri...@gmail.com> wrote:

Zak

unread,
Mar 5, 2012, 8:27:51 PM3/5/12
to pylons-...@googlegroups.com
I'm very interested in functionality. Please keep us updated.

Jonathan Vanasco

unread,
Mar 5, 2012, 11:04:36 PM3/5/12
to pylons-discuss
I've got a monkeypatched version that seems to work right now
( https://gist.github.com/1983280 ). It was the most straightforward
way of compiling all the relevant pieces from Pyramid /
Pyramid_Beaker.

I say "seems" , because I don't have my local server setup to test
with https, it works on port 80 fine. I'll need to adjust my dev
machine to test secure.

I'm going to set up an https environment tomorrow, and see if it
works. If it does, i'll port to a subcriber based system and
distribute via github.

Jonathan Vanasco

unread,
Mar 6, 2012, 2:09:47 PM3/6/12
to pylons-discuss
pyramid_subscribers_beaker_https_session

https://github.com/jvanasco/pyramid_subscribers_beaker_https_session

i've got it supporting two methods:

1. config.set_request_property
2. a NewRequest listener that manually sets the property

the latter option is likely to leave, but i already named it
"pyramid_subscribers_"

I'll toss on PyPi for others.
Reply all
Reply to author
Forward
0 new messages