Rewrite fix for UserStore.expert() to be more like UserStoreOld.expert().

This commit is contained in:
Petter Reinholdtsen 2013-09-11 20:31:12 +02:00
parent 6effc94349
commit 7ff6ea14e2

View File

@ -16,12 +16,21 @@ class UserStore(UserStoreModule, sqlite_db):
def close(self): def close(self):
self.__exit__(None,None,None) self.__exit__(None,None,None)
def currentuser(self): def current(self, name=False):
return cherrypy.session.get(cfg.session_key) """Return current user, if there is one, else None.
If name = True, return the username instead of the user."""
try:
username = cherrypy.session.get(cfg.session_key)
if name:
return username
else:
return self.get(username)
except AttributeError:
return None
def expert(self, username=None): def expert(self, username=None):
if username is None: if not username:
username = self.currentuser() username = self.current(name=True)
groups = self.attr(username,"groups") groups = self.attr(username,"groups")
if not groups: if not groups:
return False return False