[Zope] session-timeout-minutes value in runtime Zope
Peter Bengtsson
peter at fry-it.com
Fri Feb 2 08:35:28 EST 2007
Thanks but I solved it using::
from App.config import getConfiguration
conf = getConfiguration()
setattr(MyProductClass, 'SESSION_TIMEOUT_MINUTES',
conf.session_timeout_minutes)
Now I can use this::
class MyProductClass:
def getLoggedInSecurelyMinutesLeft(self):
""" return how many minutes there is left on the securely
logged in session. """
ts = self.get_session(SESSIONKEY_USER_SECURE_TIMESTAMP, None)
if ts is None:
return 0
minutes = self.SESSION_TIMEOUT_MINUTES - (time.time() - ts) / 60
return int(minutes)
yacine chaouche wrote:
> I don't know if this is what you want. If you want to have access, in
> your code, to the session-timeout-minutes variable, you can try this
> methode on your session_data_manager object :
>
> getTimeoutMinutes(self):
>
> Return the number of minutes allowed for subobject inactivity before
> expiration. PermissionView management screens
>
> This is from the api documentation of TransientContainer class, found
> in the help link in the ZMI of temp_folder/session_data_manager.
>
> In your code, you can use something like :
> <tal code>
> you'll be
> securely logged in for another <span tal:replace="python
> context.temp_folder.session_data_manager.getTimeoutMinutes() "></span>
> minutes unless you log out or log in
> again".
> </tal>
>
> Y.Chaouche
>
> 2007/1/23, Dieter Maurer <dieter at handshake.de>:
>> Peter Bengtsson wrote at 2007-1-23 13:44 +0000:
>> >This might be an FAQ but I wasn't able to find it when searching.
>> >How do I get access to the value of 'session-timeout-minutes' coming
>> >from etc/zope.conf in runtime Zope?
>>
>> The value is used to configure the so called "Session Data Manager"
>> (usually "/temp_folder/session_data").
>>
>> Its management page is able to show you the value.
>>
>> This means, there is some way to access it. You can use this
>> way in your own application (you might need a proxy role to
>> get sufficient privileges).
>>
>>
>>
>> --
>> Dieter
>> _______________________________________________
>> Zope maillist - Zope at zope.org
>> http://mail.zope.org/mailman/listinfo/zope
>> ** No cross posts or HTML encoding! **
>> (Related lists -
>> http://mail.zope.org/mailman/listinfo/zope-announce
>> http://mail.zope.org/mailman/listinfo/zope-dev )
>>
> _______________________________________________
> Zope maillist - Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
>
--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
More information about the Zope
mailing list