ahserver_g/ahserver/functionProcessor.py

29 lines
684 B
Python
Raw Normal View History

2019-11-28 15:28:33 +08:00
from appPublic.dictObject import DictObject
from appPublic.registerfunction import RegisterFunction
from aiohttp.web_response import Response, StreamResponse
from .baseProcessor import BaseProcessor
class FunctionProcessor(BaseProcessor):
@classmethod
def isMe(self,name):
return False
def __init__(self,path,resource, opts):
self.config_opts = opts
2019-11-29 11:35:33 +08:00
BaseProcessor.__init__(self,path,resource)
2019-11-28 15:28:33 +08:00
async def datahandle(self,request):
2019-11-29 11:35:33 +08:00
ns = self.config_opts.copy()
2019-11-28 15:28:33 +08:00
ns.update(self.run_ns)
2019-11-29 11:35:33 +08:00
ns = DictObject(**ns)
2019-11-28 15:28:33 +08:00
rf = RegisterFunction()
2019-11-29 11:35:33 +08:00
f = rf.get(ns.registerfunction)
2019-11-28 15:28:33 +08:00
x = await f(ns)
if isinstance(x,Response):
self.retResponse = x
else:
self.content = x