Call response function for return values of UiWebsocket actions
This commit is contained in:
parent
9b83c683b5
commit
604792a4dd
1 changed files with 12 additions and 7 deletions
|
@ -209,7 +209,9 @@ class UiWebsocket(object):
|
||||||
def asyncWrapper(self, func):
|
def asyncWrapper(self, func):
|
||||||
def asyncErrorWatcher(func, *args, **kwargs):
|
def asyncErrorWatcher(func, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
func(*args, **kwargs)
|
result = func(*args, **kwargs)
|
||||||
|
if result:
|
||||||
|
self.response(args[0], result)
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
if config.debug: # Allow websocket errors to appear on /Debug
|
if config.debug: # Allow websocket errors to appear on /Debug
|
||||||
sys.modules["main"].DebugHook.handleError()
|
sys.modules["main"].DebugHook.handleError()
|
||||||
|
@ -245,13 +247,16 @@ class UiWebsocket(object):
|
||||||
|
|
||||||
# Support calling as named, unnamed parameters and raw first argument too
|
# Support calling as named, unnamed parameters and raw first argument too
|
||||||
if type(params) is dict:
|
if type(params) is dict:
|
||||||
func(req["id"], **params)
|
result = func(req["id"], **params)
|
||||||
elif type(params) is list:
|
elif type(params) is list:
|
||||||
func(req["id"], *params)
|
result = func(req["id"], *params)
|
||||||
elif params:
|
elif params:
|
||||||
func(req["id"], params)
|
result = func(req["id"], params)
|
||||||
else:
|
else:
|
||||||
func(req["id"])
|
result = func(req["id"])
|
||||||
|
|
||||||
|
if result:
|
||||||
|
self.response(req["id"], result)
|
||||||
|
|
||||||
# Format site info
|
# Format site info
|
||||||
def formatSiteInfo(self, site, create_user=True):
|
def formatSiteInfo(self, site, create_user=True):
|
||||||
|
@ -393,8 +398,8 @@ class UiWebsocket(object):
|
||||||
|
|
||||||
if response_ok:
|
if response_ok:
|
||||||
self.response(to, "ok")
|
self.response(to, "ok")
|
||||||
|
else:
|
||||||
return inner_path
|
return inner_path
|
||||||
|
|
||||||
# Sign and publish content.json
|
# Sign and publish content.json
|
||||||
def actionSitePublish(self, to, privatekey=None, inner_path="content.json", sign=True):
|
def actionSitePublish(self, to, privatekey=None, inner_path="content.json", sign=True):
|
||||||
|
|
Loading…
Reference in a new issue