from inspect import getargspec
-from sqlalchemy import create_engine, Table, MetaData, select
+from sqlalchemy import create_engine, Table, MetaData
from sqlalchemy.orm import sessionmaker, mapper, relation
# Don't remove this, we re-export the exceptions to scripts which import us
private_transaction = False
# Find the session object
- try:
- session = kwargs['session']
- except KeyError:
+ session = kwargs.get('session')
+
+ if session is None:
if len(args) <= len(getargspec(fn)[0]) - 1:
# No session specified as last argument or in kwargs
private_transaction = True
else:
# Session is last argument in args
session = args[-1]
+ if session is None:
+ args = list(args)
+ session = args[-1] = DBConn().session()
+ private_transaction = True
if private_transaction:
session.commit_or_flush = session.commit
# them (if one doesn't already exist)
for dsc_file in changes.dsc_files.keys():
# Skip all files except orig tarballs
+ from daklib.regexes import re_is_orig_source
if not re_is_orig_source.match(dsc_file):
continue
# Skip orig files not identified in the pool