def __init__(self, *args, **kwargs): SessionPublisher.__init__(self, *args, **kwargs) self.configure(DISPLAY_EXCEPTIONS='plain', SECURE_ERRORS=0, DEBUG_PROPAGATE_EXCEPTIONS=DEVELOP_MODE, UPLOAD_DIR=get_tmpdir() + '/upload/', SESSION_COOKIE_NAME=SESSION_COOKIE_NAME, SESSION_COOKIE_DOMAIN=SESSION_COOKIE_DOMAIN, SESSION_COOKIE_PATH=SESSION_COOKIE_PATH)
def startServer (namespace,servername,configPath=None): if configPath is None: configPath = os.path.dirname(namespace.__file__) print "config path is %s" % configPath print 'Now serving %s on port 8080' % servername server = http_server.http_server('', 8080) publisher = SessionPublisher(namespace) try: publisher.read_config(os.path.join(configPath,"default.conf")) except IOError,e: print e return
def startServer(namespace, servername, configPath=None): if configPath is None: configPath = os.path.dirname(namespace.__file__) print "config path is %s" % configPath print 'Now serving %s on port 8080' % servername server = http_server.http_server('', 8080) publisher = SessionPublisher(namespace) try: publisher.read_config(os.path.join(configPath, "default.conf")) except IOError, e: print e return
def __init__ (self, *args, **kwargs): self.logger = logging.getLogger(str(self.__class__)) try: self.context = kwargs['context'] self.logger.info('Found context') except KeyError: self.context = canary.context.Context() self.logger.info('Started new context') self.config = self.context.config SessionPublisher.__init__(self, root_namespace='canary.ui', session_mgr=SqlSessionManager(self.context), config=self.config) self.setup_logs()
def start_request(self, request): SessionPublisher.start_request(self, request) os.environ['SQLSTORE_SOURCE'] = request.get_url() resp = request.response resp.set_content_type('text/html; charset=utf-8') resp.set_header('Pragma', 'no-cache') resp.set_header('Cache-Control', 'must-revalidate, no-cache, private') # FIXME: quixote with origin? resp.set_header('Access-Control-Allow-Origin', '*') request.enable_ajax = False request.browser = request.guess_browser_version() request.method = request.get_method() request.url = request.get_path() request.is_mobile = is_mobile_device(request) request.start_time = time.time() # FIXME: user login request.user = None check_auth(request) # OAuth import_obj_set("request", request)
def finish_failed_request(self, request): if DEVELOP_MODE: exc_type, exc_value, tb = sys.exc_info() raise exc_type, exc_value, tb else: return SessionPublisher.finish_failed_request(self, request)
def try_publish(self, request, path): output = SessionPublisher.try_publish(self, request, path) return output
def __init__(self, *args, **kwargs): SessionPublisher.__init__(self, *args, **kwargs) self.configure(DISPLAY_EXCEPTIONS='plain', SECURE_ERRORS=0, UPLOAD_DIR=get_tmpdir() + '/upload/')
def try_publish(self, request, path): output = SessionPublisher.try_publish(self, request, path) output = show_performance_metric(request, output) return output
def __init__(self, *args, **kwargs): SessionPublisher.__init__(self, *args, **kwargs) display = 'html' if os.environ.get('DOUBAN_PRODUCTION') else 'plain' self.configure(DISPLAY_EXCEPTIONS=display, UPLOAD_DIR=get_tmpdir() + '/upload/')