Ejemplo n.º 1
0
    def get_app(self, **options):
        app = NereidTestApp(template_folder=os.path.abspath(
            os.path.join(os.path.dirname(__file__), 'templates')))
        if 'SECRET_KEY' not in options:
            options['SECRET_KEY'] = 'secret-key'
        app.config['TEMPLATE_PREFIX_WEBSITE_NAME'] = False
        app.config.update(options)
        app.config['DATABASE_NAME'] = DB_NAME
        app.config['DEBUG'] = True
        app.session_interface.session_store = \
            FilesystemSessionStore('/tmp', session_class=Session)

        # Initialise the app now
        app.initialise()

        # Load babel as its a required extension anyway
        Babel(app)
        return app
Ejemplo n.º 2
0
def get_app(**options):
    app = NereidTestApp()
    if 'SECRET_KEY' not in options:
        options['SECRET_KEY'] = 'secret-key'
    app.config.update(options)
    from trytond.tests.test_tryton import DB_NAME
    app.config['DATABASE_NAME'] = DB_NAME
    app.config['DEBUG'] = True
    app.session_interface.session_store = \
        FilesystemSessionStore('/tmp', session_class=Session)

    # loaders is usually lazy loaded
    # Pre-fetch it so that the instance attribute _loaders will exist
    app.jinja_loader.loaders

    # Initialise the app now
    app.initialise()

    # Load babel as its a required extension anyway
    Babel(app)
    return app
Ejemplo n.º 3
0
    # If the application is to be configured in the debug mode
    DEBUG=False,

    # Load the template from FileSystem in the path below instead of the
    # default Tryton loader where templates are loaded from Database
    TEMPLATE_LOADER_CLASS='nereid.templating.FileSystemLoader',
    TEMPLATE_SEARCH_PATH='.',

    # The location where the translations of this template are stored
    TRANSLATIONS_PATH='i18n',
)

# Create a new application
app = Nereid(static_folder='%s/static/' % CWD, static_url_path='/static')

# Update the configuration with the above config values
app.config.update(CONFIG)

# Initialise the app, connect to cache and backend
app.initialise()

# Setup the filesystem cache
app.session_interface.session_store = FilesystemSessionStore(
    '/tmp', session_class=Session)

Babel(app)

if __name__ == '__main__':
    app.debug = True
    app.run('0.0.0.0')
Ejemplo n.º 4
0
    TEMPLATE_SEARCH_PATH='%s/templates/' % cwd,
    TRANSLATIONS_PATH='%s/i18n/' % cwd,
)

# Create a new application
app = Nereid()
app.session_interface.session_store = FilesystemSessionStore(
    '/tmp', session_class=Session)

# Update the configuration with the above config values
app.config.update(CONFIG)

# Initialise the app, connect to cache and backend
app.initialise()

babelized_app = Babel(app)
application = babelized_app.app.wsgi_app


class NereidHostChangeMiddleware(object):
    """
    A middleware which alters the HTTP_HOST so that you can test
    the site locally. This middleware replaces the HTTP_HOST with
    the value you prove to the :attr: site

    :param app: The application for which the middleware needs to work
    :param site: The value which should replace HTTP_HOST WSGI Environ
    """
    def __init__(self, app, site):
        self.app = app
        self.site = site