# HG changeset patch # User Sverre Rabbelier # Date 1229042079 0 # Node ID a59eaa177562159d1f367318dd5dbd5300d6f6f0 # Parent 6f1d29857072478fa052f8413c303ed64386ccc6 Added getForCurrentAccount to user.Logic It returns the user entity associated with the currently logged in user. Patch by: Sverre Rabbelier diff -r 6f1d29857072 -r a59eaa177562 app/soc/logic/models/user.py --- a/app/soc/logic/models/user.py Fri Dec 12 00:34:12 2008 +0000 +++ b/app/soc/logic/models/user.py Fri Dec 12 00:34:39 2008 +0000 @@ -22,6 +22,8 @@ ] +from google.appengine.api import users + from soc.logic.helper import notifications from soc.logic.models import base @@ -54,6 +56,22 @@ return False + def getForCurrentAccount(self): + """Retrieves the user entity for the currently logged in account + + If there is no user logged in, or they have no associated User + entity, None is returend. + """ + + account = users.get_current_user() + + if not account: + return None + + user = self.getForFields({'account': account}, unique=True) + + return user + def getKeyValues(self, entity): """See base.Logic.getKeyValues. """