~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to lib/common/db.py

  • Committer: mattgiuca
  • Date: 2008-02-05 05:53:29 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:416
Propagated the addition of "unixid" to login table down the code chain.
makeuser.py: Passes uid to makeuser.make_user_db.
makeuser.make_user_db: Added uid argument. Passes to db.create_user.
db: create_user: Added unixid argument. Inserts into table.
    get_user: Returns unixid in the dictionary. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
 
76
76
    # USER MANAGEMENT FUNCTIONS #
77
77
 
78
 
    def create_user(self, login, password, nick, fullname, rolenm, studentid,
79
 
        dry=False):
 
78
    def create_user(self, login, unixid, password, nick, fullname, rolenm,
 
79
        studentid, dry=False):
80
80
        """Creates a user login entry in the database.
81
81
        Arguments are the same as those in the "login" table of the schema.
82
82
        The exception is "password", which is a cleartext password. makeuser
84
84
        Raises an exception if the user already exists.
85
85
        """
86
86
        passhash = _passhash(password)
87
 
        query = ("INSERT INTO login (login, passhash, nick, fullname, "
88
 
            "rolenm, studentid) VALUES (%s, %s, %s, %s, %s, %s);" %
89
 
            (_escape(login), _escape(passhash), _escape(nick),
 
87
        query = ("INSERT INTO login (login, unixid, passhash, nick, fullname,"
 
88
            " rolenm, studentid) VALUES (%s, %d, %s, %s, %s, %s, %s);" %
 
89
            (_escape(login), unixid, _escape(passhash), _escape(nick),
90
90
            _escape(fullname), _escape(rolenm), _escape(studentid)))
91
91
        if dry: return query
92
92
        self.db.query(query)
137
137
 
138
138
        Raises a DBException if the login is not found in the DB.
139
139
        """
140
 
        query = ("SELECT login, nick, fullname, rolenm, studentid FROM login "
141
 
            "WHERE login = %s;" % _escape(login))
 
140
        query = ("SELECT login, unixid, nick, fullname, rolenm, studentid "
 
141
            "FROM login WHERE login = %s;" % _escape(login))
142
142
        if dry: return query
143
143
        result = self.db.query(query)
144
144
        # Expecting exactly one