YAML configurator for Flask app.
Project description
Usage
from flaskext.yamlconfig import AppYAMLConfig AppYAMLConfig(app, "main.yaml")
or
from flaskext.yamlconfig import install_yaml_config
from flaskext.yamlconfig import AppYAMLConfig
class MyConfig(AppYAMLConfig):
def configure_mysection(self, content):
for item in content:
....
yaml_config = install_yaml_config(app, MyConfig)
yaml_config("main.yaml")
Register a renderers
from flask import current_app
from flaskext.yamlconfig import Renderer, register_renderer
from werkzeug.wrappers import BaseResponse
class JsonRenderer(Renderer):
def render(self, view_result):
return current_app.response_class(json.dumps(view_result,
indent=None if request.is_xhr else 2), mimetype='application/json')
register_renderer('json', JsonRenderer)
Config file sample
index:
view: views.index.index
url:
- /
- /page/<int:page>
renderer: actions/index/index.html
blog_edit:
view: views.blog.edit_blog
url: /blog/edit/<blog_url>
renderer: actions/blog/edit.html
methods:
- GET
- POST
context:
w_group: empty
ajaxBlogJoin:
view: views.blog.ajax_blog_join
url: /ajax/blogjoin/<int:blog_id>
methods:
- POST
renderer: json
View example
def index(context, request, page=1):
'''Main page
'''
return dict(pages = Pager(Topic.all(), page))
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
Flask-YAMLConfig-0.0.3.zip
(7.1 kB
view details)
File details
Details for the file Flask-YAMLConfig-0.0.3.zip.
File metadata
- Download URL: Flask-YAMLConfig-0.0.3.zip
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42f8484d5a60cb129ee7b38e389990a1964a7dbfe51ea8dc7d0392584be3a4d5
|
|
| MD5 |
e7c1e60682ce5d11f81d82e49d6dab56
|
|
| BLAKE2b-256 |
ce1959438506bebdb0e3fde4b13a556229b815cd965624f6c8fc05bed01fe725
|