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

« back to all changes in this revision

Viewing changes to lib/common/db.py

  • Committer: drtomc
  • Date: 2008-02-20 09:41:48 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:522
Add quite a lot of stuff to get usrmgt happening.

login.py: A little bit of robustifying logic that logs you out if your account
    is still pending when you try to auth. Basically, this forces usrmgt-server
    to have another try.

authenticate.py: A small code rearrangement to produce the right behaviour
    (a generic login/passwd error) when an unknown user logs in (better than
    an internal server error :-) ).

usrmgt-server, makeuser.py: Lots of stuff to setup users. Quite a bit of stuff
    that should be db-driven is hard coded at the moment. (Only a week and a
    half till students will be hitting it, and we can't do everything!)

setup.py: Add an extra bit of svn related config.

users.sql,user.py,db.py: Add the svn_pass column to allow ivle to auth to the
    subversion server.

studpath.py: update a couple of comments to reflect a newer view of the world.

python-console: Add some timeout magic. Actually, I don't think this works,
    but it's well after bedtime, and I've still got to ride home from work.
    The morning will be soon enough.

Show diffs side-by-side

added added

removed removed

Lines of Context:
172
172
        """
173
173
        if (not (DB.check_dict(primarydict, primary_keys, must=True)
174
174
            and DB.check_dict(updatedict, tablefields, disallowed_update))):
175
 
            raise DBException("Supplied dictionary contains invalid or "
176
 
                " missing fields.")
 
175
            raise DBException("Supplied dictionary contains invalid or missing fields (1).")
177
176
        # Make a list of SQL fragments of the form "field = 'new value'"
178
177
        # These fragments are ALREADY-ESCAPED
179
178
        setlist = []
199
198
        primarydict, tablename, primary_keys: See update.
200
199
        """
201
200
        if not DB.check_dict(primarydict, primary_keys, must=True):
202
 
            raise DBException("Supplied dictionary contains invalid or "
203
 
                " missing fields.")
 
201
            raise DBException("Supplied dictionary contains invalid or missing fields (2).")
204
202
        wherelist = []
205
203
        for k,v in primarydict.items():
206
204
            wherelist.append("%s = %s" % (k, _escape(v)))
225
223
            primary_keys is indeed the primary key).
226
224
        """
227
225
        if not DB.check_dict(primarydict, primary_keys, must=True):
228
 
            raise DBException("Supplied dictionary contains invalid or "
229
 
                " missing fields.")
 
226
            raise DBException("Supplied dictionary contains invalid or missing fields (3).")
230
227
        wherelist = []
231
228
        for k,v in primarydict.items():
232
229
            wherelist.append("%s = %s" % (k, _escape(v)))
289
286
    login_primary = frozenset(["login"])
290
287
    login_fields_list = [
291
288
        "login", "passhash", "state", "unixid", "email", "nick", "fullname",
292
 
        "rolenm", "studentid", "acct_exp", "pass_exp", "last_login"
 
289
        "rolenm", "studentid", "acct_exp", "pass_exp", "last_login", "svn_pass"
293
290
    ]
294
291
    login_fields = frozenset(login_fields_list)
295
292
    # Do not return passhash when reading from the DB
307
304
        invalid keys or is missing required keys.
308
305
        """
309
306
        if 'passhash' in kwargs:
310
 
            raise DBException("Supplied arguments include passhash (invalid).")
 
307
            raise DBException("Supplied arguments include passhash (invalid) (1).")
311
308
        # Make a copy of the dict. Change password to passhash (hashing it),
312
309
        # and set 'state' to "no_agreement".
313
310
        kwargs = copy.copy(kwargs)
333
330
        with a new one.
334
331
        """
335
332
        if 'passhash' in kwargs:
336
 
            raise DBException("Supplied arguments include passhash (invalid).")
 
333
            raise DBException("Supplied arguments include passhash (invalid) (2).")
337
334
        if "password" in kwargs:
338
335
            kwargs = copy.copy(kwargs)
339
336
            kwargs['passhash'] = _passhash(kwargs['password'])