[Modeling-cvs] ProjectModeling/Modeling ModelSet.py,1.7,1.7.2.1
Status: Abandoned
Brought to you by:
sbigaret
From: <sbi...@us...> - 2003-06-17 16:57:46
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv4314 Modified Files: Tag: brch-0_9pre7-1-PyModel ModelSet.py Log Message: Deprecated method: updateModelWithCFG() --moved in Model Index: ModelSet.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelSet.py,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -C2 -d -r1.7 -r1.7.2.1 *** ModelSet.py 7 May 2003 11:28:45 -0000 1.7 --- ModelSet.py 17 Jun 2003 16:57:43 -0000 1.7.2.1 *************** *** 100,161 **** def updateModelWithCFG(model, cfg_path): """ ! Updates the model's connection dictionary and adaptorName with the values ! in file 'cfg_path'. ! ! A sample configuration file is like:: ! ! [DEFAULT] ! host: localhost ! ! [ModelName_1] ! user: user_1 ! password: pwd_1 ! ! [ModelName_2] ! adaptor: MySQL ! user: user_2 ! password: pwd_2 ! ! The special field 'adaptor', if present, changes the adaptorName of the ! model. ! ! Raises IOError if file 'cfg_path' cannot be found. ! ! See also: ModelSet.addModel() ! ! Parameters: ! ! model -- the model whose conn.dict. should be updated ! ! cfg_path -- the full path to the configuration file ! """ ! from ConfigParser import ConfigParser ! import os ! defaults=model.connectionDictionary() ! cp=ConfigParser() ! try: ! cp.readfp(open(cfg_path)) ! except IOError: ! import traceback, cStringIO, sys ! exc_raised=sys.exc_info()[:2] ! err_msg="Unable to open file '%s' pointed by env. variable MDL_DB_CONNECTIONS_CFG"%cfg_path ! exc=cStringIO.StringIO() ! traceback.print_exception(exc_raised[0], exc_raised[1], None, file=exc) ! err_msg+="\nOriginal exception was: %s"%exc.getvalue() ! raise IOError, err_msg - try: options=cp.options(model.name()) - except: return - try: options.remove('adaptor') - except ValueError: pass - for key in options: - defaults[key]=cp.get(model.name(), key) - model.setConnectionDictionary(defaults) - try: - model.setAdaptorName(cp.get(model.name(), 'adaptor')) - except: - pass - class ModelSet(Persistent): """Holds a set of Modeling.Models that can co-exist at runtime --- 100,110 ---- def updateModelWithCFG(model, cfg_path): """ ! Deprecated: use Model.updateModelWithCFG instead. This method will be ! removed in v0.9.1 """ ! import warnings ! warnings.warn("ModelSet.updateModelWithCFG() is deprecated: use Model.updateModelWithCFG() instead. This method will be removed in v0.9.1", DeprecationWarning) ! return Model.updateModelWithCFG(model, cfg_path) class ModelSet(Persistent): """Holds a set of Modeling.Models that can co-exist at runtime *************** *** 184,188 **** If the environment variable 'MDL_DB_CONNECTIONS_CFG' is set, the file it points to is used to update aModel's connection dictionary (and ! possibly its adaptorName as well). See updateModelWithCFG() for details. """ #assert --- 133,138 ---- If the environment variable 'MDL_DB_CONNECTIONS_CFG' is set, the file it points to is used to update aModel's connection dictionary (and ! possibly its adaptorName as well). See Model.updateModelWithCFG() for ! details. """ #assert *************** *** 204,209 **** cfg_path=os.environ.get('MDL_DB_CONNECTIONS_CFG') if cfg_path: updateModelWithCFG(aModel, cfg_path) ! # XML Import/Export facilities def addModelFromXML(self, xmlSource): --- 154,160 ---- cfg_path=os.environ.get('MDL_DB_CONNECTIONS_CFG') if cfg_path: + from Model import updateModelWithCFG updateModelWithCFG(aModel, cfg_path) ! # XML Import/Export facilities def addModelFromXML(self, xmlSource): |