[Modeling-cvs] ProjectModeling/Modeling Model.py,1.4.2.2,1.4.2.3
Status: Abandoned
Brought to you by:
sbigaret
|
From: <sbi...@us...> - 2003-06-28 15:30:43
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv10680
Modified Files:
Tag: brch-0_9pre7-1-PyModel
Model.py
Log Message:
loadModel() now raises ValueError whan it cannot handle the given file
Index: Model.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Model.py,v
retrieving revision 1.4.2.2
retrieving revision 1.4.2.3
diff -C2 -d -r1.4.2.2 -r1.4.2.3
*** Model.py 17 Jun 2003 16:55:54 -0000 1.4.2.2
--- Model.py 28 Jun 2003 15:30:40 -0000 1.4.2.3
***************
*** 88,91 ****
--- 88,93 ----
if cfg_path is None:
cfg_path=os.environ.get('MDL_DB_CONNECTIONS_CFG')
+ if cfg_path is None:
+ return
from ConfigParser import ConfigParser
***************
*** 137,141 ****
Returns: the loaded Modeling.Model.Model instance
! Raises IOError if file 'path' cannot be found
Parameter:
--- 139,143 ----
Returns: the loaded Modeling.Model.Model instance
! Raises ValueError if file 'path' cannot be handled.
Parameter:
***************
*** 156,166 ****
if hasattr(module, 'model'):
model=module.model
! if callable(model):
model=model()
updateModelWithCFG(model)
return model
if hasattr(module, 'pymodel'):
! model=module.pymodel
if callable(pymodel):
pymodel=pymodel()
--- 158,174 ----
if hasattr(module, 'model'):
model=module.model
! from mems_lib import isinstance
! if callable(model) and not isinstance(model, Model):
! # Model.Model derives from ZODB.Persistent, hence it is callable
! # but it shouldn't be called!
model=model()
+ import PyModel
+ if isinstance(model, PyModel.Model):
+ model=model.component
updateModelWithCFG(model)
return model
if hasattr(module, 'pymodel'):
! pymodel=module.pymodel
if callable(pymodel):
pymodel=pymodel()
***************
*** 177,181 ****
return model
! raise IOError, "Couldn't find any of these attributes in python file '%s': model, pymodel (PyModel) or model_src (xml)"%path
except:
--- 185,189 ----
return model
! raise ValueError, "Couldn't find any of these attributes in python file '%s': model, pymodel (PyModel) or model_src (xml)"%path
except:
***************
*** 183,187 ****
exc=cStringIO.StringIO()
traceback.print_exc(file=exc)
! raise IOError, 'Unable to handle python file %s\nReason: exception raised:\n%s'%(path,exc.getvalue())
finally:
--- 191,195 ----
exc=cStringIO.StringIO()
traceback.print_exc(file=exc)
! raise ValueError, 'Unable to handle python file %s\nReason: exception raised:\n%s'%(path,exc.getvalue())
finally:
***************
*** 192,196 ****
else:
! raise IOError, 'Unable to load file %s'%path
def searchModel(modelName, path=None, verbose=0):
--- 200,204 ----
else:
! raise ValueError, 'Unable to handle file %s: unrecognized format (filename should end with either with .py or .xml)'%path
def searchModel(modelName, path=None, verbose=0):
***************
*** 221,224 ****
--- 229,233 ----
model=loadModel(file)
except IOError:
+ except ValueError:
import cStringIO, traceback
exc=cStringIO.StringIO()
|