Example #1
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')
app.initialise()


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

    def __call__(self, environ, start_response):
        environ['HTTP_HOST'] = self.site
        return self.app(environ, start_response)


if __name__ == '__main__':
    # The name of the website
    site = 'test'

    app.wsgi_app = NereidHostChangeMiddleware(app.wsgi_app, site)
    app.debug = True

    app.static_folder = '%s/static' % site
    app.run('0.0.0.0')
app.config.update(CONFIG)
app.initialise()
app.jinja_env.globals.update({'json': json, 'sample': random.sample})


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

application = Sentry(
    application, Client('http://*****:*****@sentry.openlabs.co.in/10')
)

# If the file is launched from the CLI then launch the app using the debug
# web server built into werkzeug
if __name__ == '__main__':
    class NereidTestMiddleware(object):
        def __init__(self, app, site):
            self.app = app
            self.site = site

        def __call__(self, environ, start_response):
            environ['HTTP_HOST'] = self.site
            return self.app(environ, start_response)
    site = 'my.openlabs.co.in:5000'
    app.wsgi_app = NereidTestMiddleware(app.wsgi_app, site)
    app.debug = False
    app.static_folder = '%s/static' % (cwd,)
    app.session_interface.session_store = \
            FilesystemSessionStore('/tmp', session_class=Session)
    app.run('0.0.0.0')
Example #4
0
babelized_app = Babel(app)
application = babelized_app.app.wsgi_app

application = Sentry(
    application,
    Client(
        'http://*****:*****@sentry.openlabs.co.in/10'
    ))

# If the file is launched from the CLI then launch the app using the debug
# web server built into werkzeug
if __name__ == '__main__':

    class NereidTestMiddleware(object):
        def __init__(self, app, site):
            self.app = app
            self.site = site

        def __call__(self, environ, start_response):
            environ['HTTP_HOST'] = self.site
            return self.app(environ, start_response)

    site = 'my.openlabs.co.in:5000'
    app.wsgi_app = NereidTestMiddleware(app.wsgi_app, site)
    app.debug = False
    app.static_folder = '%s/static' % (cwd, )
    app.session_interface.session_store = \
            FilesystemSessionStore('/tmp', session_class=Session)
    app.run('0.0.0.0')