/[glsr]/trunk/site/user.py
Gentoo

Contents of /trunk/site/user.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 50 - (show annotations) (download) (as text)
Sat Jul 2 09:57:18 2005 UTC (9 years, 2 months ago) by port001
File MIME type: text/x-python
File size: 2021 byte(s)
Supporting code for logins
1 # Copyright 2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 #
4
5 __revision__ = "$Id$"
6 __authors__ = ["Scott Hadfield <hadfield@gentoo.org>",
7 "Ian Leitch <port001@gentoo.org>"]
8 __modulename__ = "user"
9
10 from glsr.setup import config
11 from glsr.core.db.mysql import SQLdb
12
13 def create_user(details):
14 pass
15
16 def get_uid_by_alias(alias):
17
18 return SQLdb(config.db).query(
19 "SELECT user_id FROM %(prefix)suser WHERE " % {'prefix': config.db['prefix']} +
20 "user_alias = %s", alias, fetch='one')
21
22 def get_uid_by_sid(sid):
23
24 return SQLdb(config.db).query(
25 "SELECT user_id FROM %(prefix)suser WHERE " % {'prefix': config.db['prefix']} +
26 "user_sid = %s", str(sid), fetch='one')
27
28 class User:
29
30 def __init__(self, uid):
31
32 self.__db = SQLdb(config.db)
33 self.__uid = uid
34
35 def get_alias(self):
36
37 return self.__db.query("SELECT user_alias FROM %(prefix)suser" % \
38 {'prefix': config.db['prefix']}, fetch='one')['user_alias']
39
40 def set_session(self, sid):
41
42 self.__db.query("UPDATE %(prefix)suser " % {'prefix': config.db['prefix']} +
43 "SET session_id = %s", sid, fetch='none')
44
45 def get_session(self):
46
47 return self.__db.query("SELECT user_sid FROM %(prefix)suser" % \
48 {'prefix': config.fb['prefix']}, fetch='one')['user_sid']
49
50 def get_passwd(self):
51
52 return self.__db.query("SELECT user_passwd FROM %(prefix)suser" % \
53 {'prefix': config.db['prefix']}, fetch='one')['user_passwd']
54 def set_last_ip(self, ip):
55
56 self.__db.query("UPDATE %(prefix)suser " % {'prefix': config.db['prefix']} +
57 "SET user_lastip = %s", sid, fetch='none')
58
59 def get_last_ip(self):
60
61 return self.__db.query("SELECT user_ip FROM $(prefix)suser" % \
62 {'prefix': config.db['prefix']}, fetch='one')['user_lastip']

Properties

Name Value
svn:keywords Id

  ViewVC Help
Powered by ViewVC 1.1.20