I finally came to the following solution I thought I could share :
1 from beaker.session import
SessionObject
2 from pyramid_beaker import
session_factory_from_settings
3
4 def
get_session_factory(settings):
5
"""
6 Wrap the beaker session factory to add longtimeout
support
7
"""
8 factory =
session_factory_from_settings(settings)
9 class
CustomSessionObject(factory):
10
"""
11 Our pyramid session
object
12
"""
13 _longtimeout =
factory._options.pop("longtimeout")
14 def __init__(self,
request):
15 options =
self._options.copy()
16 if "remember_me" in
request.cookies.keys():
17 options['timeout'] =
self._longtimeout
18 SessionObject.__init__(self, request.environ,
**options)
19 def session_callback(request,
response):
20 exception = getattr(request, 'exception',
None)
21 if (exception is None or
self._cookie_on_exception
22 and
self.accessed()):
23
self.persist()
24 headers =
self.__dict__['_headers']
25 if headers['set_cookie'] and
headers['cookie_out']:
26
response.headerlist.append(
27 ('Set-Cookie',
headers['cookie_out']))
28
request.add_response_callback(session_callback)
29 return CustomSessionObject
Le 18/12/2012 21:37, tonthon a écrit :
> Hi,
>
> We've got an application using beaker and SessionAuthenticationPolicy.
>
> I'm trying to figure out how to add a "remember me" option to our login
> process.
>
> Is it possible to handle the session.timeout dynamically ?
> Should I use a custom cookie instead and handle it on login and in a
> custom forbidden view ?
>
> Regards,
>
> Gaston
>
--
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.