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

« back to all changes in this revision

Viewing changes to lib/common/user.py

  • Committer: dcoles
  • Date: 2008-02-25 02:26:39 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:562
Added new app: Diff (SVN diff application)
setup.py: Added diffservice script to jail scripts

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
# user. Objects of this class are expected to be stored in the request
24
24
# session.
25
25
 
26
 
import db
27
 
import time
28
26
import common.caps
29
27
 
30
28
# Similar to db.login_fields_list but contains a different set of fields.
34
32
))
35
33
user_fields_list = (
36
34
    "login", "state", "unixid", "email", "nick", "fullname",
37
 
    "role", "studentid", "acct_exp", "pass_exp", "last_login",
38
 
    "svn_pass", "local_password",
 
35
    "role", "studentid", "acct_exp", "pass_exp", "svn_pass"
39
36
)
40
 
timestamp_fields = frozenset((
41
 
    "acct_exp", "pass_exp", "last_login",
42
 
))
43
37
# Fields not included: passhash, last_login
44
38
 
45
39
class UserException(Exception):
57
51
        # XXX Will ignore unknown fields instead of erroring
58
52
        if "rolenm" in kwargs and "role" not in kwargs:
59
53
            kwargs['role'] = common.caps.Role(kwargs['rolenm'])
60
 
        if "passhash" in kwargs and "local_password" not in kwargs:
61
 
            kwargs['local_password'] = kwargs['passhash'] is not None
 
54
            del kwargs['rolenm']
62
55
        for r in user_fields_list:
63
56
            if r in kwargs:
64
57
                self.__setattr__(r, kwargs[r])
75
68
                            "'fullname' missing")
76
69
                else:
77
70
                    self.__setattr__(r, None)
78
 
        for field in timestamp_fields:
79
 
            # Convert all timestamp fields from strings to Timestamp objects
80
 
            if hasattr(self, field):
81
 
                val = self.__getattribute__(field)
82
 
                if val is not None:
83
 
                    val = time.strptime(val, db.TIMESTAMP_FORMAT)
84
 
                    self.__setattr__(field, val)
85
 
 
86
71
    def __repr__(self):
87
72
        items = ["%s=%s" % (r, repr(self.__getattribute__(r)))
88
73
            for r in user_fields_list]