From b114f8978208938ea05cf2e3c69e84740cedb831 Mon Sep 17 00:00:00 2001 From: Torsten Werner Date: Tue, 25 Jan 2011 07:32:44 +0100 Subject: [PATCH] Add the ORMObject.get() class method. Signed-off-by: Torsten Werner --- daklib/dbconn.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/daklib/dbconn.py b/daklib/dbconn.py index fa52a918..837ce8e4 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -272,6 +272,21 @@ class ORMObject(object): raise DBUpdateError(self.validation_message % \ (property, str(self))) + @classmethod + @session_wrapper + def get(cls, primary_key, session = None): + ''' + This is a support function that allows getting an object by its primary + key. + + Architecture.get(3[, session]) + + instead of the more verbose + + session.query(Architecture).get(3) + ''' + return session.query(cls).get(primary_key) + __all__.append('ORMObject') ################################################################################ -- 2.39.5