2006-08-24 16:41:11 +02:00
|
|
|
import os
|
2006-08-24 02:06:19 +02:00
|
|
|
try:
|
|
|
|
import neo_cgi, neo_util, neo_cs
|
2006-08-30 21:56:37 +02:00
|
|
|
except ImportError:
|
|
|
|
raise ImportError("could not import clearsilver modules! Try apt-get install python-clearsilver.")
|
2006-08-24 02:06:19 +02:00
|
|
|
|
|
|
|
class CryptoBoxWebserverRender:
|
2006-08-24 16:41:11 +02:00
|
|
|
'''renders the site with clearsilver template and languagefile
|
|
|
|
|
|
|
|
'''
|
2006-08-24 02:06:19 +02:00
|
|
|
def render(self, website):
|
2006-08-24 16:41:11 +02:00
|
|
|
'''renders from clearsilver templates and returns the resulting html
|
2006-08-24 02:06:19 +02:00
|
|
|
|
2006-08-24 16:41:11 +02:00
|
|
|
Gets a dictionary with all settings, nessessary for rendering.
|
|
|
|
In fact the dictionary is a copy of the CryptoBoxWerbserverSite
|
|
|
|
object, that calls this render method. This might be bloat but
|
|
|
|
this way the render method has always a complete, actual set of values.
|
2006-08-24 02:06:19 +02:00
|
|
|
'''
|
|
|
|
|
2006-08-24 16:41:11 +02:00
|
|
|
website.log.info("rendering site: "+website.settings["Data.Action"])
|
|
|
|
|
2006-08-27 10:38:48 +02:00
|
|
|
cs_path = website.cbxPrefs["Locations"]["TemplateDir"]+"/main.cs"
|
2006-08-24 16:41:11 +02:00
|
|
|
if not os.access(cs_path, os.R_OK):
|
|
|
|
website.log.error("Couldn't read cs file: %s" % cs_path)
|
|
|
|
return "Couldn't read cs file: %s" % cs_path
|
|
|
|
|
2006-09-02 01:04:17 +02:00
|
|
|
#hdf_path = website.cbxPrefs["Locations"]["LangDir"]+"/"+website.cbxPrefs["WebSettings"]["Language"]+".hdf"
|
|
|
|
hdf_path = website.cbxPrefs["Locations"]["LangDir"]+"/"+website.settings["Settings.Language"]+".hdf"
|
2006-08-24 16:41:11 +02:00
|
|
|
if not os.access(hdf_path, os.R_OK):
|
|
|
|
website.log.error("Couldn't read hdf file: %s" % hdf_path)
|
|
|
|
return "Couldn't read hdf file: %s" % hdf_path
|
|
|
|
|
2006-08-24 02:06:19 +02:00
|
|
|
hdf = neo_util.HDF()
|
2006-08-24 16:41:11 +02:00
|
|
|
hdf.readFile(hdf_path)
|
2006-09-02 01:04:17 +02:00
|
|
|
website.log.info(website.settings)
|
2006-08-24 02:06:19 +02:00
|
|
|
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()
|
|
|
|
|