# HG changeset patch # User Daniele Nicolodi # Date 1309184157 -7200 # Node ID 05ab4b93f132808c21980397599004c9986cf497 # Parent f27d3de115682decaea6d51b9602aac032595144 Make load() method of the Database class into a static method. diff -r f27d3de11568 -r 05ab4b93f132 src/ltpdarepo/database.py --- a/src/ltpdarepo/database.py Mon Jun 27 15:52:18 2011 +0200 +++ b/src/ltpdarepo/database.py Mon Jun 27 16:15:57 2011 +0200 @@ -22,22 +22,25 @@ __slots__ = ('id', 'name', 'description') def __init__(self, id='', name='', description=''): - self.id = None - self.name = None - self.description = None + self.id = id + self.name = name + self.description = description - def load(self, id): + @staticmethod + def load(id): curs = g.db.cursor(DictCursor) curs.execute("""SELECT db_name AS id, name, description FROM available_dbs WHERE db_name=%s""", id) db = curs.fetchone() if db is None: return None - self.update(db) - return self + obj = Database() + obj.update(db) + return obj - def update(self, vals): - for key, value in vals.iteritems(): + def update(self, vals=None, **kwargs): + kwargs.update(vals or {}) + for key, value in kwargs.iteritems(): setattr(self, key, value) def create(self):