'Helper method that implements the logic to look up an
application.'

def get_app(self, reference_app=None):

    if (reference_app is not None):
        return reference_app
    if current_app:
        return current_app
    if (self.app is not None):
        return self.app
    raise RuntimeError('application    not    registered    on    db    instance    and    no    applicationbound    to    current    context')
