Esempio n. 1
0
def app():
    rv = App(__name__)
    rv.config.mailer.sender = '*****@*****.**'
    rv.config.auth.single_template = True
    rv.config.auth.hmac_key = "foobar"
    rv.pipeline = [SessionCookieManager('foobar')]
    return rv
Esempio n. 2
0
def app():
    rv = App(__name__)
    rv.config.mailer.sender = '*****@*****.**'
    rv.config.auth.single_template = True
    rv.config.auth.hmac_key = "foobar"
    rv.pipeline = [SessionManager.cookies('foobar')]
    return rv
Esempio n. 3
0
def app():
    app = App(__name__)
    app.pipeline = [Pipe1(), Pipe2(), Pipe3()]

    @app.route()
    def ok():
        return "ok"

    @app.route()
    def http_error():
        abort(422)

    @app.route()
    def error():
        raise Exception

    @app.route(pipeline=[Pipe4()])
    def pipe4():
        return "4"

    mod = app.module(__name__, 'mod', url_prefix='mod')
    mod.pipeline = [Pipe5()]

    @mod.route()
    def pipe5():
        return "5"

    @mod.route(pipeline=[Pipe6()])
    def pipe6():
        return "6"

    return app
Esempio n. 4
0
def app():
    app = App(__name__)
    app.pipeline = [Pipe1(), Pipe2(), Pipe3()]

    @app.route()
    def ok():
        return "ok"

    @app.route()
    def http_error():
        abort(422)

    @app.route()
    def error():
        raise Exception

    @app.route(pipeline=[Pipe4()])
    def pipe4():
        return "4"

    mod = app.module(__name__, 'mod', url_prefix='mod')
    mod.pipeline = [Pipe5()]

    @mod.route()
    def pipe5():
        return "5"

    @mod.route(pipeline=[Pipe6()])
    def pipe6():
        return "6"

    return app
Esempio n. 5
0
                       last_name="Bishop",
                       password="******")
    # create an admin group
    admins = auth.create_group("admin")
    # add user to admins group
    auth.add_membership(admins, user.id)
    db.commit()


@app.command('setup')
def setup():
    setup_admin()


#: pipeline
app.pipeline = [SessionCookieManager('Walternate'), db.pipe, auth.pipe]


#: exposing functions
@app.route("/")
def index():
    posts = Post.all().select(orderby=~Post.date)
    return dict(posts=posts)


@app.route("/post/<int:pid>")
def one(pid):
    def _validate_comment(form):
        # manually set post id in comment form
        form.params.post = pid
Esempio n. 6
0
    def open(self):
        response.headers["Date"] = formatdate(timeval=None,
                                              localtime=False,
                                              usegmt=True)


app.config.handle_static = False
app.config.db.adapter = 'postgres:psycopg2' \
    if not _is_pypy else 'postgres:pg8000'
app.config.db.host = DBHOSTNAME
app.config.db.user = '******'
app.config.db.password = '******'
app.config.db.database = 'hello_world'
app.config.db.pool_size = 100

app.pipeline = [DateHeaderPipe()]

db = Database(app, auto_migrate=False)
db.define_models(World, Fortune)


@app.route()
@service.json
def json():
    return {'message': 'Hello, World!'}


@app.route("/db", pipeline=[db.pipe])
@service.json
def get_random_world():
    return World.get(randint(1, 10000)).serialize()
Esempio n. 7
0
## init database and auth
from models.user import User
from models.campaign import Campaign
from models.donation import Donation
from models.cost import Cost
## init auth before passing db models due to dependencies
## on auth tables in the other models
db = Database(app, auto_migrate=True)
auth = Auth(app, db, user_model=User)
# auth.settings.update(download_url='/download')
db.define_models(Campaign, Donation, Cost)

## adding sessions and authorization handlers
app.pipeline = [
    SessionManager.cookies('verySecretKey'),
    db.pipe,
    auth.pipe
]

## add esxtensions
from weppy_haml import Haml
from weppy_assets import Assets
from weppy_bs3 import BS3
app.config.Haml.set_as_default = True
# app.config.Haml.auto_reload = True
app.use_extension(Haml)
app.config.Assets.out_folder = 'gen'
app.use_extension(Assets)
app.use_extension(BS3)

## exposing functions from controllers
Esempio n. 8
0
from weppy.orm import Database
from weppy.tools import Auth, requires
from models.Models import User, Issue

app = App(__name__)
app.config.db.uri = 'postgres://*****:*****@localhost/bazinga'

app.config.auth.single_template = True
app.config.auth.registration_verification = False
app.config.auth.hmac_key = "SomedayWholePeopleWillbeFucked"

db = Database(app, auto_migrate=True)
auth = Auth(app, db, user_model=User)

app.pipeline = [
    SessionManager.cookies('SomedayWholePeopleWillbeFucked'), db.pipe,
    auth.pipe
]

db.define_models(User, Issue)

auth_routes = auth.module(__name__)


def not_authorized():
    redirect(location='/system/login', status_code=302)


@app.route('/', methods=["get"], template='pages/index.html')
def index():
    response.meta.title = 'Bazinga Issue Tracker System'
Esempio n. 9
0
from weppy import App
from weppy.orm import Database, Model, Field
from weppy.tools import service
from pymongo import MongoClient
from load import generate_load


class ExampleModel(Model):
    foo = Field.string()
    bar = Field.string()


app = App(__name__)
db = Database(app, auto_migrate=True)
db.define_models(ExampleModel)
app.pipeline = [db.pipe]

client = MongoClient()
db = client.test_database
foos = db.foos  # collection of foo objects


@app.route("/")
@service.json
def simple_json():
    return {'foo': 'bar'}


@app.route("/model")
@service.json
def model():
Esempio n. 10
0
app.language_write = True

