def setUpClass(cls):
        '''Set up fixtures for the class.

        This methods runs once for the entire class. This test case do not
        insert or update any record on the database, so there is no problem
        to be run only once for the class.

        This way it save some time, instead of populate the test database
        each time a test is executed.
        '''
        admin = create_admin()
        app = create_app(config='quokka.test_settings',
                         DEBUG=False,
                         test=True,
                         admin_instance=admin)

        with app.app_context():
            db = list(app.extensions.get('mongoengine').keys())[0]
            db.connection.drop_database('quokka_test')
            from quokka.utils.populate import Populate
            Populate(db)()
        cls.app = app
        cls.db = db
    def setUpClass(cls):
        '''Set up fixtures for the class.

        This methods runs once for the entire class. This test case do not
        insert or update any record on the database, so there is no problem
        to be run only once for the class.

        This way it save some time, instead of populate the test database
        each time a test is executed.
        '''
        admin = create_admin()
        app = create_app(config='quokka.test_settings',
                         DEBUG=False,
                         test=True,
                         admin_instance=admin)

        with app.app_context():
            db = list(app.extensions.get('mongoengine').keys())[0]
            db.connection.drop_database('quokka_test')
            from quokka.utils.populate import Populate
            Populate(db)()
        cls.app = app
        cls.db = db
Ejemplo n.º 3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask.ext.script import Manager, Server
from flask.ext.collect import Collect
from quokka import create_app
from quokka.core.db import db
from quokka.ext.blueprints import load_blueprint_commands

app = create_app()
manager = Manager(app)
manager.add_option("-c", "--config",
                   dest="config", required=False,
                   default='quokka.settings')

collect = Collect()
collect.init_script(manager)


@manager.shell
def make_shell_context():
    " Update shell. "
    return dict(app=app, db=db)


@manager.command
def check():
    """Prints app status"""
    from pprint import pprint
    print("Extensions.")
    pprint(app.extensions)
Ejemplo n.º 4
0
def app():
    app = create_app(config='quokka.test_settings',
                     DEBUG=False,
                     test=True,
                     mode='test')
    return app
