def __call__(self, request, *param): url_path, real_path = calc_path(request.url_match['filepath'], self.base_dir) if not path.isfile(real_path): raise basehttp.HttpException(403) if real_path not in self.cache: self.cache[real_path] = template.Template(filepath = real_path) else: self.cache[real_path].reload(real_path) tplfile = self.cache[real_path] query_info = basehttp.get_params_dict(request.urls.query) funcname = query_info.get('func', None) if funcname: funcobj = tplfile.defcodes.get(funcname, None) if not funcobj: raise basehttp.NotFoundError() response = apps.J(request, funcobj, *param) else: response = request.make_response() info = {'request': request, 'response': response, 'param': param} response.append_body(tplfile.render(info)) return response
def __init__(self, cookie): ''' 解析数据,建立cookie @param cookie: cookie字符串 ''' if not cookie: self.v = {} else: self.v = basehttp.get_params_dict(cookie, ';') self.m = set()
def post_params(self): ''' 获得post方式请求参数 ''' self.recv_body() return basehttp.get_params_dict(self.get_body())
def get_params(self): ''' 获得get方式请求参数 ''' return basehttp.get_params_dict(self.urls.query)