Skip to content

Commit d677d4e

Browse files
committed
add core context processors
1 parent f17ca47 commit d677d4e

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

flask_xxl/context_processors.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
context_processors.py
4+
"""
5+
6+
from inflection import camelize
7+
8+
def get_model(model_name, blueprint=None):
9+
class_name = camelize(
10+
model_name
11+
)
12+
return __import__(
13+
blueprint or model_name.lower() +
14+
'.models', globals(), locals(),
15+
fromlist=[],
16+
).models.__dict__[class_name]
17+
18+
19+
def add_get_model():
20+
return {'get_model': get_model}

flask_xxl/templates/project/+project.name+/settings.py.bob

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,11 @@ class BaseConfig(LocalConfig):
108108
# def the_func_to_add():
109109
# #w/e you want to do
110110
# return {name:the_func_to_add}
111-
# then in templates name is aviable
111+
# then in templates name is available
112112
######################################################
113113

114114
CONTEXT_PROCESSORS = [
115+
'flask.ext.xxl.context_processors.add_get_model',
115116
#'flask.ext.xxl.context_processors.add_is_page',
116117
#'flask.ext.xxl.context_processors.common_context',
117118
#'flask.ext.xxl.context_processors.common_forms',

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ MarkupSafe==0.23
1111
Pygments==2.0.1
1212
SQLAlchemy==1.3.0
1313
WTForms==2.0.1
14-
Werkzeug==0.9.6
14+
Werkzeug==0.15.3
1515
alembic==0.6.7
1616
argparse==1.2.1
1717
blinker==1.3

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = '0,10,6'
1+
VERSION = '0,10,4'
22
import os
33
from setuptools import setup, find_packages,findall
44
from glob import glob
@@ -47,7 +47,7 @@ def get_pkg_data():
4747
'MarkupSafe==0.23',
4848
'SQLAlchemy==0.9.8',
4949
'WTForms==2.0.1',
50-
'Werkzeug==0.9.6',
50+
'Werkzeug==0.15.3',
5151
'alembic==0.6.7',
5252
'argparse==1.2.1',
5353
'itsdangerous==0.24',

0 commit comments

Comments
 (0)