mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
Dont use exec for importing templates
This commit is contained in:
parent
afe345d01b
commit
2079b3639a
6
util.py
6
util.py
@ -1,9 +1,12 @@
|
|||||||
import os, sys
|
import os, sys
|
||||||
import cherrypy
|
import cherrypy
|
||||||
import cfg
|
import cfg
|
||||||
|
import importlib
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
from filedict import FileDict
|
from filedict import FileDict
|
||||||
|
|
||||||
|
|
||||||
def mkdir(newdir):
|
def mkdir(newdir):
|
||||||
"""works the way a good mkdir should :)
|
"""works the way a good mkdir should :)
|
||||||
- already exists, silently complete
|
- already exists, silently complete
|
||||||
@ -67,7 +70,8 @@ def page_template(template='login_nav', **kwargs):
|
|||||||
#if template=='base' and kwargs['sidebar_right']=='':
|
#if template=='base' and kwargs['sidebar_right']=='':
|
||||||
# template='two_col'
|
# template='two_col'
|
||||||
if isinstance(template, basestring):
|
if isinstance(template, basestring):
|
||||||
exec ("from templates.%s import %s as template" % (template, template))
|
template_module = importlib.import_module('templates.' + template)
|
||||||
|
template = getattr(template_module, template)
|
||||||
try:
|
try:
|
||||||
submenu = cfg.main_menu.active_item().encode("sub_menu", render_subs=True)
|
submenu = cfg.main_menu.active_item().encode("sub_menu", render_subs=True)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user