Dont use exec for importing templates

This commit is contained in:
Sunil Mohan Adapa 2014-04-05 14:52:51 +09:00
parent afe345d01b
commit 2079b3639a

View File

@ -1,9 +1,12 @@
import os, sys
import cherrypy
import cfg
import importlib
import sqlite3
from filedict import FileDict
def mkdir(newdir):
"""works the way a good mkdir should :)
- already exists, silently complete
@ -67,7 +70,8 @@ def page_template(template='login_nav', **kwargs):
#if template=='base' and kwargs['sidebar_right']=='':
# template='two_col'
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:
submenu = cfg.main_menu.active_item().encode("sub_menu", render_subs=True)
except AttributeError: