Baka: Skeleton framework built top of pyramid, baka_model for sqlalchemy
Project description
Baka model add-ons
==================
`Baka_model <https://github.com/suryakencana/baka_model>`_. 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.
.. code:: python
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_model, you can apply dependency injection method for model that has been created.
.. code:: python
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
.. code:: bash
pyramid.includes =
baka_model
pyramid_debugtoolbar
pyramid_mailer
Install with code
.. code:: python
def includeme(config):
config.include('baka_model')
==================
`Baka_model <https://github.com/suryakencana/baka_model>`_. 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.
.. code:: python
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_model, you can apply dependency injection method for model that has been created.
.. code:: python
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
.. code:: bash
pyramid.includes =
baka_model
pyramid_debugtoolbar
pyramid_mailer
Install with code
.. code:: python
def includeme(config):
config.include('baka_model')
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_model-0.18.0.tar.gz
(12.8 kB
view hashes)
Built Distribution
Close
Hashes for baka_model-0.18.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d65ae1d830c258ed26347125791c1fe5c3c340c2a9ebef3d059c42b06f4de2a9 |
|
MD5 | 63fa987e48a89bbcebd23d963eaf0ce4 |
|
BLAKE2b-256 | 7315a69c4c8ed149ae3b61a83c48c953c65c562858ddb81f782b9f0b6c766f22 |