Mercurial > getan
changeset 68:a25dab413260
Add new method to update a description of an entry in the database backend
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Wed, 25 May 2011 13:26:09 +0200 |
parents | 34a0f5c533bd |
children | f0e4637ad4e4 |
files | getan/backend.py |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/getan/backend.py Wed May 25 13:23:04 2011 +0200 +++ b/getan/backend.py Wed May 25 13:26:09 2011 +0200 @@ -82,6 +82,8 @@ MOVE_ENTRY = 'UPDATE entries SET project_id = ? WHERE id = ?' +UPDATE_ENTRY = 'UPDATE entries SET description = ? WHERE id = ?' + logger = logging.getLogger() class Backend: @@ -219,6 +221,19 @@ finally: close(cur) + def update_entry(self, entry): + if not entry: + return + + cur = None + try: + cur = self.con.cursor() + cur.execute(UPDATE_ENTRY, (entry.desc, entry.id)) + self.con.commit() + logger.debug("Updated entry: '%s' (%d)" % (entry.desc, entry.id)) + finally: + close(cur) + def close(cur): """ This function closes a database cursor if it is existing """ if cur: