--- nfo/projects/netfraggle/bin/FraggleCtlModules.py 2004/09/04 20:26:01 1.3 +++ nfo/projects/netfraggle/bin/FraggleCtlModules.py 2004/09/21 18:04:42 1.6 @@ -13,31 +13,56 @@ def __init__(self,parent): self.modules = self.ScanModules() self.engine = parent + self.modfile = os.path.join(self.engine.getDefaultDir(), 'modules.xml') pass + def SaveModules(self,lmodules): + fraggleXml = fraggleParserXML.create(self) + fraggleXml.marshalXML(lmodules,self.modfile) + + def LoadModules(self): + fraggleXml = fraggleParserXML.create(self) + return fraggleXml.unmarshalXML(self.modfile) + + def SetViewport(self,viewport): + self.viewport = viewport + + def Dispatch(self,seldata,seltype): + print "Type: "+seltype + for i in self.modules: + print "Module: "+i + if i == seltype: + module = self.modules[i] + moduleInstance = module.create(self.viewport) + moduleInstance.load_content(seldata['3']) + print module + def ScanModules(self): os.chdir('..') + sys.path.append(os.path.join(os.getcwd(),'modules')) self.dir = os.listdir(os.path.join(os.getcwd(),'modules')) for i in self.dir: self.dir[self.dir.index(i)] = string.rstrip(i,'.py') - + #print self.dir if len(self.dir) != 0: try: for i in self.dir: - try: - fmodules[i] = i - except NameError: - fmodules = {i:i} + if string.find(i,'CVS') == -1 and string.find(i,'.pyc') == -1: + #print i + try: + fmodules[i] = __import__(i) + except NameError: + fmodules = {i:__import__(i)} + #print fmodules + try: print fmodules - print self.dir - - del fmodules['CVS'] - return fmodules + return fmodules + except UnboundLocalError: + return None except ImportError: pass - return None