summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2015-01-26 16:34:17 -0500
committerSimo Sorce <simo@redhat.com>2015-01-26 16:57:35 -0500
commit641a77ef0a3c4f0b933422850425a62c9f05de13 (patch)
tree79e18b618b0dbfb03434e315f0c9ed336c9d4910
parent74194d5d36cfc1be67e92924585731e9b3894605 (diff)
downloadipsilon-provsess.zip
ipsilon-provsess.tar.gz
ipsilon-provsess.tar.xz
Add helper to store provider specific dataprovsess
Signed-off-by: Simo Sorce <simo@redhat.com>
-rw-r--r--ipsilon/util/user.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/ipsilon/util/user.py b/ipsilon/util/user.py
index 5a8f159..e7c1b23 100644
--- a/ipsilon/util/user.py
+++ b/ipsilon/util/user.py
@@ -158,6 +158,27 @@ class UserSession(Log):
self._debug('Saved user attrs')
self.userattrs = userattrs
+ def _get_provider_attr_name(self, provider):
+ return '%s_data' % provider
+
+ def get_provider_data(self, provider):
+ attr = self._get_provider_attr_name(provider)
+ data = dict()
+ if attr in cherrypy.session:
+ data = cherrypy.session[attr]
+ return data
+
+ def replace_provider_data(self, provider, data):
+ attr = self._get_provider_attr_name(provider)
+ cherrypy.session[attr] = data
+ cherrypy.session.save()
+ self._debug('Saved %s provider data' % provider)
+
+ def set_provider_data_attribute(self, provider, attr, value):
+ data = self.get_provider_data(provider)
+ data['attr'] = value
+ self.replace_provider_data(provider, data)
+
def save_data(self, facility, name, data):
""" Save named data in the session so it can be retrieved later """
if facility not in cherrypy.session: