烧瓶,芹菜,sqlalchemy集成框架。
kit的Python项目详细描述
一个可配置的轻量级框架,它集成了Flask、SQLAlchemy和 Celery。
- Configure all your applications and sessions from one file (cf. Quickstart for an example).
- Run your project from the command line: Start the Werkzeug webserver, start Celery workers, start a shell in your project’s context (using IPython if available), and start the Flower monitor using the ^{tt1}$ command line tool.
- No more complicated import schemes: ^{tt2}$ and ^{tt3}$ always return the correct (and configured) application corresponding to the module.
- Kit makes sure database connections are correctly handled (e.g. removed after each request and task) under the hood. You can configure this behavior via the ^{tt4}$ decorator.
查看examples/文件夹中的几个示例应用程序,或阅读 关于GitHub pages的完整文档。
kit正在开发中。
安装
$ pip install kit
快速启动
配置文件示例:
root:'..'flasks:-modules:['my_project.app','my_project.app.views']kwargs:static_folder:'st'config:debug:yestesting:yes-modules:['my_project.api']celeries:-modules:['my_project.tasks']config:broker_url:'redis://'sessions:db:url:'mysql://...'engine:pool_recycle:3600options:commit:yesraise:nomodules:['my_project.startup']
提供以下配置选项:
- root:项目根目录,将被添加到python路径(默认为 '.')
- flasks:烧瓶应用程序设置列表。每个项目都有以下内容
可用键:
- modules:使用此应用程序的模块列表。在每个 在这些模块中,可以使用kit.Flask(__name__)来恢复 已配置的应用程序。应用程序的名称将自动 从这个模块列表生成。
- kwargs:传递给^{tt12}的关键字参数字典$ 构造器。
- config:用于配置 申请。名称不区分大小写,因此不需要大写。
- celeries:芹菜应用程序设置列表。每个项目都有
提供以下按键:
- modules:使用此应用程序的模块列表。在每个 在这些模块中,可以使用kit.Celery(__name__)来恢复 已配置的应用程序。应用程序的名称将自动 从这个模块列表生成。
- kwargs:传递给 celery.Celery构造函数。
- config:用于配置 申请。名称不区分大小写,因此不需要大写。
- sessions:会话字典。密钥是会话名称(使用
作为kit.get_session的参数。每个项目都有以下内容
可用设置:
- url:数据库url(默认为sqlite://)
- kwargs:要传递给的关键字参数字典 sqlalchemy.orm.sessionmaker。
- engine:要传递到绑定引擎的关键字参数字典 构造器。
- options:当前有两个可用选项:
- commit:是否在每个请求之后提交会话 或任务(默认为False)。
- raise:是否重新引发提交期间发现的任何错误 (默认为True)。
- modules:要导入的模块列表(不属于 应用程序)。
然后可以使用kit命令行工具管理项目:
- kit shell将在项目环境中启动一个shell(all 应用程序和会话将预先创建和设置)。
- kit server将为您的一个烧瓶运行werkzeug服务器 应用程序(如果找到多个应用程序,系统将提示您 选择一个)。
- kit worker将启动一个芹菜工人(如果不止一个芹菜 应用程序存在于项目中,提示您选择一个项目。
- kit flower启动花工监视器。
kit -h显示每个选项的用法和可用选项列表 命令。
下一步
在命令行工具之外实例化应用程序(例如 要在不同的wsgi服务器上运行它,可以指定一个path参数 到kit.Flask函数。这将在返回之前加载工具包 申请书。path参数在所有其他函数上都可用 嗯(例如,允许从ipython笔记本访问模型)。