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.17.9.tar.gz
(12.8 kB
view hashes)
Built Distributions
Close
Hashes for baka_model-0.17.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e441e384c54ae10022589c2eae9e74e8e747252c25c1070f220c96a3fc34a4ee |
|
MD5 | b17bf2176fe77a8a139bc951d6a5409f |
|
BLAKE2b-256 | 6aa6d40724aba8d4f36ea198ca960511f9fa2e2e4734d284d4662295478058b6 |
Close
Hashes for baka_model-0.17.9-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76e46e4fed03a72c5dae7299f4de29526a6cbcc3a007fcffcb70add66d0eb10b |
|
MD5 | acadfefa5676d9e88565785c4e5692ad |
|
BLAKE2b-256 | e8ad06626450a3992fe619b09a2e65aa7b13512a6c10d36e892d806f54e1da23 |