# HG changeset patch # User Daniele Nicolodi # Date 1309176801 -7200 # Node ID d19c5ae165de5e9350fd6495ea009d9becb785c1 # Parent 76e6b6c5d5cb76f3e4d0b8b72689fba07cdce269 Make load() method of the User class into a static method. diff -r 76e6b6c5d5cb -r d19c5ae165de src/ltpdarepo/user.py --- 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: