Example #1
0
def run():
    # __file__ contains <submin-dir>/dispatch/cgirunner.py
    submin_www_dir = os.path.dirname(__file__)
    submin_dir = os.path.dirname(submin_www_dir)

    from submin.bootstrap import SubminInstallationCheck
    check = SubminInstallationCheck(submin_dir)
    if not check.ok:
        print "Status: 500\r\n\r\n",
        print check.error_page()
        sys.exit(0)

    from submin.models import storage
    storage.open()

    try:
        from submin.dispatch.cgirequest import CGIRequest
        from submin.dispatch.dispatcher import dispatcher

        req = CGIRequest()
        response = dispatcher(req)
        req.writeResponse(response)
    except Exception as e:
        import traceback
        trace = traceback.extract_tb(sys.exc_info()[2])
        list = traceback.format_list(trace)
        list.append(str(e))
        print "Status: 500\r\n\r\n",
        print ''.join(list)

    storage.close()
	def __init__(self, environ, start_response):
		self.environ = environ
		self.start_response = start_response
		from submin.models import storage
		self.storage = storage
		self.storage.open()

		# importing options is only possbile after storage.open()
		from submin.models import options

		submin_www_dir = options.static_path('www')
		os.chdir(submin_www_dir) # same behaviour as CGI script

		from submin.bootstrap import SubminInstallationCheck
		submin_dir = options.lib_path()
		check = SubminInstallationCheck(submin_dir, environ)
		if not check.ok:
			self.start_response("500 Not Ok", [])
			return check.error_page().encode("utf-8")

		os.environ['SUBMIN_ENV'] = environ['SUBMIN_ENV']

		from submin.dispatch.wsgirequest import WSGIRequest
		from submin.dispatch.dispatcher import dispatcher
		self.WSGIRequest = WSGIRequest
		self.dispatcher = dispatcher
Example #3
0
def run():
	# __file__ contains <submin-dir>/dispatch/cgirunner.py
	submin_www_dir = os.path.dirname(__file__)
	submin_dir = os.path.dirname(submin_www_dir)

	from submin.bootstrap import SubminInstallationCheck
	check = SubminInstallationCheck(submin_dir)
	if not check.ok:
		print "Status: 500\r\n\r\n",
		print check.error_page()
		sys.exit(0)

	from submin.models import storage
	storage.open()

	try:
		from submin.dispatch.cgirequest import CGIRequest
		from submin.dispatch.dispatcher import dispatcher

		req = CGIRequest()
		response = dispatcher(req)
		req.writeResponse(response)
	except Exception as e:
		import traceback
		trace = traceback.extract_tb(sys.exc_info()[2])
		list = traceback.format_list(trace)
		list.append(str(e))
		print "Status: 500\r\n\r\n",
		print ''.join(list)

	storage.close()