Commit 8b6b20a5 authored by Vincent Pelletier's avatar Vincent Pelletier

Use tool-level preference accessor.

This simplifies code a lot, with added bonus of enabling use of highest-precedence System Preference.
Also, user_name is not used in the local cached function, so move it to cache key instead.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45678 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent be35fb4f
......@@ -51,28 +51,16 @@
<item>
<key> <string>_body</string> </key>
<value> <string>""" Get (in seconds) authentication expire interval for an user. """\n
from zExceptions import Unauthorized\n
from Products.ERP5Type.Cache import CachingMethod\n
\n
def getMaxUserInactivityDuration(user_name=None):\n
expire_interval = None\n
portal_preferences = context.portal_preferences\n
try:\n
active_preference = portal_preferences.getActivePreference()\n
except Unauthorized:\n
# when logging for first time through login_form user is still anonymous \n
# and so getActivePreference is not accessible. Try to get default preference\n
# for an ERP5 site \n
active_preference = getattr(portal_preferences, \'default_site_preference\', None)\n
if active_preference is not None:\n
expire_interval = active_preference.getPreferredMaxUserInactivityDuration()\n
return expire_interval\n
def getMaxUserInactivityDuration():\n
return context.portal_preferences.getPreferredMaxUserInactivityDuration()\n
\n
getMaxUserInactivityDuration = CachingMethod( \\\n
getMaxUserInactivityDuration, \\\n
"ERP5Site_getMaxUserInactivityDuration", \\\n
"ERP5Site_getMaxUserInactivityDuration_%s" % (user_name, ), \\\n
cache_factory=\'erp5_ui_medium\')\n
return getMaxUserInactivityDuration(user_name)\n
return getMaxUserInactivityDuration()\n
</string> </value>
</item>
<item>
......
9
\ No newline at end of file
10
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment