From 2bd7a892f1a5636bf13cf305998f4a805883c22d Mon Sep 17 00:00:00 2001 From: Torsten Werner Date: Mon, 24 Jan 2011 00:00:53 +0100 Subject: [PATCH] Add PoolFile.validate(). Signed-off-by: Torsten Werner --- daklib/dbconn.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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 -- 2.39.5