]> err.no Git - dak/commitdiff
Extend ORMObject.validate() to support _id columns.
authorTorsten Werner <twerner@debian.org>
Tue, 25 Jan 2011 06:11:13 +0000 (07:11 +0100)
committerTorsten Werner <twerner@debian.org>
Tue, 25 Jan 2011 06:11:13 +0000 (07:11 +0100)
It won't throw an exception if the numeric _id property is set instead the real
property.

Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/dbconn.py

index d81e1ed52177999962333546ba90b342ab0ae546..fa52a9187bbc080caeaaa43919033b0435021b41 100755 (executable)
@@ -262,6 +262,12 @@ class ORMObject(object):
         validation fails.
         '''
         for property in self.not_null_constraints():
+            # TODO: It is a bit awkward that the mapper configuration allow
+            # directly setting the numeric _id columns. We should get rid of it
+            # in the long run.
+            if hasattr(self, property + '_id') and \
+                getattr(self, property + '_id') is not None:
+                continue
             if not hasattr(self, property) or getattr(self, property) is None:
                 raise DBUpdateError(self.validation_message % \
                     (property, str(self)))
@@ -2239,7 +2245,8 @@ class DBSource(ORMObject):
             'install_date']
 
     def not_null_constraints(self):
-        return ['source', 'version', 'install_date']
+        return ['source', 'version', 'install_date', 'maintainer', \
+            'changedby', 'poolfile', 'install_date']
 
 __all__.append('DBSource')