changeset 165:83ba64c9a51e

A project entry in the db must have a key Without a key a project is not selectable.
author Björn Ricks <bjoern.ricks@intevation.de>
date Thu, 06 Dec 2012 15:29:16 +0100
parents 90abd423fc0c
children eead2420b8bc
files getan/backend.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/getan/backend.py	Thu Dec 06 15:04:29 2012 +0100
+++ b/getan/backend.py	Thu Dec 06 15:29:16 2012 +0100
@@ -25,7 +25,7 @@
 """
 CREATE TABLE projects (
     id          INTEGER PRIMARY KEY AUTOINCREMENT,
-    key         VARCHAR(16),
+    key         VARCHAR(16) NOT NULL,
     description VARCHAR(256),
     active      BOOLEAN DEFAULT 1
 )
@@ -87,6 +87,9 @@
 
 logger = logging.getLogger()
 
+class InvalidProjectKeyError(Exception):
+    pass
+
 class Backend(object):
 
     def __init__(self, database = DEFAULT_DATABASE):
@@ -132,6 +135,10 @@
 
                 if not row:
                     break
+                # check key
+                if not row[1]:
+                    raise InvalidProjectKeyError("Project with id %s needs " \
+                            "a key" % row[0])
                 proj = Project(*row)
                 proj.entries = self.load_entries(proj.id)
                 projects.append(proj)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)