示例#1
0
def main(argv, environ):
    alist, args = getopt.getopt(argv[1:], "", ["help"])

    for (field, val) in alist:
        if field == "--help":
            usage(argv[0])
            return

    dbname = args[0]
    py_file = args[1]
    if py_file[-3:] == ".py":
        py_file = py_file[:-3]
    dbclassname = args[2]

    ml = ihooks.ModuleImporter()
    try:
        mod = ml.import_module(py_file)
    except:
        import handle_error
        sys.stderr.write("Unable to load file %s\n%s" %
                         (py_file, handle_error.exceptionString()))
        sys.exit(-1)

    dbclass = getattr(mod, dbclassname)

    CDBIGenerator(dbname, dbclass).generate()
示例#2
0
def main(argv, environ):
  alist, args = getopt.getopt(argv[1:], "", ["help"])

  for (field, val) in alist:
    if field == "--help":
      usage (argv[0])
      return

  dbname = args[0]
  py_file = args[1]
  if py_file[-3:] == ".py":
    py_file = py_file[:-3]
  dbclassname = args[2]

  ml = ihooks.ModuleImporter()
  try:
    mod = ml.import_module(py_file)
  except:
    import handle_error
    sys.stderr.write("Unable to load file %s\n%s" % (py_file, handle_error.exceptionString()))
    sys.exit(-1)

  dbclass = getattr(mod, dbclassname)

  CDBIGenerator(dbname, dbclass).generate()
示例#3
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
示例#4
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
示例#5
0
        except Redirected:
            # catch redirect exceptions
            SHOULD_DISPLAY = 0
        except DisplayError, num:
            ncgi.hdf.setValue("Query.error", str(num))
            if self._error_template:
                ncgi.hdf.setValue("Content", self._error_template)
            else:
                DISPLAY_ERROR = 1
        except:
            SHOULD_DISPLAY = 0
            DISPLAY_ERROR = 1

            import handle_error
            handle_error.handleException("Display Failed!")
            ERROR_MESSAGE = handle_error.exceptionString()

        if DISPLAY_ERROR:
            #print "Content-Type: text/html\n\n"

            # print the page

            self['Content-Type'] = "text/html"

            # print the page
            self.push("<head>")
            self.push('''
<script type="text/javascript">
function toggleDebugInfo() {
    var tb = document.getElementById('%s');
    if (tb == null) return;
示例#6
0
        except Redirected:
            # catch redirect exceptions
            SHOULD_DISPLAY = 0
        except DisplayError, num:
            ncgi.hdf.setValue("Query.error", str(num))
            if self._error_template:
                ncgi.hdf.setValue("Content", self._error_template)
            else:
                DISPLAY_ERROR = 1
        except:
            SHOULD_DISPLAY = 0
            DISPLAY_ERROR = 1
            
            import handle_error
            handle_error.handleException("Display Failed!")
            ERROR_MESSAGE = handle_error.exceptionString()

        if DISPLAY_ERROR:
            #print "Content-Type: text/html\n\n"

            # print the page

            self['Content-Type'] = "text/html"

            # print the page
            self.push("<head>")
            self.push('''
<script type="text/javascript">
function toggleDebugInfo() {
    var tb = document.getElementById('%s');
    if (tb == null) return;
示例#7
0
        except Redirected:
            # catch redirect exceptions
            SHOULD_DISPLAY = 0
        except DisplayError, num:
            ncgi.hdf.setValue("Query.error", str(num))
            if self._error_template:
                ncgi.hdf.setValue("Content", self._error_template)
            else:
                DISPLAY_ERROR = 1
        except:
            SHOULD_DISPLAY = 0
            DISPLAY_ERROR = 1
            
            import handle_error
            handle_error.handleException("Display Failed!")
            ERROR_MESSAGE = handle_error.exceptionString()

        if DISPLAY_ERROR:
            print "Content-Type: text/html\n\n"

            # print the page

            print "<H1> Error in Page </H1>"
            print "A copy of this error report has been submitted to the developers. "
            print "The details of the error report are below."


            print "<PRE>"
            print neo_cgi.htmlEscape(ERROR_MESSAGE)
            print "</PRE>\n"
            # print debug info always on page error...
        except Redirected:
            # catch redirect exceptions
            SHOULD_DISPLAY = 0
        except DisplayError, num:
            ncgi.hdf.setValue("Query.error", str(num))
            if self._error_template:
                ncgi.hdf.setValue("Content", self._error_template)
            else:
                DISPLAY_ERROR = 1
        except:
            SHOULD_DISPLAY = 0
            DISPLAY_ERROR = 1
            
            import handle_error
            handle_error.handleException("Display Failed!")
            ERROR_MESSAGE = handle_error.exceptionString()

        if DISPLAY_ERROR:
            print "Content-Type: text/html\n\n"

            # print the page

            print "<H1> Error in Page </H1>"
            print "A copy of this error report has been submitted to the developers. "
            print "The details of the error report are below."


            print "<PRE>"
            print neo_cgi.htmlEscape(ERROR_MESSAGE)
            print "</PRE>\n"
            # print debug info always on page error...