X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdbconn.py;h=fb322aeaf674e22fa455c6af95c84e004f8d8f78;hb=a44e7de5fff597b9c2e04de3d22ae57422060f65;hp=c2de12cecc5553a1aeeb8302f42ee8f70f602dee;hpb=2f476bb0ea63798993f8777671686ddd7fb7a235;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index c2de12ce..fb322aea 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -59,12 +59,18 @@ __all__ = ['IntegrityError', 'SQLAlchemyError'] ################################################################################ def session_wrapper(fn): + """ + Wrapper around common ".., session=None):" handling. If the wrapped + function is called without passing 'session', we create a local one + and destroy it when the function ends. + """ + def wrapped(*args, **kwargs): private_transaction = False session = kwargs.get('session') # No session specified as last argument or in kwargs, create one. - if session is None and len(args) == len(getargspec(fn)[0]) - 1: + if session is None and len(args) <= len(getargspec(fn)[0]) - 1: private_transaction = True kwargs['session'] = DBConn().session() @@ -75,6 +81,9 @@ def session_wrapper(fn): # We created a session; close it. kwargs['session'].close() + wrapped.__doc__ = fn.__doc__ + wrapped.func_name = fn.func_name + return wrapped ################################################################################ @@ -165,7 +174,7 @@ __all__.append('Archive') @session_wrapper def get_archive(archive, session=None): """ - returns database id for given c{archive}. + returns database id for given C{archive}. @type archive: string @param archive: the name of the arhive @@ -1426,6 +1435,7 @@ class Queue(object): # TODO: Move into database as above if conf.FindB("Dinstall::SecurityQueueBuild"): # Copy it since the original won't be readable by www-data + import utils utils.copy(src, dest) else: # Create a symlink to it @@ -1900,7 +1910,7 @@ def get_suite(suite, session=None): generated if not supplied) @rtype: Suite - @return: Suite object for the requested suite name (None if not presenT) + @return: Suite object for the requested suite name (None if not present) """ q = session.query(Suite).filter_by(suite_name=suite)