cryptonas-branches/pythonrewrite/bin2/CryptoBoxWebserverRender.py
age 697d5f9b0c webserver, sites and settings splitted
included some new functions from the perl file
the clearsilver templates have to be modified next
2006-08-24 00:06:19 +00:00

30 lines
898 B
Python

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()