New UiWebsocket API command to run commands as other site
This commit is contained in:
parent
8a331e7400
commit
1ac69ae315
1 changed files with 11 additions and 0 deletions
|
@ -5,6 +5,7 @@ import hashlib
|
|||
import os
|
||||
import shutil
|
||||
import re
|
||||
import copy
|
||||
|
||||
import gevent
|
||||
|
||||
|
@ -321,6 +322,16 @@ class UiWebsocket(object):
|
|||
|
||||
# - Actions -
|
||||
|
||||
def actionAs(self, to, address, cmd, params=[]):
|
||||
if not self.hasSitePermission(address):
|
||||
return self.response(to, "No permission for site %s" % address)
|
||||
req_self = copy.copy(self)
|
||||
req_self.site = self.server.sites.get(address)
|
||||
req_self.hasCmdPermission = self.hasCmdPermission # Use the same permissions as current site
|
||||
req_obj = super(UiWebsocket, req_self)
|
||||
req = {"id": to, "cmd": cmd, "params": params}
|
||||
req_obj.handleRequest(req)
|
||||
|
||||
# Do callback on response {"cmd": "response", "to": message_id, "result": result}
|
||||
def actionResponse(self, to, result):
|
||||
if to in self.waiting_cb:
|
||||
|
|
Loading…
Reference in a new issue