]> err.no Git - dak/commitdiff
changes: Use @session_wrapper
authorFrank Lichtenheld <djpig@debian.org>
Fri, 30 Oct 2009 22:02:47 +0000 (22:02 +0000)
committerFrank Lichtenheld <djpig@debian.org>
Fri, 30 Oct 2009 22:02:47 +0000 (22:02 +0000)
Signed-off-by: Frank Lichtenheld <djpig@debian.org>
daklib/changes.py
daklib/dbconn.py

index fd09cb7f2086b4c96ebaeffd21da5a047ef6a31a..dd5e373c87dc33942909f51dde3aa3a98634cc15 100755 (executable)
@@ -177,31 +177,20 @@ class Changes(object):
 
         return summary
 
+    @session_wrapper
     def remove_known_changes(self, session=None):
-        if session is None:
-            session = DBConn().session()
-            privatetrans = True
-
         session.delete(get_knownchange(self.changes_file, session))
 
-        if privatetrans:
-            session.commit()
-            session.close()
-
-
     def mark_missing_fields(self):
         """add "missing" in fields which we will require for the known_changes table"""
         for key in ['urgency', 'maintainer', 'fingerprint', 'changed-by' ]:
             if (not self.changes.has_key(key)) or (not self.changes[key]):
                 self.changes[key]='missing'
 
+    @session_wrapper
     def add_known_changes(self, dirpath, session=None):
         """add "missing" in fields which we will require for the known_changes table"""
         cnf = Config()
-        privatetrans = False
-        if session is None:
-            session = DBConn().session()
-            privatetrans = True
 
         changesfile = os.path.join(dirpath, self.changes_file)
         filetime = datetime.datetime.fromtimestamp(os.path.getctime(changesfile))
index bdb9ab4f0373560b954205c5e37477b9628fe775..bdd72fb322ac94cd9e533b1d668f53d21afed2b6 100755 (executable)
@@ -124,6 +124,8 @@ def session_wrapper(fn):
 
     return wrapped
 
+__all__.append('session_wrapper')
+
 ################################################################################
 
 class Architecture(object):