python tools library: through use openstack library, to provider convenience for flask application.
Project description
Desc:
through use openstack library, to provider convenience for flask application.at the same time by using the oslo.db library to simplify the operation of the database. by adding the log function, can make dameon process between more processes using the log function.
Dependent:
flask gunicorn greenlet postgresql oslo.db oslo.config
Methods:
daemon application
>>> from osmo.app.application import QApplication
log application
>>> from osmo.core import log as logging
web application
>>> from osmo.web.wsgiapp import WsgiApplication
database application
>>> from sqlalchemy.ext.declarative import declarative_base >>> from osmo.db import api >>> from osmo.db import models
>>> BASE = declarative_base(cls=models.ModelBase)
>>> def get_session(*args, **kwargs): >>> return api.get_session(*args, **kwargs)
>>> def get_engine(*args, **kwargs): >>> return api.get_engine(*args, **kwargs)
>>> def model_query(model, session=None, args=None, **kwargs): >>> """ >>> :param model : Model to query, Must be subclass of ModelBase >>> :type model : models.ModelBase
>>> usage: >>> user_model = model_query(UserModel)\ >>> .filter(UserModel.name == 'jinlong')\ >>> .first() >>> """ >>> if not issubclass(model, models.ModelBase): >>> raise TypeError("model must be subclass of ModelBase")
>>> if not session: >>> session = get_session() >>> query = session.query(model) if not args else session.query(*args) >>> return query
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
osmo-0.1.4.tar.gz
(26.1 kB
view details)
Built Distribution
osmo-0.1.4-py2.7.egg
(53.0 kB
view details)
File details
Details for the file osmo-0.1.4.tar.gz
.
File metadata
- Download URL: osmo-0.1.4.tar.gz
- Upload date:
- Size: 26.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08d54b76c25d25a42827c667c2e3b5544cab6c0a04f7f8b1fcf62013be96beac |
|
MD5 | eb45ffbbb8b85e4b832a6ccb499b6eb1 |
|
BLAKE2b-256 | 67b5129f8ecd326349f375498dac3ca4e6cf940b442cf09bd47f59da0612f468 |
File details
Details for the file osmo-0.1.4-py2.7.egg
.
File metadata
- Download URL: osmo-0.1.4-py2.7.egg
- Upload date:
- Size: 53.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e3aa857b9da348df127818a1f4aef0da19a3be6d871c4c582654cf52b1a0963 |
|
MD5 | a37777681f003ddfc89a469c4740ef36 |
|
BLAKE2b-256 | b5391f245d09a964bd23bc0bf2eab20575d61e3faf22229f37396ecaf9b9de73 |