import neo_cgi
# send neo_cgi handler through the python stdin/stdout/environ
# calls
neo_cgi.cgiWrap(context.stdin, context.stdout, context.environ)
# setup a random form handling option
neo_cgi.IgnoreEmptyFormVars(1)
# create a CGI handler context
ncgi = neo_cgi.CGI()
# setup HDF loadpaths (relative from the current directory)
ncgi.hdf.setValue("hdf.loadpaths.0","tmpl")
# parse the form data (and post upload data)
ncgi.parse()
# read static HDF data into the HDF dataset
ncgi.hdf.readFile("mytemplate.hdf")
# process some query data (second argument is default value if missing)
a_var = ncgi.hdf.getValue("Query.a_var","")
a_cookie = ncgi.hdf.getValue("Cookie.a_cookie","")
a_int_var = ncgi.hdf.getIntValue("Query.a_int_var,0)
# put some data into the HDF dataset
ncgi.hdf.setValue("CGI.Page.Title","My Webpage")
ncgi.hdf.setValue("CGI.Page.Contents","This is the page contents")
# use some utility functions
ncgi.hdf.setValue("CGI.HDFDUMP",neo_cgi.htmlEscape(ncgi.hdf.dump()))
# render the clearsilver template
ncgi.display("mytemplate.cst")
|