Ejemplo n.º 1
0
def action_runfcgi():
    from flup.server.fcgi import WSGIServer
    workpath = dirname(argv[0])
    config = config_generate()
    application = make_app(config)
    bindaddr = pathjoin(workpath, "werkzeug.sock")
    print "Binding to %s" % (bindaddr,)
    WSGIServer(application, bindAddress=bindaddr).run()
Ejemplo n.º 2
0
from lodgeit import local
from lodgeit.application import make_app
from lodgeit.database import db

dburi = 'sqlite:////tmp/lodgeit.db'

SECRET_KEY = 'no secret key'


def run_app(app, path='/'):
    env = create_environ(path, SECRET_KEY)
    return run_wsgi_app(app, env)


action_runserver = script.make_runserver(
    lambda: make_app(dburi, SECRET_KEY, debug=True),
    use_reloader=True)


action_shell = script.make_shell(
    lambda: {
        'app': make_app(dburi, SECRET_KEY, False, True),
        'local': local,
        'db': db,
        'run_app': run_app
    },
    ('\nWelcome to the interactive shell environment of LodgeIt!\n'
     '\n'
     'You can use the following predefined objects: app, local, db.\n'
     'To run the application (creates a request) use *run_app*.')
)
Ejemplo n.º 3
0
from lodgeit.database import db
import os
import binascii

dburi = 'mysql://*****:*****@db:3306/enzotools_pastebin' % \
    os.environ["DB_ENV_MYSQL_ROOT_PASSWORD"]
SECRET_KEY = binascii.hexlify(os.urandom(24))


def run_app(app, path='/'):
    env = create_environ(path, SECRET_KEY)
    return run_wsgi_app(app, env)


action_runserver = script.make_runserver(
    lambda: make_app(dburi, SECRET_KEY, debug=True), use_reloader=True)

action_shell = script.make_shell(
    lambda: {
        'app': make_app(dburi, SECRET_KEY, False, True),
        'local': local,
        'db': db,
        'run_app': run_app
    }, ('\nWelcome to the interactive shell environment of LodgeIt!\n'
        '\n'
        'You can use the following predefined objects: app, local, db.\n'
        'To run the application (creates a request) use *run_app*.'))

if __name__ == '__main__':
    script.run()
Ejemplo n.º 4
0
from werkzeug.test import Client
from werkzeug.wrappers import BaseResponse
from lodgeit.application import make_app
from json import loads

client = Client(make_app('sqlite://', 'NONE', False, True), BaseResponse)


def is_json(response):
    """True if the response is JSON and the HTTP status was 200."""
    return (response.status_code == 200
            and response.headers.get('Content-Type', '') == 'application/json')


def json(response):
    """The response parsed as JSON.

    No attempt is made to ensure the response is valid or even looks
    like JSON before parsing.
    """
    return loads(response.data)
Ejemplo n.º 5
0
import os
from lodgeit.application import make_app

app = make_app(
    # the path to the database
    dburi=os.environ.get('DBURI'),
    # generate with os.urandom(30)
    secret_key=os.environ.get('SECRET_KEY', ''))
Ejemplo n.º 6
0
from nose import with_setup

from lodgeit.application import db, make_app
from lodgeit.models import Paste

foo = make_app('sqlite://', 'NONE', False, True)


def setup():
    pass


def teardown():
    Paste.query.delete()
    db.session.commit()
    db.session.remove()


def testcase():
    def dec(f):
        return with_setup(setup, teardown)(f)
    return dec

testcase.__test__ = False
Ejemplo n.º 7
0
def run_app(app, path='/'):
    config = config_generate()
    env = create_environ(path, config["secret_key"])
    return run_wsgi_app(app, env)

def action_runfcgi():
    from flup.server.fcgi import WSGIServer
    workpath = dirname(argv[0])
    config = config_generate()
    application = make_app(config)
    bindaddr = pathjoin(workpath, "werkzeug.sock")
    print "Binding to %s" % (bindaddr,)
    WSGIServer(application, bindAddress=bindaddr).run()

action_runserver = script.make_runserver(
    lambda: make_app(config_generate(), debug=True),
    use_reloader=True)

action_shell = script.make_shell(
    lambda: {
        'app': make_app(config_generate(), False, True),
        'local': local,
        'db': db,
        'run_app': run_app,
    },
    ('\nWelcome to the interactive shell environment of LodgeIt!\n'
     '\n'
     'You can use the following predefined objects: app, local, db.\n'
     'To run the application (creates a request) use *run_app*.')
)
Ejemplo n.º 8
0
from lodgeit import local
from lodgeit.application import make_app
from lodgeit.database import session

dburi = 'sqlite:////tmp/lodgeit.db'

SECRET_KEY = 'no secret key'


def run_app(app, path='/'):
    env = create_environ(path, SECRET_KEY)
    return run_wsgi_app(app, env)


action_runserver = script.make_runserver(lambda: make_app(dburi, SECRET_KEY),
                                         use_reloader=True)

action_shell = script.make_shell(
    lambda: {
        'app': make_app(dburi, SECRET_KEY, False, True),
        'local': local,
        'session': session,
        'run_app': run_app
    }, ('\nWelcome to the interactive shell environment of LodgeIt!\n'
        '\n'
        'You can use the following predefined objects: app, local, session.\n'
        'To run the application (creates a request) use *run_app*.'))

if __name__ == '__main__':
    script.run()
Ejemplo n.º 9
0
from werkzeug.test import Client
from werkzeug.wrappers import BaseResponse
from lodgeit.application import make_app
from json import loads

client = Client(make_app('sqlite://', 'NONE', False, True), BaseResponse)


def is_json(response):
    """True if the response is JSON and the HTTP status was 200."""
    return (response.status_code == 200 and
            response.headers.get('Content-Type', '') == 'application/json')


def json(response):
    """The response parsed as JSON.

    No attempt is made to ensure the response is valid or even looks
    like JSON before parsing.
    """
    return loads(response.data)
Ejemplo n.º 10
0
from nose import with_setup

from lodgeit.application import db, make_app
from lodgeit.models import Paste

foo = make_app('sqlite://', 'NONE', False, True)


def setup():
    pass


def teardown():
    Paste.query.delete()
    db.session.commit()
    db.session.remove()


def testcase():
    def dec(f):
        return with_setup(setup, teardown)(f)

    return dec


testcase.__test__ = False