changeset 174:36b9f2d31810

Add backend method to update a project in the database Update the project key and description in the database.
author Björn Ricks <bjoern.ricks@intevation.de>
date Thu, 13 Dec 2012 09:30:52 +0100
parents a5319bb1ac13
children 5e069074b1c9
files getan/backend.py
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/getan/backend.py	Thu Dec 13 09:00:09 2012 +0100
+++ b/getan/backend.py	Thu Dec 13 09:30:52 2012 +0100
@@ -85,6 +85,8 @@
 
 UPDATE_ENTRY = 'UPDATE entries SET description = ? WHERE id = ?'
 
+UPDATE_PROJECT = "UPDATE projects SET key = ?, description = ? WHERE id = ?"
+
 logger = logging.getLogger()
 
 class InvalidProjectKeyError(Exception):
@@ -244,6 +246,20 @@
         finally:
             close(cur)
 
+    def update_project(self, project):
+        if not project:
+            return
+
+        cur = None
+        try:
+            cur = self.con.cursor()
+            cur.execute(UPDATE_PROJECT, (project.key, project.desc, project.id))
+            self.con.commit()
+            logger.debug("Updated project: (%d) %s %s" % (project.id,
+                project.key, project.desc))
+        finally:
+            close(cur)
+
 def close(cur):
     """ This function closes a database cursor if it is existing """
     if cur:
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)