From 4d586052503ffc5d047a6fed07ac03cf92ae11ab Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Fri, 7 Sep 2007 09:05:07 +0000 Subject: Checkpoint svn path=/scripts/rpki/sql.py; revision=933 --- scripts/rpki/sql.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'scripts/rpki') diff --git a/scripts/rpki/sql.py b/scripts/rpki/sql.py index 785caa38..9215abef 100644 --- a/scripts/rpki/sql.py +++ b/scripts/rpki/sql.py @@ -32,6 +32,10 @@ class sql_persistant(object): # to SQL. sql_dirty = False + ## @var sql_attributes + # Tuple of attributes to translate between this Python object and its SQL representation. + sql_attributes = None # Must be overriden by derived type + @classmethod def sql_fetch(cls, db, **kwargs): """Fetch rows from SQL based on a canned query and a set of @@ -89,3 +93,9 @@ class sql_persistant(object): for kids in self.sql_children.values(): for kid in getattr(self, kids): kid.sql_store(db, cur) + + def sql_makedict(self): + """Copy attributes from this object into a dict for use with + canned SQL queries. + """ + return dict((a, getattr(self, a)) for a in self.sql_attributes) -- cgit v1.2.3