app/soc/logic/accounts.py
changeset 1600 0aa3de1b2acc
parent 1547 c8c269ef0498
child 1619 66f944747562
equal deleted inserted replaced
1599:b56976cac36b 1600:0aa3de1b2acc
    23   '"Sverre Rabbelier" <sverre@rabbelier.nl>',
    23   '"Sverre Rabbelier" <sverre@rabbelier.nl>',
    24   ]
    24   ]
    25 
    25 
    26 
    26 
    27 from google.appengine.api import users
    27 from google.appengine.api import users
       
    28 
       
    29 
       
    30 def getCurrentAccount(normalize=True):
       
    31   """Returns an optionally normalized version of the current account.
       
    32   """
       
    33 
       
    34   account = users.get_current_user()
       
    35   return normalizeAccount(account) if (account and normalize) else account
    28 
    36 
    29 
    37 
    30 def normalizeAccount(account):
    38 def normalizeAccount(account):
    31   """Returns a normalized version of the specified account.
    39   """Returns a normalized version of the specified account.
    32   """
    40   """
    66     account: a Google Account (users.User) object;
    74     account: a Google Account (users.User) object;
    67       if not supplied, the current logged-in user is checked
    75       if not supplied, the current logged-in user is checked
    68   """
    76   """
    69 
    77 
    70   # Get the currently logged in user
    78   # Get the currently logged in user
    71   current = users.get_current_user()
    79   current = getCurrentAccount()
    72 
    80 
    73   if current and (not account):
    81   if current and (not account):
    74     # default to the current user
    82     # default to the current user
    75     account = current
    83     account = current
    76 
    84