示例#1
0
 def wrapper(*args, **kwargs):
     cherrypy.thread_data.template = loader.load(filename)
     opt = options.copy()
     if not ajax.is_xhr() and method == 'html':
         opt.setdefault('doctype', 'html')
     serializer = get_serializer(method, **opt)
     stream = func(*args, **kwargs)
     if not isinstance(stream, Stream):
         return stream
     return encode(serializer(stream), method=serializer,
                   encoding=encoding)
示例#2
0
 def web(self):
     if cherrypy.request.method == "POST":
         if is_xhr():
             jq = cherrypy.request.json
             print("JQ: %s" % jq)
             if "args" in jq and "kwargs" in jq:
                 return self._dispatcher._execute(jq[u"args"], jq[u"kwargs"])
             elif "args" in jq:
                 return self._dispatcher._execute(jq[u"args"])
             else:
                 raise AttributeError
示例#3
0
 def wrapper(*args, **kwargs):
     cherrypy.thread_data.template = loader.load(filename)
     opt = options.copy()
     if not ajax.is_xhr() and method == 'html':
         opt.setdefault('doctype', 'html')
     serializer = get_serializer(method, **opt)
     stream = func(*args, **kwargs)
     if not isinstance(stream, Stream):
         return stream
     return encode(serializer(stream),
                   method=serializer,
                   encoding=encoding)
示例#4
0
	def web(self):
		if cherrypy.request.method == "POST":
			RLOCK = threading.RLock() 
			RLOCK.acquire()
			if is_xhr():
				jq = cherrypy.request.json
				#print('headers:',cherrypy.request.headers)
				#print('JQ: %s' % jq)
				if  'args' in jq and 'kwargs' in jq:
					return self._dispatcher._execute(jq[u'args'], jq[u'kwargs'])
				elif  'args' in jq:
					return self._dispatcher._execute(jq[u'args'])
				else:
					raise AttributeError
			else:
				print('HEADERS:',cherrypy.request.headers)
				print('JSON:',cherrypy.request.json)
			RLOCK.release()