Mercurial > hg > ltpdarepo
changeset 20:d19c5ae165de
Make load() method of the User class into a static method.
author | Daniele Nicolodi <daniele@grinta.net> |
---|---|
date | Mon, 27 Jun 2011 14:13:21 +0200 |
parents | 76e6b6c5d5cb |
children | 19f233ab545f |
files | src/ltpdarepo/user.py |
diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ltpdarepo/user.py Mon Jun 27 14:08:38 2011 +0200 +++ b/src/ltpdarepo/user.py Mon Jun 27 14:13:21 2011 +0200 @@ -50,7 +50,8 @@ def __getitem__(self, name): return getattr(self, name) - def load(self, username): + @staticmethod + def load(username): conn = connection() curs = conn.cursor(DictCursor) curs.execute("""SELECT username, @@ -61,10 +62,11 @@ FROM users WHERE username=%s""", username) user = curs.fetchone() if user is None: - return user + return None + obj = User() for key, value in user.iteritems(): - setattr(self, key, value) - return self + setattr(obj, key, value) + return obj def create(self): if not self.password: