From: Torsten Werner Date: Sun, 23 Jan 2011 23:00:53 +0000 (+0100) Subject: Add PoolFile.validate(). X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bd7a892f1a5636bf13cf305998f4a805883c22d;p=dak Add PoolFile.validate(). Signed-off-by: Torsten Werner --- diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 877c5a39..0ecb6692 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