diff options
author | pzread <netfirewall@gmail.com> | 2013-06-16 03:00:34 +0800 |
---|---|---|
committer | pzread <netfirewall@gmail.com> | 2013-06-16 03:00:34 +0800 |
commit | ef9cd376c41e0992a3cbf7e4a2529d6338d68d7c (patch) | |
tree | 26b6ed96d90646f61afbb36556bbcdb74be4d810 /src/py/imc/proxy.py | |
parent | e8ab9406d9c1e4c0091eea35bf78638e92ed014b (diff) | |
download | taiwan-online-judge-ef9cd376c41e0992a3cbf7e4a2529d6338d68d7c.tar taiwan-online-judge-ef9cd376c41e0992a3cbf7e4a2529d6338d68d7c.tar.gz taiwan-online-judge-ef9cd376c41e0992a3cbf7e4a2529d6338d68d7c.tar.bz2 taiwan-online-judge-ef9cd376c41e0992a3cbf7e4a2529d6338d68d7c.tar.lz taiwan-online-judge-ef9cd376c41e0992a3cbf7e4a2529d6338d68d7c.tar.xz taiwan-online-judge-ef9cd376c41e0992a3cbf7e4a2529d6338d68d7c.tar.zst taiwan-online-judge-ef9cd376c41e0992a3cbf7e4a2529d6338d68d7c.zip |
Add web part. Add filter to imc.js
Diffstat (limited to 'src/py/imc/proxy.py')
-rwxr-xr-x | src/py/imc/proxy.py | 66 |
1 files changed, 28 insertions, 38 deletions
diff --git a/src/py/imc/proxy.py b/src/py/imc/proxy.py index e21b171..6b95674 100755 --- a/src/py/imc/proxy.py +++ b/src/py/imc/proxy.py @@ -146,47 +146,11 @@ class Proxy: return None def register_call(self,path,func_name,func): - parts = path.split('/')[:-1] - child,name,filt = self._callpath_root - i = 0 - size = len(parts) - while i < size: - try: - child,name,filt = child[parts[i]] - i += 1 - - except KeyError: - while i < size: - part = parts[i] - node = ({},{},[]) - child[part] = node - child,name,filt = node - i += 1 - - break - + child,name,filt = self._walk_path(path,True) name[func_name] = func def register_filter(self,path,func): - parts = path.split('/')[:-1] - child,name,filt = self._callpath_root - i = 0 - size = len(parts) - while i < size: - try: - child,name,filt = child[parts[i]] - i += 1 - - except KeyError: - while i < size: - part = parts[i] - node = ({},{},[]) - child[part] = node - child,name,filt = node - i += 1 - - break - + child,name,filt = self._walk_path(path,True) filt.append(func) def call(self,dst,func_name,timeout,*args): @@ -265,6 +229,32 @@ class Proxy: with Auth.change_current_iden(self._idendesc,self._auth): self.call(info['src_link'] + 'imc/','reject_sendfile',65536,filekey) + def _walk_path(self,path,create = False): + parts = path.split('/')[:-1] + child,name,filt = self._callpath_root + i = 0 + size = len(parts) + while i < size: + try: + child,name,filt = child[parts[i]] + i += 1 + + except KeyError: + if create == False: + raise + + else: + while i < size: + part = parts[i] + node = ({},{},[]) + child[part] = node + child,name,filt = node + i += 1 + + break + + return (child,name,filt) + def _route_call(self,in_conn,caller_link,caller_retid,idendesc,dst,func_name,timeout,param): def __add_wait_caller(conn_link): callback = tornado.stack_context.wrap(lambda result : self._ret_call(caller_link,caller_retid,result)) |