Baka: Skeleton framework built top of pyramid, baka_tenshi for sqlalchemy
Project description
Baka model add-ons
Baka_tenshi is add-ons baka framework built top of pyramid that provides an SQLAlchemy declarative Base alias model.Model and a add method on request.db.
Usage
You can use these as base classes for declarative model definitions, e.g.
from base_model.model import Model
class MyModel(Model):
"""Example model class."""
__tablename__ = 'base.mymodel'
@classmethod
def do_first(cls, session):
instance = session.query(cls).first()
Register Model
using Baka_tenshi, you can apply dependency injection method for model that has been created.
def includeme(config):
config.register_model('base.MyModel')
# in view handler request
@route('/my.model', renderer='json')
def view_mymodel(request):
MyModel = request.find_model('base.mymodel')
mymodel = MyModel()
mymodel.name = 'user model'
mymodel.address = 'user address'
mymodel.phone = '0089800-998'
request.db.add(mymodel)
return {'success': True}
Install
Install with .ini file
pyramid.includes =
Baka_tenshi
pyramid_debugtoolbar
pyramid_mailer
Install with code
def includeme(config):
config.include('Baka_tenshi')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
baka_tenshi-1.0.3.dev7.tar.gz
(11.1 kB
view hashes)
Built Distribution
Close
Hashes for baka_tenshi-1.0.3.dev7-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f6d259a41f6623ca63001a22087bdb9e27b8d3b61edaadd538d157b567a07fa |
|
MD5 | 2d365da887d59a75311a00a1d33dcf59 |
|
BLAKE2b-256 | 1fad6d953423fad57290f5a0f1e5b185c44a42194d890e8d0b30ab476b4e994a |