[Kimchi-devel] [PATCH][Wok 1/2] Move constant from auth.py to template.py

Ramon Medeiros ramonn at linux.vnet.ibm.com
Wed Jul 20 17:24:58 UTC 2016


As auth importing template, this was causing an error. To avoid it, put
REFRESH constant at template, and as auth is importing it, use by
reference.

Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
---
 src/wok/auth.py     | 9 ++++-----
 src/wok/template.py | 1 +
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/wok/auth.py b/src/wok/auth.py
index 0355e86..421f8f3 100644
--- a/src/wok/auth.py
+++ b/src/wok/auth.py
@@ -40,7 +40,6 @@ from wok.utils import get_all_tabs, run_command
 USER_NAME = 'username'
 USER_GROUPS = 'groups'
 USER_ROLES = 'roles'
-REFRESH = 'robot-refresh'
 
 tabs = get_all_tabs()
 
@@ -263,13 +262,13 @@ def check_auth_session():
         debug("Session authenticated for user %s" % session)
         wokRobot = cherrypy.request.headers.get('Wok-Robot')
         if wokRobot == "wok-robot":
-            if (time.time() - cherrypy.session[REFRESH] >
+            if (time.time() - cherrypy.session[template.REFRESH] >
                     int(config.get('server', 'session_timeout')) * 60):
                 cherrypy.session[USER_NAME] = None
                 cherrypy.lib.sessions.expire()
                 raise cherrypy.HTTPError(401, "sessionTimeout")
         else:
-            cherrypy.session[REFRESH] = time.time()
+            cherrypy.session[template.REFRESH] = time.time()
         return True
 
     debug("Session not found")
@@ -316,7 +315,7 @@ def login(username, password, **kwargs):
     cherrypy.session[USER_NAME] = username
     cherrypy.session[USER_GROUPS] = user.get_groups()
     cherrypy.session[USER_ROLES] = user.get_roles()
-    cherrypy.session[REFRESH] = time.time()
+    cherrypy.session[template.REFRESH] = time.time()
     cherrypy.session.release_lock()
     return user.get_user()
 
@@ -324,7 +323,7 @@ def login(username, password, **kwargs):
 def logout():
     cherrypy.session.acquire_lock()
     cherrypy.session[USER_NAME] = None
-    cherrypy.session[REFRESH] = 0
+    cherrypy.session[template.REFRESH] = 0
     cherrypy.session.release_lock()
     cherrypy.lib.sessions.close()
 
diff --git a/src/wok/template.py b/src/wok/template.py
index 2162c8a..68243d9 100644
--- a/src/wok/template.py
+++ b/src/wok/template.py
@@ -28,6 +28,7 @@ from glob import iglob
 
 from wok.config import paths
 
+REFRESH = 'robot-refresh'
 
 def get_lang():
     cookie = cherrypy.request.cookie
-- 
2.5.5




More information about the Kimchi-devel mailing list