
On Jul 20 04:38PM, Ramon Medeiros wrote:
On 07/20/2016 03:06 PM, Paulo Ricardo Paz Vital wrote:
Adds a header "Session-Expires-On" returning the remaining time to expire the session.
Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- src/wok/template.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/src/wok/template.py b/src/wok/template.py index 68243d9..43a34db 100644 --- a/src/wok/template.py +++ b/src/wok/template.py @@ -22,14 +22,18 @@ import cherrypy import errno import json +import time from Cheetah.Template import Template from glob import iglob
+from wok import config as config from wok.config import paths
+EXPIRES_ON = 'Session-Expires-On' REFRESH = 'robot-refresh'
+ def get_lang(): cookie = cherrypy.request.cookie if "wokLang" in cookie.keys(): @@ -110,6 +114,17 @@ def render_cheetah_file(resource, data):
def render(resource, data): + # get timeout and last refresh + s_timeout = float(config.config.get("server", "session_timeout")) + cherrypy.session.acquire_lock() + last_req = cherrypy.session.get(REFRESH) + cherrypy.session.release_lock() + + # last_request is present: calculate remaining time + if last_req is not None: + session_expires = (float(last_req) + (s_timeout * 60)) - time.time() + cherrypy.response.headers[EXPIRES_ON] = session_expires As commented by Aline on RFC, was requested on https://github.com/kimchi-project/wok/issues/133#issuecomment-232752799
On Jul 20 02:24PM, Ramon Medeiros wrote: the time the session will expires since last request, so I guess the correct formula is:
session_expires = (float(last_req) + (s_timeout * 60))
Doesn't? just check with Peter Pennings,
he says that is easier to deal just with the remaining time.
OK! So, I guess it's reviewed-by :-)
He is also copied here
+ if can_accept('application/json'): cherrypy.response.headers['Content-Type'] = \ 'application/json;charset=utf-8' -- 2.5.5
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel
--
Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel
-- Paulo Ricardo Paz Vital Linux Technology Center, IBM Systems http://www.ibm.com/linux/ltc/