def refresh( submodule ): if submodule in _loaded_module_objects: module, mtime = _loaded_module_objects[submodule] dlog("Attempting reload '%s'..." % submodule) try: module = reload(module) except Exception, e: dtrace("There was an error reloading %s :" % module.__file__) return False finally:
def get( module, submodule ): if submodule in _loaded_module_objects: return _loaded_module_objects[ submodule ][0].exported_class full_path = '.'.join( ['urb', module, submodule, 'exported_class'] ) try: cls, mod = _get_class(full_path) dlog("Dynamically loaded %s from %s" % (cls, mod.__file__)) _loaded_module_objects[ submodule ] = mod, _get_mtime(mod.__file__) return cls except Exception, e: dtrace("Exception dynamically importing %s.%s" % (module, submodule)) return None
# session contextual command if hasattr(player.session.context, contextual): # get the command contextual = getattr(player.session.context, contextual) # validate passed arguments against schema try: data = validation.command(self, contextual, args) # run the comand if validated contextual(player.session, data) db.commit() except validation.ValidationError, e: self.tell(player, e.message) except Exception, e: self.tell(player, "Sorry, that command resulted in an error on the server.") dtrace("Context command caused an error : %s %s" % (command, args)) else: # its not contextual so check dynamic commands comm_cls = commands.get(command) if comm_cls: # validate passed arguments against schema try: data = validation.command(self, comm_cls, args) # create live command object new_comm = comm_cls(self, player, data) # let command verify submission new_comm.verify() new_comm.perform() db.commit() return except validation.ValidationError, e: self.tell(player, e.message)