## init database and auth
from models.user import User
from models.campaign import Campaign
from models.donation import Donation
from models.cost import Cost
## init auth before passing db models due to dependencies
## on auth tables in the other models
db = Database(app, auto_migrate=True)
auth = Auth(app, db, user_model=User)
# auth.settings.update(download_url='/download')
db.define_models(Campaign, Donation, Cost)

## adding sessions and authorization handlers
app.pipeline = [SessionManager.cookies('verySecretKey'), db.pipe, auth.pipe]

## add esxtensions
from weppy_haml import Haml
from weppy_assets import Assets
from weppy_bs3 import BS3
app.config.Haml.set_as_default = True
# app.config.Haml.auto_reload = True
app.use_extension(Haml)
app.config.Assets.out_folder = 'gen'
app.use_extension(Assets)
app.use_extension(BS3)

## exposing functions from controllers
auth_routes = auth.module(__name__, url_prefix='account')
Esempio n. 11
0
class DateHeaderPipe(Pipe):
    def open(self):
        response.headers["Date"] = formatdate(timeval=None, localtime=False, usegmt=True)


app.config.handle_static = False
app.config.db.adapter = 'postgres:psycopg2' \
    if not _is_pypy else 'postgres:pg8000'
app.config.db.host = DBHOSTNAME
app.config.db.user = '******'
app.config.db.password = '******'
app.config.db.database = 'hello_world'
app.config.db.pool_size = 100

app.pipeline = [DateHeaderPipe()]

db = Database(app, auto_migrate=False)
db.define_models(World, Fortune)


@app.route()
@service.json
def json():
    return {'message': 'Hello, World!'}


@app.route("/db", pipeline=[db.pipe])
@service.json
def get_random_world():
    return World.get(randint(1, 10000)).serialize()
Esempio n. 12
0
    )
    # create an admin group
    admins = auth.create_group("admin")
    # add user to admins group
    auth.add_membership(admins, user.id)
    db.commit()


@app.command('setup')
def setup():
    setup_admin()


#: pipeline
app.pipeline = [
    SessionManager.cookies('Walternate'), db.pipe, auth.pipe
]


#: exposing functions
@app.route("/")
def index():
    posts = Post.all().select(orderby=~Post.date)
    return dict(posts=posts)


@app.route("/post/<int:pid>")
def one(pid):
    def _validate_comment(form):
        # manually set post id in comment form
        form.params.post = pid
Esempio n. 13
0
from weppy_rest import REST, serialize

from logic.scanning import begin_scan, scan_finished_callback
from serializers.hardware import SpectrumAnalyzerSerializer, FieldProbeSerializer
from serializers.scanning import ScanSerializer, ResultSerializer, ScanResultMatSerializer
from tasks import increase_progress
from utils import CORS

app = App(__name__)
app.config.url_default_namespace = "main"
app.use_extension(BS3)
app.use_extension(REST)

app.config_from_yaml('db.yml', 'db')
db = Database(app, auto_migrate=True)
app.pipeline = [db.pipe, CORS()]

from models.hardware import SpectrumAnalyzer, FieldProbe
from models.scanning import Scan, ScanResult, XResultRow, ScanResultMat

db.define_models(SpectrumAnalyzer, FieldProbe, Scan, ScanResult, XResultRow,
                 ScanResultMat)
from controllers import main, hardware, scanning

analyzers = app.rest_module(__name__,
                            'spectrumanalyzer',
                            SpectrumAnalyzer,
                            serializer=SpectrumAnalyzerSerializer,
                            url_prefix='analyzers')
probes = app.rest_module(__name__,
                         'fieldprobe',
Esempio n. 14
0
from redis import Redis

app = App(__name__)

app.config.static_version = '1.5.0'
app.config.static_version_urls = True
app.config.url_default_namespace = "main"
app.config_from_yaml('redis.yml', 'redis')
app.config_from_yaml('sentry.yml', 'Sentry')
app.config.Haml.set_as_default = True

app.use_extension(Haml)
app.use_extension(Sentry)

from .models import Version, Extension

db = Database(app, auto_migrate=True)
db.define_models(Version, Extension)

redis = Redis(**app.config.redis)
cache = Cache(redis=RedisCache(**app.config.redis))

app.pipeline = [db.pipe]

from .controllers import main, docs, extensions
from . import commands

#: ensure 'docs' folder presence
if not os.path.exists(os.path.join(app.root_path, "docs")):
    os.mkdir(os.path.join(app.root_path, "docs"))
Esempio n. 15
0
    )
    # create an admin group
    admins = auth.create_group("admin")
    # add user to admins group
    auth.add_membership(admins, user.id)
    db.commit()


@app.command('setup')
def setup():
    setup_admin()


#: pipeline
app.pipeline = [
    SessionCookieManager('Walternate'), db.pipe, auth.pipe
]


#: exposing functions
@app.route("/")
def index():
    posts = Post.all().select(orderby=~Post.date)
    return dict(posts=posts)


@app.route("/post/<int:pid>")
def one(pid):
    def _validate_comment(form):
        # manually set post id in comment form
        form.params.post = pid
Esempio n. 16
0
from .build import build_all
from .keys import DB_PIPE_KEY
from .models import Character

app = App(__name__)

db = Database(app, auto_migrate=True)
db.define_models(Character)


@app.command('setup')
def setup():
    build_all(db)


app.pipeline = [SessionCookieManager(DB_PIPE_KEY), db.pipe]


@app.route('/')
def there_is_always_one_truth():
    return "真実はいつもひとつ!"


@app.route('/character/<int:character_id>', methods="get")
@service.json
def character(character_id):
    return db(Character.id == character_id).select().first()


@app.route('/character/<str:name>', methods="get")
@service.json