예제 #1
0
def setup_app(command, conf, vars):
    """Place any commands to setup wombat here"""
    load_environment(conf.global_conf, conf.local_conf)

    # Create cache dir, if it doesn't exist yet
    import os
    import os.path
    if not os.path.exists(config['app_conf']['cache_dir']):
        os.makedirs(config['app_conf']['cache_dir'])

    # Populate the DB on 'paster setup-app'
    import wombat.model as model
    # Create the tables if they don't already exist
    meta.metadata.create_all(bind=meta.engine)
    create_roles(model)

    answer = ""

    if config['app_conf']['create_superuser'] == "false":
        answer = "n"

    while not answer in ("y", "n"):
        print "Set up superuser account now? (Y/N)"
        answer = sys.stdin.readline().strip().lower()

    if answer == "y":
        setup_superuser(model)
예제 #2
0
def setup_app(command, conf, vars):
    """Place any commands to setup wombat here"""
    load_environment(conf.global_conf, conf.local_conf)

    # Create cache dir, if it doesn't exist yet
    import os
    import os.path
    if not os.path.exists(config['app_conf']['cache_dir']):
        os.makedirs(config['app_conf']['cache_dir'])

    # Populate the DB on 'paster setup-app'
    import wombat.model as model
    # Create the tables if they don't already exist
    meta.metadata.create_all(bind=meta.engine)
    create_roles(model)

    answer = ""

    if config['app_conf']['create_superuser'] == "false":
        answer = "n"

    while not answer in ("y", "n"):
        print "Set up superuser account now? (Y/N)"
        answer = sys.stdin.readline().strip().lower()

    if answer == "y":
        setup_superuser(model)
예제 #3
0
def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
    """Create a Pylons WSGI application and return it

    ``global_conf``
        The inherited configuration for this application. Normally from
        the [DEFAULT] section of the Paste ini file.

    ``full_stack``
        Whether or not this application provides a full WSGI stack (by
        default, meaning it handles its own exceptions and errors).
        Disable full_stack when this application is "managed" by
        another WSGI middleware.

    ``app_conf``
        The application's local configuration. Normally specified in the
        [app:<name>] section of the Paste ini file (where <name>
        defaults to main).
    """
    # Configure the Pylons environment
    load_environment(global_conf, app_conf)

    # The Pylons WSGI app
    app = PylonsApp()

    app = RoutesMiddleware(app, config['routes.map'])
    app = SessionMiddleware(app, config)
    app = CacheMiddleware(app, config)

    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)

    if asbool(full_stack):
        # Handle Python exceptions
        app = ErrorHandler(app, global_conf, **config['pylons.errorware'])

        # Display error documents for 401, 403, 404 status codes (and
        # 500 when debug is disabled)
        if asbool(config['debug']):
            app = StatusCodeRedirect(app)
        else:
            app = StatusCodeRedirect(app, [401, 403, 404, 500])

    # Establish the Registry for this application
    app = RegistryManager(app)

    # Static files
    if asbool(static_files):
        static_app = StaticURLParser(config['pylons.paths']['static_files'])
        media_app = StaticURLParser(config['app_conf']['media_dir'])
        thumb_app = StaticURLParser(config['app_conf']['thumb_dir'])
        urlmap = URLMap()
        urlmap['/media'] = media_app
        urlmap['/thumb'] = thumb_app
        app = Cascade([urlmap, static_app, app])
    return app
예제 #4
0
def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
    """Create a Pylons WSGI application and return it

    ``global_conf``
        The inherited configuration for this application. Normally from
        the [DEFAULT] section of the Paste ini file.

    ``full_stack``
        Whether or not this application provides a full WSGI stack (by
        default, meaning it handles its own exceptions and errors).
        Disable full_stack when this application is "managed" by
        another WSGI middleware.

    ``app_conf``
        The application's local configuration. Normally specified in the
        [app:<name>] section of the Paste ini file (where <name>
        defaults to main).
    """
    # Configure the Pylons environment
    load_environment(global_conf, app_conf)

    # The Pylons WSGI app
    app = PylonsApp()

    app = RoutesMiddleware(app, config['routes.map'])
    app = SessionMiddleware(app, config)
    app = CacheMiddleware(app, config)

    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)

    if asbool(full_stack):
        # Handle Python exceptions
        app = ErrorHandler(app, global_conf, **config['pylons.errorware'])

        # Display error documents for 401, 403, 404 status codes (and
        # 500 when debug is disabled)
        if asbool(config['debug']):
            app = StatusCodeRedirect(app)
        else:
            app = StatusCodeRedirect(app, [401, 403, 404, 500])

    # Establish the Registry for this application
    app = RegistryManager(app)

    # Static files
    if asbool(static_files):
        static_app = StaticURLParser(config['pylons.paths']['static_files'])
        media_app = StaticURLParser(config['app_conf']['media_dir'])
        thumb_app = StaticURLParser(config['app_conf']['thumb_dir'])
        urlmap = URLMap()
        urlmap['/media'] = media_app
        urlmap['/thumb'] = thumb_app
        app = Cascade([urlmap, static_app, app])
    return app