cryptonas-branches/pythonrewrite/bin2/CryptoBoxWebserverRender.py

30 lines
898 B
Python
Raw Normal View History

try:
import neo_cgi, neo_util, neo_cs
except:
print "could not import clearsilver modules! Try apt-get install python-clearsilver."
class CryptoBoxWebserverRender:
def render(self, website):
'''
render a clearsilver template and return the result.
gets:
- path to clearsilver template
- dictionary with settings (optional)
- path to hdf dataset (optional)
'''
## overload to the max
website.log.info("rendering site: "+website.settings["Data.Action"]+" "+str(website.settings))
cs_path = website.cbxPrefs["Settings"]["TemplateDir"]+"/main.cs"
hdf_path = website.cbxPrefs["Settings"]["LangDir"]+"/"+website.cbxPrefs["Settings"]["Language"]+".hdf"
hdf = neo_util.HDF()
if hdf_path != "":
hdf.readFile(hdf_path)
for key in website.settings.keys():
hdf.setValue(key,str(website.settings[key]))
cs = neo_cs.CS(hdf)
cs.parseFile(cs_path)
return cs.render()