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
::
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
::
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.7.tar.gz
(12.8 kB
view hashes)
Built Distributions
Close
Hashes for baka_model-0.17.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | adfaa6b8ec00af73f793ef466147bd6c23914c66b7030bdca8b5d927c53177ca |
|
MD5 | 567d12f10f960624fdb0e0d2d7e16dfa |
|
BLAKE2b-256 | 3c2d4ddd4964d041f41af7dcedda5a69385cbf5749b341e81f8478a1cac01d93 |
Close
Hashes for baka_model-0.17.7-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d45a2eb12c6ea4c566dc547cef1dcab98335505697612dc8341f8ddcfdbe46db |
|
MD5 | e302126c5920748a9d5b068746452881 |
|
BLAKE2b-256 | cb62fd8532885bf68b9bcfb538ffd9ab8c66511e4e2d4cc06b483008a09b606d |