def __registerFuncs(_F_REGISTERS): # replace some system function definition with a server-proof version: if len(_F_REGISTERS): import myclips.functions as _mycfuncs # manually bootstrap system functions _mycfuncs.SystemFunctionBroker.bootstrap() for _funcInfo in _F_REGISTERS: myclips_server.logger.info("Registering: %s", str(_funcInfo)) _moduleName = "<none>" _className = "<none>" try: # prepare the replacement _moduleName = _funcInfo['module'] _className = _funcInfo['class'] _funcInstance = myclips.newInstance(_className, None, _moduleName) _mycfuncs.SystemFunctionBroker.register(_funcInstance, False) except: myclips_server.logger.critical("Error registering %s.%s\n%s---------------\n", _moduleName, _className, traceback.format_exc() ) else: # then replace the definition myclips_server.logger.info("\t\t...Done")
def __registerFuncs(_F_REGISTERS): # replace some system function definition with a server-proof version: if len(_F_REGISTERS): import myclips.functions as _mycfuncs # manually bootstrap system functions _mycfuncs.SystemFunctionBroker.bootstrap() for _funcInfo in _F_REGISTERS: myclips_server.logger.info("Registering: %s", str(_funcInfo)) _moduleName = "<none>" _className = "<none>" try: # prepare the replacement _moduleName = _funcInfo['module'] _className = _funcInfo['class'] _funcInstance = myclips.newInstance( _className, None, _moduleName) _mycfuncs.SystemFunctionBroker.register( _funcInstance, False) except: myclips_server.logger.critical( "Error registering %s.%s\n%s---------------\n", _moduleName, _className, traceback.format_exc()) else: # then replace the definition myclips_server.logger.info("\t\t...Done")
except KeyError, e: try: importFile = funcDict['import'] importFile = "/".join([FUNCTIONS_DIR.rstrip("/"), importFile]) except KeyError, e: myclips.logger.error("Malformed function definition in manifest file %s:\n\tError: %s\n\tDefinition: %s", manifestPath, repr(e), str(funcDict)) else: try: funcListInside = json.load(open(importFile, "rU")) except Exception, e: myclips.logger.error("Functions manifest file %s cannot be loaded: %s", importFile, repr(e)) else: funcList.extend(funcListInside) else: try: funcInstance = myclips.newInstance(funcClass, None, funcModule) except ImportError, e: myclips.logger.error("Error loading function definition class: %s", e) else: cls.register(funcInstance) class SystemFunctionRedefinitionError(MyClipsException): ''' Raised on attempt to redefine a already defined system function ''' pass