def __init__(self, context, pagename=0, readDefaultHDF=1, israwpage=0, **parms): if pagename == 0: raise NoPageName, "missing pagename" self.pagename = pagename self.readDefaultHDF = readDefaultHDF self._israwpage = israwpage self.context = context self._pageparms = parms self._error_template = None self.page_start_time = time.time() neo_cgi.cgiWrap(context.stdin, context.stdout, context.environ) neo_cgi.IgnoreEmptyFormVars(1) self.ncgi = neo_cgi.CGI() self.ncgi.parse() self._path_num = 0 domain = self.ncgi.hdf.getValue("CGI.ServerName", "") domain = self.ncgi.hdf.getValue("HTTP.Host", domain) self.domain = domain self.subclassinit() self.setPaths([self.ncgi.hdf.getValue("CGI.DocumentRoot", "")])
def __init__(self, context, pagename=None, readDefaultHDF=1, israwpage=0, parseCGI=1, makePUT=0, **parms): if pagename is None: pagename = self._pagename if not pagename: raise NoPageName("missing pagename") self.pagename = pagename self.readDefaultHDF = readDefaultHDF self._israwpage = israwpage self.context = context self._pageparms = parms self._error_template = None self.page_start_time = time.time() if makePUT: context.environ['REQUEST_METHOD'] = 'PUT' neo_cgi.cgiWrap(context.stdin, context.stdout, context.environ) neo_cgi.IgnoreEmptyFormVars(1) self.ncgi = neo_cgi.CGI() if parseCGI: self.ncgi.parse() self._path_num = 0 domain = self.ncgi.hdf.getValue("CGI.ServerName", "") domain = self.ncgi.hdf.getValue("HTTP.Host", domain) self.domain = domain self.setPaths([self.ncgi.hdf.getValue("CGI.DocumentRoot", "")]) self._sent_headers = 0 self._reply_headers = {} self._reply_code = 200 if self.ncgi.hdf.getValue("CGI.HTTPS", ""): self.http = "https://" else: self.http = "http://" try: self.subclassinit() except: SHOULD_DISPLAY = 0 DISPLAY_ERROR = 1 import handle_error handle_error.handleException("Display Failed!") ERROR_MESSAGE = handle_error.exceptionString() return
def run_neo_cgi(self, filename): stdin = cStringIO.StringIO("") stdout = cStringIO.StringIO() neo_cgi.cgiWrap(stdin, stdout, {}) neo_cgi.IgnoreEmptyFormVars(1) ncgi = neo_cgi.CGI() path = os.path.dirname(filename) ncgi.hdf.setValue("hdf.loadpaths.path", path) ncgi.display(filename) return
def main(): neo_cgi.cgiWrap(sys.stdin, sys.stdout, os.environ) neo_cgi.IgnoreEmptyFormVars(1) ncgi = neo_cgi.CGI() ncgi.parse() ret = receive(ncgi) print "Content-type: text/plain" print if ret: print "success", ret else: print "fail"