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

« back to all changes in this revision

Viewing changes to www/common/makeuser.py

  • Committer: mattgiuca
  • Date: 2008-02-04 23:58:25 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:407
makeuser.py: Creating a DB user now has a "force" parameter, which if true
    will allow a field in the DB to be overwritten.

Show diffs side-by-side

added added

removed removed

Lines of Context:
168
168
    if errors:
169
169
        raise Exception, errors
170
170
 
171
 
def make_user_db(login, password, nick, fullname, rolenm, studentid):
172
 
    """Creates a user's entry in the database, filling in all the fields."""
 
171
def make_user_db(login, password, nick, fullname, rolenm, studentid,
 
172
    force=True):
 
173
    """Creates a user's entry in the database, filling in all the fields.
 
174
    If force is False, throws an exception if the user already exists.
 
175
    If True, overwrites the user's entry in the DB.
 
176
    """
173
177
    dbconn = db.DB()
 
178
    if force:
 
179
        # Delete user if it exists
 
180
        try:
 
181
            dbconn.delete_user(login)
 
182
        except:
 
183
            pass
174
184
    dbconn.create_user(login, password, nick, fullname, rolenm, studentid)
175
185
    dbconn.close()