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
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
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
def db(): app = App(__name__) db = Database(app, config=sdict(uri='sqlite:memory', auto_migrate=True, auto_connect=True)) db.define_models(Register) return db
def db(): app = App(__name__) db = DAL(app, config=sdict(uri='sqlite://dal.db')) db.define_models([ Stuff, Person, Thing, Feature, Price, Doctor, Patient, Appointment, House, Mouse, NeedSplit, Zoo, Animal, Elephant ]) return db
def db(): app = App(__name__) db = DAL(app, config=sdict(uri='sqlite://validators.db')) db.define_models([ A, AA, AAA, B, Consist, Len, Inside, Num, Eq, Match, Anyone, Proc, Person, Thing, Allowed, Mixed ]) return db
def db(): app = App(__name__) db = Database(app, config=sdict(uri='sqlite://dal.db')) db.define_models([ Stuff, Person, Thing, Feature, Price, Doctor, Patient, Appointment, User, Organization, Membership, House, Mouse, NeedSplit, Zoo, Animal, Elephant, Dog, Subscription ]) return db
def db(): app = App(__name__) db = Database(app, config=sdict(uri='sqlite://validators.db', auto_connect=True, auto_migrate=True)) db.define_models([ A, AA, AAA, B, Consist, Len, Inside, Num, Eq, Match, Anyone, Proc, Person, Thing, Allowed, Mixed ]) return db
# -*- coding: utf-8 -*- from weppy import App, session, now, url, redirect, abort from weppy.orm import Database, Model, Field, belongs_to, has_many from weppy.tools import requires from weppy.tools.auth import Auth, AuthUser from weppy.sessions import SessionCookieManager app = App(__name__) app.config.auth.single_template = True app.config.auth.registration_validation = False app.config.auth.hmac_key = "MassiveDynamicRules" #: define models class User(AuthUser): # will create "auth_user" table and groups/permissions ones has_many('posts', 'comments') class Post(Model): belongs_to('user') has_many('comments') title = Field() text = Field('text') date = Field('datetime') default_values = {'user': lambda: session.auth.user.id, 'date': now} validation = {'title': {'presence': True}, 'text': {'presence': True}} fields_rw = {'user': False, 'date': False}
import copy import time import os import time from datetime import datetime, timedelta from operator import attrgetter import winsound from lockfile import LockFile from operator import attrgetter from euristiche import Euristiche from node import Node from arc import Arc from weppy import App, request from weppy.tools import service app = App(__name__) key_googleMaps1 = "AIzaSyB27xz94JVRPsuX4qJMMiZpGVoQiQITFb8" key_googleMaps = "AIzaSyDEeQ7ybauE3th_3d-GQZQcvGI-UxKOFF8" key_googleMaps3 = "AIzaSyC549poFoVcUz3BsDOJ9XpO7CniNTDC6b4" key_googleMaps4 = "AIzaSyCGikzsm0Bc1uOQzDX78Q15fUCXFV6C1ZQ" key_googleMaps5 = "AIzaSyBU1ZCLrPVP3jO--jkEO7aILisum9ip73I" key_googleMaps6 = "AIzaSyC2jdBIolYJ3ttIuDn2AGdbBCDjLHzm2Cg" key_googleMaps7 = "AIzaSyAXKpiXm64FfQxXRym4gLqNipU2wgVHG0w" isTest = False isBenchmark = False isLoop = False ncycle = 1 def createNode(dati_dict): node_dict = collections.OrderedDict()
# -*- coding: utf-8 -*- import os from weppy import App from weppy.cache import Cache, RedisCache from weppy.orm import Database from weppy_haml import Haml from weppy_sentry import Sentry 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 weppy import App, request app = App(__name__) @app.route('/') def welcome(): # request.params 작동이 좀 특이함. 다른 건 빡빡한데 얘는 왜 그냥 None 주지? return dict(name=request.params.name or 'world') @app.route('/posts', methods='get') def post_list(): return '왜 methods가 옵션인 거죠? JAX-RS보다 나쁘잖아요?' @app.route('/posts/<int:post_id>', methods='get') def post_detail(post_id): # 1. post_id가 int 타입이 아니면 “Invalid action” 에러가 난다. # 2. int라고 했지만 post_id는 결국 문자열로 들어온다. return 'Post - %s' % post_id if __name__ == '__main__': app.run()
from weppy import App, session, redirect, url, response, request from weppy.sessions import SessionManager, current from weppy.tools import service 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)
# -*- coding: utf-8 -*- from weppy import App, session, now, url, redirect, abort from weppy.orm import Database, Model, Field, belongs_to, has_many from weppy.tools import requires from weppy.tools.auth import Auth, AuthUser from weppy.sessions import SessionManager app = App(__name__) app.config.auth.single_template = True app.config.auth.registration_verification = False app.config.auth.hmac_key = "MassiveDynamicRules" #: define models class User(AuthUser): # will create "auth_user" table and groups/permissions ones has_many('posts', 'comments') class Post(Model): belongs_to('user') has_many('comments') title = Field() text = Field.text() date = Field.datetime() default_values = { 'user': lambda: session.auth.user.id,
# -*- coding: utf-8 -*- from weppy import App, session, now, url, redirect, abort from weppy.orm import Database, Model, Field, belongs_to, has_many from weppy.tools import requires from weppy.tools.auth import Auth, AuthUser from weppy.sessions import SessionCookieManager app = App(__name__) app.config.auth.single_template = True app.config.auth.registration_verification = False app.config.auth.hmac_key = "MassiveDynamicRules" #: define models class User(AuthUser): # will create "auth_user" table and groups/permissions ones has_many('posts', 'comments') class Post(Model): belongs_to('user') has_many('comments') title = Field() text = Field('text') date = Field('datetime') default_values = { 'user': lambda: session.auth.user.id,
from weppy import App from weppy.dal import Field, Model from weppy import DAL from weppy.tools import service app = App(__name__) app.config.db.uri = 'sqlite://corals.db' class Coral(Model): file = Field('text') species = Field('text') date = Field('text') score = Field('float') rank = Field('int') db = DAL(app, auto_migrate=False) app.common_handlers = [ db.handler, ] db.define_models(Coral) rows = Coral.all().select() @app.route("/") def corals(): return None
def app(): app = App(__name__) app.language_write = True delattr(Tinstance, '_t') return app
from weppy import App, DAL from weppy.tools import Auth from weppy.sessions import SessionCookieManager ## init our app app = App(__name__) app.config.static_version = '0.1.0' app.config.static_version_urls = True app.config.url_default_namespace = "main" ## language settings app.languages = ['en', 'it'] app.language_default = 'en' app.language_force_on_url = True 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 = DAL(app) auth = Auth( app, db, usermodel=User, mailer=None, base_url="/account" ) auth.settings.update(download_url='/download') db.define_models([Campaign, Donation, Cost])
from weppy import App, DAL from weppy.sessions import SessionCookieManager from weppy.tools import Auth app = App(__name__, template_folder="./views") # Config app.config.url_default_namespace = "main" app.config.templates_auto_reload = True app.config.db.adapter = "sqlite" app.config.db.host = "127.0.0.1" # Language settings app.languages = ['en'] app.language_default = 'en' app.language_force_on_url = True app.language_write = True # init database and auth from <%= appName %>.models.user import User # init auth before passing db models due to dependencies # on auth tables in the other models db = DAL(app) auth = Auth( app, db, usermodel=User ) # adding sessions and authorization handlers from <%= appName %>.utils import get_cryptogen_string app.route.common_handlers = [
def app(): rv = App(__name__) rv.config.db.uri = 'sqlite:memory' return rv
from weppy import App, DAL, request, session, abort from weppy.dal import Field, Model from weppy.tools.auth import AuthUser from weppy.tools import Auth from weppy.sessions import SessionCookieManager app = App(__name__) class User(AuthUser): # will create "users" table and groups/permissions ones has_many('posts', 'comments') pass class Post(Model): belongs_to('user') has_many('comments') title = Field() text = Field('text') date = Field('datetime') default_values = { 'user': lambda: session.auth.user.id, 'date': lambda: request.now } validation = { 'title': {'presence': True}, 'text': {'presence': True} } form_rw = { 'user': False, 'date': False }
from weppy import App from weppy.orm import Database from weppy.tools import Auth from weppy.sessions import SessionManager ## init our app app = App(__name__) app.config.static_version = '0.1.0' app.config.static_version_urls = True app.config.url_default_namespace = "main" app.config.auth.hmac_key = "99b2fdd8-3622-4237-9f1b-9ce4445045d9" app.config.auth.registration_verification = False app.config.auth.single_template = True ## language settings app.languages = ['en', 'it'] app.language_default = 'en' app.language_force_on_url = True 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)
def app(): app = App(__name__) app.languages = ['en', 'it'] app.language_default = 'en' app.language_force_on_url = True return app
def app(): app = App(__name__) return app
from weppy import App, DAL from weppy.tools import Auth from weppy.sessions import SessionCookieManager ## init our app app = App(__name__) app.config.static_version = '0.1.0' app.config.static_version_urls = True app.config.url_default_namespace = "main" ## language settings app.languages = ['en', 'it'] app.language_default = 'en' app.language_force_on_url = True 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 = DAL(app) auth = Auth( app, db, usermodel=User, base_url="account" ) auth.settings.update(download_url='/download') db.define_models(Campaign, Donation, Cost) ## adding sessions and authorization handlers
import os import sys from functools import partial from random import randint from weppy import App, request, response from weppy.orm import Database, Model, Field, rowmethod from weppy.tools import service _is_pypy = hasattr(sys, 'pypy_version_info') if sys.version_info[0] == 3: xrange = range DBHOSTNAME = os.environ.get('DBHOST', 'localhost') app = App(__name__) class World(Model): tablename = "world" randomnumber = Field.int() @rowmethod('serialize') def _serialize(self, row): return {'id': row.id, 'randomNumber': row.randomnumber} class Fortune(Model): tablename = "fortune" message = Field.string() @rowmethod('serialize')
def test_user_assign_valid_level(): app = App(__name__) app.config.logging.pytest = sdict(level='info') result = _call_create_logger(app) assert result.handlers[-1].level == logging.INFO
from weppy import App, request, session, url, redirect, abort from weppy.dal import DAL, Field, Model, AuthModel from weppy.validators import isntEmpty from weppy.tools import Auth, requires from weppy.sessions import SessionCookieManager app = App(__name__) #: define models class User(AuthModel): # will create "auth_user" table and groups/permissions ones pass class Post(Model): tablename = "posts" fields = [ Field("author", "reference auth_user", default=lambda: session.auth.user.id), Field("title"), Field("text", "text"), Field("date", "datetime", default=lambda: request.now) ] visibility = { "author": (False, False), "date": (False, False) } validators = { "title": isntEmpty(),
from weppy import App, DAL from weppy.tools import Auth from weppy.sessions import SessionCookieManager ## init our app app = App(__name__) app.config.static_version = '0.1.0' app.config.static_version_urls = True app.config.url_default_namespace = "main" ## language settings app.languages = ['en', 'it'] app.language_default = 'en' app.language_force_on_url = True 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 = DAL(app) auth = Auth(app, db, usermodel=User, mailer=None, base_url="/account") auth.settings.update(download_url='/download') db.define_models([Campaign, Donation, Cost]) ## adding sessions and authorization handlers app.expose.common_handlers = [ SessionCookieManager('verySecretKey'), db.handler, auth.handler
def test_user_no_assign_level(): app = App(__name__) app.config.logging.pytest = sdict() result = _call_create_logger(app) assert result.handlers[-1].level == logging.WARNING
import sys from functools import partial from random import randint from weppy import App, Pipe, request, response from weppy.orm import Database, Model, Field, rowmethod from weppy.tools import service from email.utils import formatdate _is_pypy = hasattr(sys, 'pypy_version_info') if sys.version_info[0] == 3: xrange = range DBHOSTNAME = 'tfb-database' app = App(__name__) class World(Model): tablename = "world" randomnumber = Field.int() @rowmethod('serialize') def _serialize(self, row): return {'id': row.id, 'randomNumber': row.randomnumber} class Fortune(Model): tablename = "fortune" message = Field.string() @rowmethod('serialize')
def db(): app = App(__name__) db = DAL(app) db.define_models([TModel]) return db
def app(): rv = App(__name__) rv.config.mailer.sender = '*****@*****.**' return rv
import os from weppy import App app = App(__name__) @app.route('/') def welcome_index(): return 'Hello World test' if __name__ == "__main__": # important !!!!!!! 5000 or PORT env of Heroku port = os.getenv('PORT', 5000) app.run(host='0.0.0.0', port=int(port), debug=True)
from weppy import App, request, session, url, redirect, abort from weppy.dal import DAL, Field, Model, belongs_to, has_many from weppy.tools import requires from weppy.tools.auth import Auth, AuthUser from weppy.sessions import SessionCookieManager app = App(__name__) #: define models class User(AuthUser): # will create "auth_user" table and groups/permissions ones has_many('posts', 'comments') class Post(Model): belongs_to('user') has_many('comments') title = Field() text = Field('text') date = Field('datetime') default_values = { 'user': lambda: session.auth.user.id, 'date': lambda: request.now } validation = { 'title': {'presence': True}, 'text': {'presence': True}
def db(): app = App(__name__) db = Database(app, config=sdict(uri='sqlite:memory')) auth = Auth(app, db, usermodel=User) db.define_models(Thing) return db
from weppy import Cache from weppy import request from weppy import response from weppy import sdict from weppy.cache import DiskCache from apiv2_frodo import id_url from apiv2_frodo import isbn_url from apiv2_frodo import get_info as get_info_byurl from apiv2 import get_info as get_info_byid from search import search_pc from const import const app = App(__name__) app.config.logging.logfile = sdict(level="debug", max_size=100 * 1024 * 1024) cache = Cache(disk=DiskCache()) cache.clear = cache.disk.clear def vjson(version): def jsonresp(func): @functools.wraps(func) def dumpjson(*args, **kwargs): response.headers[ 'Content-Type'] = 'application/json; charset=utf-8' obj = func(*args, **kwargs) obj['version'] = version
import os import sys from functools import partial from random import randint from weppy import App, request, response from weppy.orm import Database, Model, Field, rowmethod from weppy.tools import service _is_pypy = hasattr(sys, 'pypy_version_info') if sys.version_info[0] == 3: xrange = range DBHOSTNAME = os.environ.get('DBHOST', 'localhost') app = App(__name__) class World(Model): tablename = "world" randomnumber = Field('int') @rowmethod('serialize') def _serialize(self, row): return {'id': row.id, 'randomNumber': row.randomnumber} class Fortune(Model): tablename = "fortune" message = Field() @rowmethod('serialize')
def initialize_database(): app = App('app') app.config_from_yaml('db.yml', 'db') db = Database(app) db.define_models(SpectrumAnalyzer, FieldProbe, Scan, ScanResult) return db
def app(): app = App(__name__) app.config.templates_escape = 'all' return app
import json 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")