[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] Add PoolFile.validate().



Signed-off-by: Torsten Werner <twerner@debian.org>
---
 daklib/dbconn.py |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/daklib/dbconn.py b/daklib/dbconn.py
index 877c5a3..0ecb669 100755
--- a/daklib/dbconn.py
+++ b/daklib/dbconn.py
@@ -1213,6 +1213,15 @@ class PoolFile(ORMObject):
         return ['filename', 'file_id', 'filesize', 'md5sum', 'sha1sum', \
             'sha256sum', 'location', 'source', 'last_used']
 
+    def validate(self):
+        # sha1sum and sha256sum are not validated yet
+        if self.filename is None or len(self.filename) == 0 or \
+            self.filesize < 0 or self.md5sum is None or \
+            len(self.md5sum) == 0 or self.location is None:
+            raise DBUpdateError( \
+                "Validation failed because some properties must not be empty in object\n%s" % \
+                str(self))
+
 __all__.append('PoolFile')
 
 @session_wrapper
-- 
1.5.6.5



Reply to: