Skip to main content

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:

  1. daemon application

    >>> from osmo.app.application import QApplication
    
  2. log application

    >>> from osmo.core import log as logging
    
  3. web application

    >>> from osmo.web.wsgiapp import WsgiApplication
    
  4. 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


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.5.tar.gz (30.5 kB view details)

Uploaded Source

File details

Details for the file osmo-0.1.5.tar.gz.

File metadata

  • Download URL: osmo-0.1.5.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for osmo-0.1.5.tar.gz
Algorithm Hash digest
SHA256 52eb30fb29db40e2764fe785fd8f30724129735b9ffe39a3b3934b2cc2143340
MD5 0b0bb3664c0d7b4bfbab3e733235a3ae
BLAKE2b-256 3ebe432a9bd7152597a3b62d80ba8a425d52f8e998f0cc9dbebcfde9444b11f8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page