X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FSessions.py;h=305e55bdffa7141b3fdf6728b025f520c530df10;hb=38587adfb2af0eeb23106eae99bccbc229784254;hp=b91ca12aaea6236ca31c9591cf6b643a5d39489a;hpb=c2a0cb62e9f7bdab6b4725e8d23a52266afe02a9;p=plcapi.git diff --git a/PLC/Sessions.py b/PLC/Sessions.py index b91ca12..305e55b 100644 --- a/PLC/Sessions.py +++ b/PLC/Sessions.py @@ -79,7 +79,7 @@ class Session(Row): def sync(self, commit = True, insert = None): if not self.has_key('session_id'): # Before a new session is added, delete expired sessions - expired = Sessions(self.api, expires = -int(time.time())).values() + expired = Sessions(self.api, expires = -int(time.time())) for session in expired: session.delete(commit) @@ -98,13 +98,13 @@ class Sessions(Table): """ def __init__(self, api, session_ids = None, expires = int(time.time())): - self.api = api + Table.__init__(self, api, Session) sql = "SELECT %s FROM view_sessions WHERE True" % \ ", ".join(Session.fields) if session_ids: - sql += " AND session_id IN (%s)" % ", ".join(api.db.quote(session_ids)) + sql += " AND session_id IN (%s)" % ", ".join(map(api.db.quote, session_ids)) if expires is not None: if expires >= 0: @@ -113,7 +113,4 @@ class Sessions(Table): expires = -expires sql += " AND expires < %(expires)d" - rows = self.api.db.selectall(sql, locals()) - - for row in rows: - self[row['session_id']] = Session(api, row) + self.selectall(sql, locals())