Example #1
0
File: CSPage.py Project: jeske/csla
    def __init__(self, context, pagename=0,readDefaultHDF=1,israwpage=0):
	if pagename == 0:
	    raise NoPageName, "missing pagename"
	self.pagename = pagename
	self.readDefaultHDF = readDefaultHDF
        self._israwpage = israwpage
        self.context = context

        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.debugEnabled = self.ncgi.hdf.getIntValue("Query.debug",self.ncgi.hdf.getIntValue("Cookie.debug",0))
        if self.debugEnabled:
            profiler.enable()
        self.subclassinit()
        self.setPaths([self.ncgi.hdf.getValue("CGI.DocumentRoot","")])
Example #2
0
File: CSPage.py Project: jeske/csla
    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","")])

        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://"
 def testValidateErrorString(self):
   fake_stdin = StringIO.StringIO("")
   fake_stdout = StringIO.StringIO()
   fake_env = {}
   neo_cgi.cgiWrap(fake_stdin, fake_stdout, fake_env)
   ncgi = neo_cgi.CGI()
   ncgi.error("%s")
   assert fake_stdout.getvalue().find("%s") != -1
 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 
Example #5
0
    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
Example #6
0
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"