~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-03-09 13:56:05 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:674
userservice: Fixed encoding of User objects into JSON
    (previously exception raised if they had a timestamp,
    which is not encodable).
    Calls str so they are represented by their "nice" string formats.

Show diffs side-by-side

added added

removed removed

Lines of Context:
329
329
    if 'role' in user:
330
330
        user['rolenm'] = str(user['role'])
331
331
        del user['role']
332
 
    user = dict(user)
333
332
    try:
334
333
        del user['svn_pass']
335
334
    except KeyError:
336
335
        pass
 
336
    # Convert time stamps to nice strings
 
337
    try:
 
338
        if user['pass_exp'] is not None:
 
339
            user['pass_exp'] = str(user['pass_exp'])
 
340
    except KeyError:
 
341
        pass
 
342
    try:
 
343
        if user['acct_exp'] is not None:
 
344
            user['acct_exp'] = str(user['acct_exp'])
 
345
    except KeyError:
 
346
        pass
 
347
    try:
 
348
        if user['last_login'] is not None:
 
349
            user['last_login'] = str(user['last_login'])
 
350
    except KeyError:
 
351
        pass
337
352
    response = cjson.encode(user)
338
353
    req.content_type = "text/plain"
339
354
    req.write(response)