コード例 #1
0
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
コード例 #2
0
ファイル: test_dal.py プロジェクト: hydeparkk/weppy
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,
            User,
            Organization,
            Membership,
            House,
            Mouse,
            NeedSplit,
            Zoo,
            Animal,
            Elephant,
            Dog,
            Subscription,
        ]
    )
    return db
コード例 #3
0
ファイル: test_logger.py プロジェクト: farnetani/weppy
def test_user_assign_invaild_level():
    app = App(__name__)
    app.config.logging.pytest = sdict(
        level='invalid'
    )
    result = _call_create_logger(app)
    assert result.handlers[-1].level == logging.WARNING
コード例 #4
0
ファイル: test_dal.py プロジェクト: alex-bender/weppy
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
コード例 #5
0
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
コード例 #6
0
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
コード例 #7
0
ファイル: test_validators.py プロジェクト: mulonemartin/weppy
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
コード例 #8
0
ファイル: test_validators.py プロジェクト: kooksee/weppy
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
コード例 #9
0
ファイル: test_orm.py プロジェクト: olivierh59500/weppy
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
コード例 #10
0
ファイル: test_orm.py プロジェクト: lethargilistic/weppy
def db():
    app = App(__name__)
    db = Database(
        app, config=sdict(
            uri='sqlite://dal.db', auto_connect=True, auto_migrate=True))
    db.define_models([
        Stuff, Person, Thing, Feature, Price, Doctor, Patient, Appointment,
        User, Organization, Membership, House, Mouse, NeedSplit, Zoo, Animal,
        Elephant, Dog, Subscription
    ])
    return db
コード例 #11
0
ファイル: test_validators.py プロジェクト: yws/weppy
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
コード例 #12
0
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
コード例 #13
0
ファイル: douproxy.py プロジェクト: alingse/douproxy
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
            return json.dumps(obj, ensure_ascii=False).encode('utf-8')
コード例 #14
0
ファイル: parsers.py プロジェクト: johnmahugu/weppy-REST
def _parse(accepted_set, params):
    rv = sdict()
    for key in accepted_set & set(params):
        rv[key] = params[key]
    return rv
コード例 #15
0
ファイル: test_orm.py プロジェクト: olivierh59500/weppy
def test_computations(db):
    row = sdict(price=12.95, quantity=3)
    rv = db.Stuff.total.compute(row)
    assert rv == 12.95 * 3
コード例 #16
0
ファイル: test_auth.py プロジェクト: kooksee/weppy
def db():
    app = App(__name__)
    db = DAL(app, config=sdict(uri='sqlite:memory'))
    auth = Auth(app, db, usermodel=User)
    db.define_models(Thing)
    return db
コード例 #17
0
ファイル: test_dal.py プロジェクト: kooksee/weppy
def test_computations(db):
    row = sdict(price=12.95, quantity=3)
    rv = db.Stuff.total.compute(row)
    assert rv == 12.95*3
コード例 #18
0
ファイル: appmodule.py プロジェクト: johnmahugu/weppy-REST
 def __init__(
         self,
         app,
         name,
         import_name,
         model,
         serializer=None,
         parser=None,
         enabled_methods=['index', 'create', 'read', 'update', 'delete'],
         disabled_methods=[],
         list_envelope='data',
         single_envelope=None,
         use_envelope_on_parsing=False,
         url_prefix=None,
         hostname=None,
         pipeline=[]):
     self._fetcher_method = self._get_dbset
     self._select_method = self._get_row
     self._after_parse = self._after_parse_params
     self.error_404 = self.build_error_404
     self.error_422 = self.build_error_422
     add_service_pipe = True
     super_pipeline = list(pipeline)
     for pipe in super_pipeline:
         if isinstance(pipe, ServicePipe):
             add_service_pipe = False
             break
     if add_service_pipe:
         super_pipeline.insert(0, ServicePipe('json'))
     super(RESTModule, self).__init__(app,
                                      name,
                                      import_name,
                                      url_prefix=url_prefix,
                                      hostname=hostname,
                                      pipeline=super_pipeline)
     self.ext = self.app.ext.REST
     self._pagination = sdict()
     for key in ('page_param', 'pagesize_param', 'min_pagesize',
                 'max_pagesize', 'default_pagesize'):
         self._pagination[key] = self.ext.config[key]
     self._path_base = self.ext.config.base_path
     self._path_rid = self.ext.config.base_id_path
     self._serializer_class = serializer or \
         self.ext.config.default_serializer
     self._parser_class = parser or self.ext.config.default_parser
     self._parsing_params_kwargs = {}
     self.model = model
     self.serializer = self._serializer_class(self.model)
     self.parser = self._parser_class(self.model)
     self.enabled_methods = enabled_methods
     self.disabled_methods = disabled_methods
     self.list_envelope = list_envelope
     self.use_envelope_on_parsing = use_envelope_on_parsing
     self.single_envelope = single_envelope
     self.index_pipeline = [SetFetcher(self)]
     self.create_pipeline = []
     self.read_pipeline = [SetFetcher(self), RecordFetcher(self)]
     self.update_pipeline = [SetFetcher(self)]
     self.delete_pipeline = [SetFetcher(self)]
     self.init()
     self._after_initialize()
コード例 #19
0
ファイル: test_auth.py プロジェクト: olivierh59500/weppy
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
コード例 #20
0
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
コード例 #21
0
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