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

« back to all changes in this revision

Viewing changes to www/apps/userservice/__init__.py

  • Committer: mattgiuca
  • Date: 2008-02-19 07:12:38 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:506
dispatch.__init__, dispatch.request, cgirequest:
    Removed "username" attribute from Request objects altogether.
    Use req.user.login instead.
consoleservice, userservice, fileservice, debuginfo, studpath:
    Replaced use of "req.username" with "req.user.login".
Yay, refactor complete!

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
 
100
100
def handle(req):
101
101
    """Handler for the Console Service AJAX backend application."""
102
 
    if req.username is None:
 
102
    if req.user is None:
103
103
        # Not logged in
104
104
        req.throw_error(req.HTTP_FORBIDDEN)
105
105
    if len(req.path) > 0 and req.path[-1] == os.sep:
148
148
        db.start_transaction()
149
149
        try:
150
150
 
151
 
            user_details = db.get_user(req.username)
 
151
            user_details = db.get_user(req.user.login)
152
152
            # Check that the user's status is "no_agreement".
153
153
            # (Both to avoid redundant calls, and to stop disabled users from
154
154
            # re-enabling their accounts).
155
155
            if user_details.state != "no_agreement":
156
156
                req.throw_error(req.HTTP_BAD_REQUEST)
157
157
            # Write state "pending" to ensure we don't try this again
158
 
            db.update_user(req.username, state="pending")
 
158
            db.update_user(req.user.login, state="pending")
159
159
        except:
160
160
            db.rollback()
161
161
            raise
247
247
 
248
248
    try:
249
249
        login = fields.getfirst('login')
250
 
        if not fullpowers and login != req.username:
 
250
        if not fullpowers and login != req.user.login:
251
251
            # Not allowed to edit other users
252
252
            req.throw_error(req.HTTP_FORBIDDEN)
253
253
    except AttributeError:
254
254
        # If login not specified, update yourself
255
 
        login = req.username
 
255
        login = req.user.login
256
256
 
257
257
    # Make a dict of fields to update
258
258
    update = {}