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 gevent postgresql oslo.db oslo.config
Methods
daemon application
>>> from osmo.app.application import QApplicationlog application
>>> from osmo.core import log as loggingweb application
>>> from osmo.web.wsgiapp import WsgiApplicationdatabase 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.2.0.tar.gz
(27.2 kB
view details)
File details
Details for the file osmo-0.2.0.tar.gz
.
File metadata
- Download URL: osmo-0.2.0.tar.gz
- Upload date:
- Size: 27.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b060caa70055d19c248041448cc5dcde89655c5bc0be5c4399aefd0ce07a755 |
|
MD5 | ec57fd35d5b69ed6ce9a383bc2a0f81a |
|
BLAKE2b-256 | 0c4b50fe73e566ae18b702a59f9982a8648317f889f1704498593cdb5d733522 |