def __handleInternalRequest(pathNouns, _path, **kwargs): # # Handle a request internally # if len(pathNouns) > 1: if pathNouns[1] == "resources": if len(pathNouns) == 3: ext = pathNouns[2][pathNouns[2].rfind("."):] PMS.Log("(Framework) Getting resource named '%s'" % pathNouns[2]) resource = Resource.Load(pathNouns[2]) return Objects.DataObject(resource, Resource.MimeTypeForExtension(ext)) if pathNouns[1] == "sharedresources": if len(pathNouns) == 3: ext = pathNouns[2][pathNouns[2].rfind("."):] PMS.Log("(Framework) Getting shared resource named '%s'" % pathNouns[2]) resource = Resource.LoadShared(pathNouns[2]) return Objects.DataObject(resource, Resource.MimeTypeForExtension(ext)) elif pathNouns[1] == "function" and len(pathNouns) >= 3: name = pathNouns[2] pos = name.rfind(".") if pos > -1: name = name[:pos] PMS.Log(name) if name not in __reservedFunctionNames: if len(pathNouns) == 4: kwargs['query'] = pathNouns[3] result = __callNamed(name, **kwargs) #PMS.Log(result) return result elif pathNouns[1] == "prefs": if len(pathNouns) == 2: return Prefs.__container() else: Prefs.__setAll(kwargs) result = __callNamed("ValidatePrefs", addToLog=False) if result: return result else: return ''
def __handleInternalRequest(pathNouns, path, **kwargs): # # Handle a request internally # if len(pathNouns) > 1: if pathNouns[1] == "resources": if len(pathNouns) == 3: if Resource.__publicResources.has_key(pathNouns[2]): PMS.Log("(Framework) Getting resource named '%s'" % pathNouns[2]) resource = Resource.Load(pathNouns[2]) return Objects.DataObject( resource, Resource.__publicResources[pathNouns[2]]) if pathNouns[1] == "sharedresources": if len(pathNouns) == 3: if Resource.__publicSharedResources.has_key(pathNouns[2]): PMS.Log("(Framework) Getting shared resource named '%s'" % pathNouns[2]) resource = Resource.LoadShared(pathNouns[2]) return Objects.DataObject( resource, Resource.__publicSharedResources[pathNouns[2]]) elif pathNouns[1] == "function" and len(pathNouns) >= 4: name = pathNouns[2] if name not in __reservedFunctionNames: encodedArgs = pathNouns[3] pos = encodedArgs.rfind(".") if pos > -1: encodedArgs = encodedArgs[:pos] fkwargs = pickle.loads(D(encodedArgs)) # Override encoded kwargs with kwargs passed in the URL for key in kwargs: fkwargs[key] = kwargs[key] if len(pathNouns) == 4: return __callNamed(name, **fkwargs) elif len(pathNouns) == 5: return __callNamed(name, query=pathNouns[4], **fkwargs) elif pathNouns[1] == "prefs": if len(pathNouns) == 2: return Prefs.__container() else: Prefs.__setAll(kwargs) return __callNamed("ValidatePrefs", addToLog=False)