(domain, app_id, wrap_cls=None, latest=False, target=None)
Utility for getting an app, making sure it's in the domain specified, and
    wrapping it in the right class (Application or RemoteApp).

    'target' is only used if latest=True.  It should be set to one of:
       'build', 'release', or 'save'

    Here are some common usages and the simpler dbaccessor alternatives:
        current_app = get_app(domain, app_id)
                    = get_current_app_doc(domain, app_id)
        latest_released_build = get_app(domain, app_id, latest=True)
                              = get_latest_released_app_doc(domain, app_id)
        latest_build = get_app(domain, app_id, latest=True, target='build')
                     = get_latest_build_doc(domain, app_id)
    Use wrap_app() if you need the wrapped object.
Utility for getting an app, making sure it's in the domain specified, and
    wrapping it in the right class (Application or RemoteApp).
Utility for getting an app making sure it s in the domain specified and wrapping it in the right class ( Application or RemoteApp ) .
def get_app(domain, app_id, wrap_cls=None, latest=False, target=None):
    """
    Utility for getting an app, making sure it's in the domain specified, and
    wrapping it in the right class (Application or RemoteApp).

    'target' is only used if latest=True.  It should be set to one of:
       'build', 'release', or 'save'

    Here are some common usages and the simpler dbaccessor alternatives:
        current_app = get_app(domain, app_id)
                    = get_current_app_doc(domain, app_id)
        latest_released_build = get_app(domain, app_id, latest=True)
                              = get_latest_released_app_doc(domain, app_id)
        latest_build = get_app(domain, app_id, latest=True, target='build')
                     = get_latest_build_doc(domain, app_id)
    Use wrap_app() if you need the wrapped object.
    """
    from .models import Application
    if not app_id:
        raise Http404()
    try:
        app = Application.get_db().get(app_id)
    except ResourceNotFound:
        raise Http404()

    if latest:
        if not domain:
            domain = app['domain']

        if app.get('copy_of'):
            # The id passed in corresponds to a build
            app_id = app.get('copy_of')

        if target == 'build':
            app = get_latest_build_doc(domain, app_id) or app
        elif target == 'save':
            # If the app_id passed in was the working copy, just use that app.
            # If it's a build, get the working copy.
            if app.get('copy_of'):
                app = get_current_app_doc(domain, app_id)
        else:
            app = get_latest_released_app_doc(domain, app_id) or app

    if domain and app['domain'] != domain:
        raise Http404()
    try:
        return wrap_app(app, wrap_cls=wrap_cls)
    except DocTypeError:
        raise Http404()
def get_app ( domain , app_id , wrap_cls = None , latest = False , target = None ) : from . models import Application if not app_id : raise Http404 ( ) try : app = Application . get_db ( ) . get ( app_id ) except ResourceNotFound : raise Http404 ( ) if latest : if not domain : domain = app [ 'domain' ] if app . get ( 'copy_of' ) : # The id passed in corresponds to a build app_id = app . get ( 'copy_of' ) if target == 'build' : app = get_latest_build_doc ( domain , app_id ) or app elif target == 'save' : # If the app_id passed in was the working copy, just use that app. # If it's a build, get the working copy. if app . get ( 'copy_of' ) : app = get_current_app_doc ( domain , app_id ) else : app = get_latest_released_app_doc ( domain , app_id ) or app if domain and app [ 'domain' ] != domain : raise Http404 ( ) try : return wrap_app ( app , wrap_cls = wrap_cls ) except DocTypeError : raise Http404 ( )