Ejemplo n.º 5
0
see this post
http://www.onurguzel.com/
how-to-run-flask-applications-with-nginx-using-gunicorn/
"""

import argparse
from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware
from werkzeug.contrib.fixers import ProxyFix
from quokka import create_app, create_api
from quokka.utils.paas import activate

# If running on PAAS such as OpenShift or heroku may require venv activation
activate()

application = DispatcherMiddleware(create_app(), {'/api': create_api()})

application.wsgi_app = ProxyFix(application.app.wsgi_app)

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Run Quokka App for WSGI")
    parser.add_argument('-p', '--port', help='App Port')
    parser.add_argument('-i', '--host', help='App Host')
    parser.add_argument('-r',
                        '--reloader',
                        action='store_true',
                        help='Turn reloader on')
    parser.add_argument('-d',
                        '--debug',
                        action='store_true',
                        help='Turn debug on')
Ejemplo n.º 6
0
import sys
if len(sys.argv) > 1 and sys.argv[1] == "-r":
    reloader = True
else:
    reloader = False

from quokka import create_app
app = create_app()
app.run(use_reloader=reloader)
def app():
    app = create_app(config='quokka.test_settings',
                     DEBUG=False,
                     test=True,
                     mode='test')
    return app
Ejemplo n.º 8
0
 def create_app(self):
     self.admin = create_admin()
     return create_app(config='quokka.test_settings',
                       DEBUG=False,
                       test=True,
                       admin_instance=self.admin)
 def create_app(self):
     return create_app(config='quokka.test_settings',
                       DEBUG=False,
                       test=True)
Ejemplo n.º 10
0
 def create_app(self):
     self.admin = create_admin()
     return create_app(config='quokka.test_settings',
                       DEBUG=False,
                       test=True,
                       admin_instance=self.admin)
Ejemplo n.º 11
0
#!/usr/bin/python

import argparse
from werkzeug.serving import run_simple
from quokka import create_app

application = app = create_app(ADMIN_REQUIRES_LOGIN=True)

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Run Quokka App for WSGI")
    parser.add_argument('-p', '--port', help='App Port')
    parser.add_argument('-i', '--host', help='App Host')
    parser.add_argument('-r',
                        '--reloader',
                        action='store_true',
                        help='Turn reloader on')
    parser.add_argument('-d',
                        '--debug',
                        action='store_true',
                        help='Turn debug on')
    args = parser.parse_args()
    run_simple(
        args.host or '127.0.0.1',
        int(args.port) if args.port else 5000,
        application,
        use_reloader=args.reloader or False,
        use_debugger=args.debug or False,
    )
Ejemplo n.º 12
0
def app():
    """Flask Pytest uses it"""
    os.chdir('quokka/project_template/')
    return create_app()
Ejemplo n.º 13
0
# -*- coding: utf-8 -*-

from werkzeug.serving import run_simple
from werkzeug.contrib.fixers import ProxyFix
from quokka import create_app

application = create_app()

application.wsgi_app = ProxyFix(application.wsgi_app)
"""
see this post
http://www.onurguzel.com/
how-to-run-flask-applications-with-nginx-using-gunicorn/
"""

if __name__ == "__main__":
    run_simple('0.0.0.0',
               5000,
               application,
               use_reloader=True,
               use_debugger=True)
Ejemplo n.º 14
0
# -*- coding: utf-8 -*-

from werkzeug.serving import run_simple
from werkzeug.contrib.fixers import ProxyFix
from quokka import create_app

application = create_app()

application.wsgi_app = ProxyFix(application.wsgi_app)

"""
see this post
http://www.onurguzel.com/
how-to-run-flask-applications-with-nginx-using-gunicorn/
"""

if __name__ == "__main__":
    run_simple(
        '0.0.0.0',
        5000,
        application,
        use_reloader=True,
        use_debugger=True
    )
Ejemplo n.º 15
0
#!/usr/bin/python

import argparse
from werkzeug.serving import run_simple
from quokka import create_app

application = app = create_app(ADMIN_REQUIRES_LOGIN=True)


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Run Quokka App for WSGI")
    parser.add_argument('-p', '--port', help='App Port')
    parser.add_argument('-i', '--host', help='App Host')
    parser.add_argument('-r', '--reloader', action='store_true',
                        help='Turn reloader on')
    parser.add_argument('-d', '--debug', action='store_true',
                        help='Turn debug on')
    args = parser.parse_args()
    run_simple(
        args.host or '127.0.0.1',
        int(args.port) if args.port else 5000,
        application,
        use_reloader=args.reloader or False,
        use_debugger=args.debug or False,
    )
Ejemplo n.º 16
0
#!/usr/bin/python

import argparse
from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware
from quokka import create_app, create_api
from quokka.utils.paas import activate

application = DispatcherMiddleware(create_app(), {
    '/api': create_api()
})

application = app = activate(application)


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Run Quokka App for WSGI")
    parser.add_argument('-p', '--port', help='App Port')
    parser.add_argument('-i', '--host', help='App Host')
    parser.add_argument('-r', '--reloader', action='store_true',
                        help='Turn reloader on')
    parser.add_argument('-d', '--debug', action='store_true',
                        help='Turn debug on')
    args = parser.parse_args()
    run_simple(
        args.host or '0.0.0.0',
        int(args.port) if args.port else 5000,
        application,
        use_reloader=args.reloader or False,
        use_debugger=args.debug or False,
    )
#!/usr/bin/python
"""
see this post
http://www.onurguzel.com/
how-to-run-flask-applications-with-nginx-using-gunicorn/
"""

import argparse
from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware
from werkzeug.contrib.fixers import ProxyFix
from quokka import create_app, create_api
from quokka.utils.paas import activate


application = DispatcherMiddleware(create_app(), {
    '/api': create_api()
})

application.wsgi_app = ProxyFix(application.app.wsgi_app)

application = app = activate(application)

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Run Quokka App for WSGI")
    parser.add_argument('-p', '--port', help='App Port')
    parser.add_argument('-i', '--host', help='App Host')
    parser.add_argument('-r', '--reloader', action='store_true',
                        help='Turn reloader on')
    parser.add_argument('-d', '--debug', action='store_true',
                        help='Turn debug on')