modeling-cvs Mailing List for Object-Relational Bridge for python (Page 30)
Status: Abandoned
Brought to you by:
sbigaret
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
(54) |
Apr
(29) |
May
(94) |
Jun
(47) |
Jul
(156) |
Aug
(132) |
Sep
(40) |
Oct
(6) |
Nov
(18) |
Dec
(24) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(18) |
Feb
(59) |
Mar
(7) |
Apr
|
May
(8) |
Jun
(2) |
Jul
(12) |
Aug
(15) |
Sep
(12) |
Oct
(6) |
Nov
(25) |
Dec
(1) |
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
(27) |
Mar
|
Apr
(16) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <sbi...@us...> - 2003-05-06 13:21:32
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv29562 Modified Files: DatabaseChannel.py Log Message: Fixed selectObjectsWithFetchSpecification(): should cancelfetch() when something goes wrong Index: DatabaseChannel.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseChannel.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** DatabaseChannel.py 6 May 2003 12:20:32 -0000 1.12 --- DatabaseChannel.py 6 May 2003 13:21:29 -0000 1.13 *************** *** 348,369 **** raise RuntimeError, 'a fetch in already in progress' self.__isFetchInProgress=1 ! # Reinitializes settings ! self.setCurrentEditingContext(anEditingContext) ! import ModelSet ! defModelSet=ModelSet.defaultModelSet() ! entity=defModelSet.entityNamed(aFetchSpecification.entityName()) ! self.setCurrentEntity(entity) ! self.setIsLocking(aFetchSpecification.locksObjects()) ! self.setIsRefreshingObjects(aFetchSpecification.refreshesRefetchedObjects()) ! # Get an adaptorChannel ! if not self._adaptorChannel.isOpen(): ! self._adaptorChannel.openChannel() ! ! #self._adaptorChannel.executeExpression(sqlExpr) ! self._adaptorChannel.selectAttributes(entity.attributesToFetch(), ! aFetchSpecification, ! self._isLocking, ! entity) def setCurrentEditingContext(self, anEditingContext): """ --- 348,374 ---- raise RuntimeError, 'a fetch in already in progress' self.__isFetchInProgress=1 ! try: ! # Reinitializes settings ! self.setCurrentEditingContext(anEditingContext) ! import ModelSet ! defModelSet=ModelSet.defaultModelSet() ! entity=defModelSet.entityNamed(aFetchSpecification.entityName()) ! self.setCurrentEntity(entity) ! self.setIsLocking(aFetchSpecification.locksObjects()) ! self.setIsRefreshingObjects(aFetchSpecification.refreshesRefetchedObjects()) ! # Get an adaptorChannel ! if not self._adaptorChannel.isOpen(): ! self._adaptorChannel.openChannel() + #self._adaptorChannel.executeExpression(sqlExpr) + self._adaptorChannel.selectAttributes(entity.attributesToFetch(), + aFetchSpecification, + self._isLocking, + entity) + except: + # If something went wrong we must cancel the fetch in progress + self.cancelFetch() + raise + def setCurrentEditingContext(self, anEditingContext): """ |
From: <sbi...@us...> - 2003-05-06 12:20:35
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv3082 Modified Files: CHANGES DatabaseChannel.py Log Message: Fixed DatabaseChannel.fetchObject(): it was not MT-safe wrt Database snapshots' caching when an EC in an other thread is garbage-collected in the middle of fetchObject() (see comments in the code for further details) Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v retrieving revision 1.98 retrieving revision 1.99 diff -C2 -d -r1.98 -r1.99 *** CHANGES 25 Apr 2003 18:13:33 -0000 1.98 --- CHANGES 6 May 2003 12:20:31 -0000 1.99 *************** *** 8,11 **** --- 8,15 ---- -------------------------------------------------------- + * Fixed DatabaseChannel.fetchObject(): it was not MT-safe wrt Database + snapshots' caching in some circumstances (see comments in the code for + further details) + * Added scripts/mdl_compile_model.py and update the __init__.py generated by mdl_generate_DB_schema.py so that it automatically tries to load the Index: DatabaseChannel.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseChannel.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** DatabaseChannel.py 14 Mar 2003 11:40:06 -0000 1.11 --- DatabaseChannel.py 6 May 2003 12:20:32 -0000 1.12 *************** *** 150,229 **** self.databaseContext().registerLockedObjectWithGlobalID(globalID) ! # Handle snapshot ! # NB: ask delegate __TBD ! if self.isRefreshingObjects() or self.isLocking(): ! # Unconditional refresh ! database.recordSnapshotForGlobalID(snapshot, globalID) ! if self.isRefreshingObjects(): ! # NB: isLocking-> no need to invalidate objects since two ECs cannot ! # hold the same object at the same time ! NC.postNotification(ObjectsChangedInStoreNotification, self, ! {UpdatedKey: (globalID,)}) ! else: ! # Should the snapshot be updated? if there is already one, no update. ! # __TBD ask the DatabaseContext delegate whether we should refresh ! # __TBD and, if yes, post ObjectsChangedInStoreNotification ! registeredSnapshot=database.snapshotForGlobalID(globalID) ! if not registeredSnapshot: database.recordSnapshotForGlobalID(snapshot, globalID) else: ! snapshot=registeredSnapshot ! ec=self._editingContext ! object=ec.objectForGlobalID(globalID) ! ! if object is not None and not object.isFault(): ! return object ! ! if object is not None and object.isFault(): ! #NC.removeObserver(object.faultHandler(), GlobalIDChangedNotification, ! # globalID) ! NC.removeObserver(ec, GlobalIDChangedNotification, globalID) ! #object.clearFault() ! #else: ! cd=ClassDescription.classDescriptionForName(self._currentEntity.name()) ! # first, check that we do not have a fault registered under the ``root'' ! # GlobalID ! root_cd_name=cd.rootClassDescription().entityName() ! ! if root_cd_name!=cd.entityName(): ! root_globalID=KeyGlobalID(root_cd_name, globalID.keyValues()) ! trace('Searching for possible fault w/ rootGlobalID=%s'%root_globalID) ! possible_faulted_object=ec.objectForGlobalID(root_globalID) ! if possible_faulted_object: ! if possible_faulted_object.isFault(): ! trace('Found it: posting GlobalIDChangedNotification') ! NC.postNotification(GlobalIDChangedNotification, root_globalID, ! {root_globalID: globalID}) ! object=possible_faulted_object ! # useless: it did receive the notification, and it has unregistered ! # itself from the list of the observers ! #NC.removeObserver(object.faultHandler(), ! # GlobalIDChangedNotification, globalID) ! object.clearFault() ! new_class=cd.classForInstances() ! object.__class__=new_class ! object.__class__.__init__(object) ! else: ! raise RuntimeError, "Serious: shouldn't happen, please report" else: ! # create object ! object=cd.createInstanceWithEditingContext(ec) ! ec.recordObject(object, globalID) ! else: ! if not object: ! # create object ! object=cd.createInstanceWithEditingContext(ec) ! ec.recordObject(object, globalID) ! ! # Initialize the new object or the cleared fault ! try: ! object.clearFault() ! except: ! pass ! ec.initializeObject(object, globalID, ec) ! return object --- 150,256 ---- self.databaseContext().registerLockedObjectWithGlobalID(globalID) ! ! # Now we need to lock the corresponding database object. Why? ! # ! # One could argue that e.g. since an EC forwards objectsWithFetchSpec() ! # ultimately to its root object store --an ObjectStoreCoordinator--, and ! # since OSC locks/unlocks itself before/after each operation, an other EC ! # used in a concurrent thread can access the Database object (and its ! # snapshots) in the meantime. ! # ! # This is true w.r.t. ECs standard operations, but there remains a case ! # where a concurrent thread can change the Database's snapshots: when an ! # EC is finalized and garbage-collected, it forgets its objects and ! # decrements the corresponding snapshot reference count --at this time, if ! # the ref.count falls down to zero, the snapshot is removed from the ! # Database's snapshots cache. ! # ! # Now this can happen in another thread while in this thread, the snapshot ! # has been retrieved but it has not been used yet by ec.initializeObject() ! # (forwarded to and handled by DBContext.initializeObject()). When this ! # happens, Database.incrementSnapshotCountForGlobalID() called by ! # DBContext.initializeObject() raises KeyError on the corresp. GlobalID ! # since the corresponding snapshot has been thrown away. ! # ! database.lock() ! try: ! # Handle snapshot ! # NB: ask delegate __TBD ! if self.isRefreshingObjects() or self.isLocking(): ! # Unconditional refresh database.recordSnapshotForGlobalID(snapshot, globalID) + if self.isRefreshingObjects(): + # NB: isLocking-> no need to invalidate objects since two ECs cannot + # hold the same object at the same time + NC.postNotification(ObjectsChangedInStoreNotification, self, + {UpdatedKey: (globalID,)}) else: ! # Should the snapshot be updated? if there is already one, no update. ! # __TBD ask the DatabaseContext delegate whether we should refresh ! # __TBD and, if yes, post ObjectsChangedInStoreNotification ! registeredSnapshot=database.snapshotForGlobalID(globalID) ! if not registeredSnapshot: ! database.recordSnapshotForGlobalID(snapshot, globalID) ! else: ! snapshot=registeredSnapshot ! ! ec=self._editingContext ! object=ec.objectForGlobalID(globalID) ! ! if object is not None and not object.isFault(): ! return object ! ! if object is not None and object.isFault(): ! #NC.removeObserver(object.faultHandler(), GlobalIDChangedNotification, ! # globalID) ! NC.removeObserver(ec, GlobalIDChangedNotification, globalID) ! #object.clearFault() ! #else: ! cd=ClassDescription.classDescriptionForName(self._currentEntity.name()) ! # first, check that we do not have a fault registered under the ``root'' ! # GlobalID ! root_cd_name=cd.rootClassDescription().entityName() ! if root_cd_name!=cd.entityName(): ! root_globalID=KeyGlobalID(root_cd_name, globalID.keyValues()) ! trace('Searching for possible fault w/ rootGlobalID=%s'%root_globalID) ! possible_faulted_object=ec.objectForGlobalID(root_globalID) ! if possible_faulted_object: ! if possible_faulted_object.isFault(): ! trace('Found it: posting GlobalIDChangedNotification') ! NC.postNotification(GlobalIDChangedNotification, root_globalID, ! {root_globalID: globalID}) ! object=possible_faulted_object ! # useless: it did receive the notification, and it has unregistered ! # itself from the list of the observers ! #NC.removeObserver(object.faultHandler(), ! # GlobalIDChangedNotification, globalID) ! object.clearFault() ! new_class=cd.classForInstances() ! object.__class__=new_class ! object.__class__.__init__(object) ! ! else: ! raise RuntimeError, "Serious: shouldn't happen, please report" else: ! # create object ! object=cd.createInstanceWithEditingContext(ec) ! ec.recordObject(object, globalID) else: ! if not object: ! # create object ! object=cd.createInstanceWithEditingContext(ec) ! ec.recordObject(object, globalID) ! ! # Initialize the new object or the cleared fault ! try: ! object.clearFault() ! except: ! pass ! ec.initializeObject(object, globalID, ec) ! finally: ! database.unlock() ! return object *************** *** 332,336 **** if not self._adaptorChannel.isOpen(): self._adaptorChannel.openChannel() ! #self._adaptorChannel.executeExpression(sqlExpr) self._adaptorChannel.selectAttributes(entity.attributesToFetch(), --- 359,363 ---- if not self._adaptorChannel.isOpen(): self._adaptorChannel.openChannel() ! #self._adaptorChannel.executeExpression(sqlExpr) self._adaptorChannel.selectAttributes(entity.attributesToFetch(), *************** *** 338,342 **** self._isLocking, entity) - def setCurrentEditingContext(self, anEditingContext): --- 365,368 ---- |
From: <sbi...@us...> - 2003-04-25 18:39:18
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks In directory sc8-pr-cvs1:/tmp/cvs-serv17242/ModelMasons/Python_bricks Modified Files: init.tmpl Log Message: Corrected: sorry, I took some code from branch 0_9pre6_ModelMasons_base_generation_scheme + fixed some silly bugs Index: init.tmpl =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks/init.tmpl,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** init.tmpl 25 Apr 2003 18:13:35 -0000 1.4 --- init.tmpl 25 Apr 2003 18:39:13 -0000 1.5 *************** *** 11,15 **** script mdl_compile_model.py ! Simply returns if a model named '$model_name' has already been loaded """ from Modeling import ModelSet --- 11,15 ---- script mdl_compile_model.py ! Simply returns if a model named "$model_name" has already been loaded """ from Modeling import ModelSet *************** *** 18,26 **** return try: - #if $base_dir: - from $(base_dir).model_$(model_name)_pickle import model_pickle - #else from model_$(model_name)_pickle import model_pickle - #end if import cPickle m=cPickle.loads(model_pickle) --- 18,22 ---- *************** *** 37,49 **** try: - #if $base_dir: - from $(base_dir).model_$(model_name) import model_src - #else from model_$(model_name) import model_src - #end if ModelSet.defaultModelSet().addModelFromXML({'string': model_src}) model=ModelSet.defaultModelSet().modelNamed("$(model_name)") except: ! exc=StringIO.StringIO() traceback.print_exc(file=exc) warnings.warn("Couldn't load model 'model_$(model_name).xml'\nReason:\n%s"%exc.getvalue()) --- 33,41 ---- try: from model_$(model_name) import model_src ModelSet.defaultModelSet().addModelFromXML({'string': model_src}) model=ModelSet.defaultModelSet().modelNamed("$(model_name)") except: ! exc=cStringIO.StringIO() traceback.print_exc(file=exc) warnings.warn("Couldn't load model 'model_$(model_name).xml'\nReason:\n%s"%exc.getvalue()) |
From: <sbi...@us...> - 2003-04-25 18:37:40
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks In directory sc8-pr-cvs1:/tmp/cvs-serv16690/Python_bricks Modified Files: module_base.tmpl Log Message: Fixed: incorrect import statement Index: module_base.tmpl =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks/module_base.tmpl,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** module_base.tmpl 20 Apr 2003 16:10:40 -0000 1.1 --- module_base.tmpl 25 Apr 2003 18:37:35 -0000 1.2 *************** *** 1,5 **** ## This template will build the module #for entity in $entities: ! from $(entity.className())Base import $(entity.className())Base #end for from Modeling.Validation import ValidationException --- 1,5 ---- ## This template will build the module #for entity in $entities: ! from $(entity.moduleName())Base import $(entity.className())Base #end for from Modeling.Validation import ValidationException |
From: <sbi...@us...> - 2003-04-25 18:14:09
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv7380/Modeling Modified Files: CHANGES Log Message: Added scripts/mdl_compile_model.py and update the __init__.py generated by mdl_generate_DB_schema.py so that it automatically tries to load the pickled model. Using the pickled model is *much* faster than loading the model from its xml description. Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -d -r1.97 -r1.98 *** CHANGES 22 Apr 2003 17:05:25 -0000 1.97 --- CHANGES 25 Apr 2003 18:13:33 -0000 1.98 *************** *** 8,11 **** --- 8,16 ---- -------------------------------------------------------- + * Added scripts/mdl_compile_model.py and update the __init__.py generated by + mdl_generate_DB_schema.py so that it automatically tries to load the + pickled model. Using the pickled model is *much* faster than loading the + model from its xml description. + * Fixed AbstractDBAPI2Adaptor.create/dropDatabaseWithAdmin.Conn.Dict.(): under some circumstances it was possible that createDB() fails when called |
From: <sbi...@us...> - 2003-04-25 18:14:07
|
Update of /cvsroot/modeling/ProjectModeling In directory sc8-pr-cvs1:/tmp/cvs-serv7380 Modified Files: setup.py Log Message: Added scripts/mdl_compile_model.py and update the __init__.py generated by mdl_generate_DB_schema.py so that it automatically tries to load the pickled model. Using the pickled model is *much* faster than loading the model from its xml description. Index: setup.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/setup.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** setup.py 21 Apr 2003 22:25:55 -0000 1.22 --- setup.py 25 Apr 2003 18:13:32 -0000 1.23 *************** *** 65,68 **** scripts = ['Modeling/scripts/mdl_generate_DB_schema.py', 'Modeling/scripts/mdl_generate_python_code.py', ! 'Modeling/scripts/mdl_validate_model.py', ] ) --- 65,69 ---- scripts = ['Modeling/scripts/mdl_generate_DB_schema.py', 'Modeling/scripts/mdl_generate_python_code.py', ! 'Modeling/scripts/mdl_validate_model.py', ! 'Modeling/scripts/mdl_compile_model.py', ] ) |
From: <sbi...@us...> - 2003-04-25 18:13:41
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks In directory sc8-pr-cvs1:/tmp/cvs-serv7380/Modeling/ModelMasons/Python_bricks Modified Files: init.tmpl Log Message: Added scripts/mdl_compile_model.py and update the __init__.py generated by mdl_generate_DB_schema.py so that it automatically tries to load the pickled model. Using the pickled model is *much* faster than loading the model from its xml description. Index: init.tmpl =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks/init.tmpl,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** init.tmpl 7 Aug 2002 22:18:48 -0000 1.3 --- init.tmpl 25 Apr 2003 18:13:35 -0000 1.4 *************** *** 3,38 **** # Load the model ! from Modeling import ModelSet ! import os, warnings, StringIO, traceback ! from model_$(model_name) import model_src ! try: ! if ModelSet.defaultModelSet().modelNamed("$(model_name)") is None: ! ModelSet.defaultModelSet().addModelFromXML({'string': model_src}) ! model=ModelSet.defaultModelSet().modelNamed('$(model_name)') ! except: ! exc=StringIO.StringIO() ! traceback.print_exc(file=exc) ! warnings.warn("Couldn't load model 'model_$(model_name).xml'\nReason:\n%s"%exc.getvalue()) ! del exc ! del os, warnings, StringIO, traceback, model_src ! # Or, alternatively: use the xml file (ok for dev. mode, not for install w/ ! # distutils) ! # ! # from Modeling import ModelSet ! # import os, warnings, StringIO, traceback ! # try: ! # if ModelSet.defaultModelSet().modelNamed("$(model_name)") is None: ! # from os import getcwd, path ! # mydir = os.path.abspath(os.path.dirname(__file__)) ! # xmlmodelPath=path.join(mydir,'model_$(model_name).xml') ! # ModelSet.defaultModelSet().addModelFromXML({'file': xmlmodelPath}) ! # model=ModelSet.defaultModelSet().modelNamed('$(model_name)') ! # except: ! # exc=StringIO.StringIO() ! # traceback.print_exc(file=exc) ! # warnings.warn("Couldn't load model 'model_$(model_name).xml'\nReason:\n%s"%exc.getvalue()) ! # del exc ! # ! # del os, warnings, StringIO, traceback --- 3,69 ---- # Load the model ! #--------------------------------------- ! def loadModel(): ! """Load model from either the pickled model created by mdl_compile_model.py ! or from the string stored in model_$(model_name).model_src ! The module containing the pickled model is usually generated with the ! script mdl_compile_model.py ! Simply returns if a model named '$model_name' has already been loaded ! """ ! from Modeling import ModelSet ! import os, warnings, cStringIO, traceback ! if ModelSet.defaultModelSet().modelNamed("$(model_name)") is not None: ! return ! try: ! #if $base_dir: ! from $(base_dir).model_$(model_name)_pickle import model_pickle ! #else ! from model_$(model_name)_pickle import model_pickle ! #end if ! import cPickle ! m=cPickle.loads(model_pickle) ! ModelSet.defaultModelSet().addModel(m) ! model=ModelSet.defaultModelSet().modelNamed("$(model_name)") ! except: ! exc=cStringIO.StringIO() ! traceback.print_exc(file=exc) ! warnings.warn("Couldn't load model from pickle'\n"\ ! "Reason:\n%s"%exc.getvalue()) ! del exc ! else: ! return ! ! try: ! #if $base_dir: ! from $(base_dir).model_$(model_name) import model_src ! #else ! from model_$(model_name) import model_src ! #end if ! ModelSet.defaultModelSet().addModelFromXML({'string': model_src}) ! model=ModelSet.defaultModelSet().modelNamed("$(model_name)") ! except: ! exc=StringIO.StringIO() ! traceback.print_exc(file=exc) ! warnings.warn("Couldn't load model 'model_$(model_name).xml'\nReason:\n%s"%exc.getvalue()) ! del exc ! ! # Or, alternatively: use the xml file (ok for dev. mode, not for install w/ ! # distutils) ! # ! # try: ! # from os import getcwd, path ! # mydir = os.path.abspath(os.path.dirname(__file__)) ! # xmlmodelPath=path.join(mydir,'model_$(model_name).xml') ! # ModelSet.defaultModelSet().addModelFromXML({'file': xmlmodelPath}) ! # model=ModelSet.defaultModelSet().modelNamed('$(model_name)') ! # except: ! # exc=cStringIO.StringIO() ! # traceback.print_exc(file=exc) ! # warnings.warn("Couldn't load model 'model_$(model_name).xml'\nReason:\n%s"%exc.getvalue()) ! # del exc ! # ! # del os, warnings, StringIO, traceback ! #--------------------------------------- ! loadModel() |
From: <sbi...@us...> - 2003-04-25 18:13:41
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv7380/Modeling/scripts Added Files: mdl_compile_model.py Log Message: Added scripts/mdl_compile_model.py and update the __init__.py generated by mdl_generate_DB_schema.py so that it automatically tries to load the pickled model. Using the pickled model is *much* faster than loading the model from its xml description. --- NEW FILE: mdl_compile_model.py --- #! /usr/bin/env python #----------------------------------------------------------------------------- # # Modeling Framework: an Object-Relational Bridge for python # (c) 2001, 2002, 2003 Sebastien Bigaret # # This file is part of the Modeling Framework. # # The Modeling Framework is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 2 of the License, or (at # your option) any later version. # # The Modeling Framework is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License along # with the Modeling Framework; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # #----------------------------------------------------------------------------- """ compile_model.py ``Compile'' an xml_model into two python modules, model_<modelName>.py and model_<modelName>_pickled.py: - model_<model_name>.py: contains the whole xml-file in a single module attribute: model_src - model_<modelName>_pickled.py: the second one contains a single attribute as well: model_pickle, which is a raw string to be loaded by cPickle.loads() Storing the model in a python file make it easier to install a package and its model using distutils. Storing the pickled version accelerates the loading of a model. Written by: Sebastien Bigaret """ import sys, getopt def loadModel(xmlFilePath): """ Creates a python module (file: model_<modelName>.py) and dumps the content of the file 'xmlFilePath' in a string attribute named 'model_src' """ from Modeling import ModelSet ms=ModelSet.ModelSet() ms.addModelFromXML({'file': xmlFilePath}) model=ms.models()[0] model._modelSet=None return model def write_xml_model_in_python_module(xmlFilePath, modelName): """ Creates a python module (file: model_<modelName>.py) and dumps the content of the file 'xmlFilePath' in a string attribute named 'model_src' """ xml=open(xmlFilePath, 'r') file=open('model_%s.py'%modelName, 'w') file.write('model_src="""') s=xml.readline() while s!='': file.write(s) s=xml.readline() file.write('"""\n') xml.close() file.close() def write_pickled_model(model): """ Creates a python module (file: model_<modelName>_pickle.py) and dumps a pickled version of the supplied model in module's attribute 'model_pickle'. """ import cPickle file=open('model_%s_pickle.py'%model.name(), 'w') file.write('model_pickle=r"""') pickled=cPickle.dump(model, file) file.write('"""\n') file.close() def usage(prgName, exitStatus=None): print """%s <model.xml> ``Compile'' an xml_model into two python modules, model_<modelName>.py and model_<modelName>_pickled.py. - model_<model_name>.py: contains the whole xml-file in a single module attribute: model_src - model_<modelName>_pickled.py: the second one contains a single attribute as well: model_pickle, which is a raw string to be loaded by cPickle.loads() Options ------- -h Prints this message """ % prgName if exitStatus is not None: sys.exit(exitStatus) def main(argv): me=argv[0] try: options, args = getopt.getopt(sys.argv[1:], 'h') except getopt.GetoptError,msg: print me, msg usage(me, 1) verbose=0 for k, v in options: if k=='-h': usage(me, 0) if len(args)!=1: usage(me,1) model=loadModel(args[0]) write_xml_model_in_python_module(args[0], model.name()) write_pickled_model(model) if __name__ == "__main__": main(sys.argv) |
From: <sbi...@us...> - 2003-04-22 17:05:30
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/AbstractDBAPI2AdaptorLayer In directory sc8-pr-cvs1:/tmp/cvs-serv31031/DatabaseAdaptors/AbstractDBAPI2AdaptorLayer Modified Files: AbstractDBAPI2Adaptor.py Log Message: Fixed AbstractDBAPI2Adaptor.create/dropDatabaseWithAdmin.Conn.Dict.(): under some circumstances it was possible that createDB() fails when called just after the drop, fails (see comments in the code for details) Index: AbstractDBAPI2Adaptor.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/AbstractDBAPI2AdaptorLayer/AbstractDBAPI2Adaptor.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractDBAPI2Adaptor.py 10 Jan 2003 10:45:45 -0000 1.1 --- AbstractDBAPI2Adaptor.py 22 Apr 2003 17:05:26 -0000 1.2 *************** *** 132,137 **** cur.execute(sqlExpr.statement()) finally: cnx.close() ! def defaultExpressionClass(self): "See Modeling.interfaces.Adaptor for details" --- 132,153 ---- cur.execute(sqlExpr.statement()) finally: + # Note: it can be that, when drop/createDBWithAdminConnDict() are called + # just one after the other (such as in mdl_generate_DB_schema.py) + # it is not sufficient to close the cnx, or, e.g. postgresql + # raises the following error: + # ERROR: CREATE DATABASE: source database "template1" is being + # accessed by other users + # (this happens particularly often when creating the DB after dropping + # the database initially failed --because the database does not exist + # yet, e.g.) + # Since I remember having seen possibly-related strange things on + # drop/createDB w/ mysql I've changed the code here: explicit closing + # followed by explicit destruction. As far as I can tell it solves the + # problem, I suspect a delayed destruction of the cnx in dropDB() + # causing the connection to persist when createDB begins. + cur.rollback() ; cur.close() cnx.close() ! del cur, cnx ! def defaultExpressionClass(self): "See Modeling.interfaces.Adaptor for details" *************** *** 152,156 **** --- 168,176 ---- cur.execute(sqlExpr.statement()) finally: + # See comments in createDatabaseWithAdministrativeConnectionDictionary() + # --> explicit closing and destruction of cnx and cur are intended here + cur.rollback() ; cur.close() cnx.close() + del cur; del cnx def expressionFactory(self): |
From: <sbi...@us...> - 2003-04-22 17:05:29
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv31031 Modified Files: CHANGES Log Message: Fixed AbstractDBAPI2Adaptor.create/dropDatabaseWithAdmin.Conn.Dict.(): under some circumstances it was possible that createDB() fails when called just after the drop, fails (see comments in the code for details) Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** CHANGES 22 Apr 2003 09:31:57 -0000 1.96 --- CHANGES 22 Apr 2003 17:05:25 -0000 1.97 *************** *** 3,10 **** Module Modeling --------------- ! Current release is: 0.9-pre-5 / See also: TODO, INSTALL and doc/ * ** Distributed under the GNU General Public License ** -------------------------------------------------------- * Added a field 'comment' for Model, Entity, Attribute & Relationship, after --- 3,17 ---- Module Modeling --------------- ! Current release is: 0.9-pre-6 / See also: TODO, INSTALL and doc/ * ** Distributed under the GNU General Public License ** -------------------------------------------------------- + + * Fixed AbstractDBAPI2Adaptor.create/dropDatabaseWithAdmin.Conn.Dict.(): + under some circumstances it was possible that createDB() fails when called + just after the drop, fails (see comments in the code for details) + + * Fixed mdl_generate_DB_schema: some options ('-t -p -s -f -F) were silently + ignored * Added a field 'comment' for Model, Entity, Attribute & Relationship, after |
From: <sbi...@us...> - 2003-04-22 12:11:13
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv26189/scripts Modified Files: mdl_generate_DB_schema.py Log Message: Fixed: some options were not taken into account (-t, -p, -s, -f and -F) Index: mdl_generate_DB_schema.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/scripts/mdl_generate_DB_schema.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mdl_generate_DB_schema.py 4 Feb 2003 08:38:10 -0000 1.2 --- mdl_generate_DB_schema.py 22 Apr 2003 12:11:08 -0000 1.3 *************** *** 223,230 **** _create_options_to_key={ '-T': CreateTablesKey, '-P': PrimaryKeyConstraintsKey, ! '-S': CreatePrimaryKeySupportKey, 'F': ForeignKeyConstraintsKey } _drop_options_to_key={ '-t': DropTablesKey, '-p': DropPrimaryKeyConstraintsKey, ! '-s': DropPrimaryKeySupportKey, 'F': DropForeignKeyConstraintsKey } def main(args): --- 223,230 ---- _create_options_to_key={ '-T': CreateTablesKey, '-P': PrimaryKeyConstraintsKey, ! '-S': CreatePrimaryKeySupportKey, '-F': ForeignKeyConstraintsKey } _drop_options_to_key={ '-t': DropTablesKey, '-p': DropPrimaryKeyConstraintsKey, ! '-s': DropPrimaryKeySupportKey, '-f': DropForeignKeyConstraintsKey } def main(args): *************** *** 267,271 **** if k in _drop_options_to_key.keys(): ! generation_options[_drop_options_to_key[k]]=0; continue if k == '-D': --- 267,271 ---- if k in _drop_options_to_key.keys(): ! generation_options[_drop_options_to_key[k]]=1; continue if k == '-D': |
From: <sbi...@us...> - 2003-04-22 11:08:04
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv711/scripts Modified Files: mdl_validate_model.py Log Message: added '-Q' + suppressed logging of warning message when '-w' is supplied Index: mdl_validate_model.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/scripts/mdl_validate_model.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mdl_validate_model.py 14 Mar 2003 14:35:17 -0000 1.2 --- mdl_validate_model.py 22 Apr 2003 11:08:00 -0000 1.3 *************** *** 59,64 **** Return status: ! 0 if the model is valide, ! 1 if the model has errors 2 if some warnings were issued (except with --ignore-warnings) 3 in case the model cannot be loaded --- 59,64 ---- Return status: ! 0 if the model is valid, ! 1 if the model has errors (no matter whether there are warnings) 2 if some warnings were issued (except with --ignore-warnings) 3 in case the model cannot be loaded *************** *** 66,73 **** Options: -------- ! ! -q --quiet quiet mode ! -w --ignore-warnings ignore warnings -h --help gives this help """ % prgName sys.stderr.write(_usage) --- 66,76 ---- Options: -------- ! Default is to print informational, warning and error messages ! ! -q --quiet ignore info, only prints warnings and errors ! -w --ignore-warnings only print errors (see also: Return status above) ! -Q really quiet: do not print anything -h --help gives this help + -v --verbose prints extra info. on the runtime steps """ % prgName sys.stderr.write(_usage) *************** *** 86,90 **** me=args[0] try: options, args = getopt.getopt(sys.argv[1:], ! 'hqvw', ["help", "quiet", "verbose", "ignore-warnings",]) --- 89,93 ---- me=args[0] try: options, args = getopt.getopt(sys.argv[1:], ! 'hQqvw', ["help", "quiet", "verbose", "ignore-warnings",]) *************** *** 95,101 **** for k, v in options: if k in ('-h', '--help'): usage(me); return 0 ! if k in ('-q', '--quiet'): quiet_mode=1; continue if k in ('-v', '--verbose'): verbose=1; continue ! if k in ('-i', '--ignore_warnings'): ignore_warnings=1; continue if len(args)!=1: usage(me) ; return 1 --- 98,111 ---- for k, v in options: if k in ('-h', '--help'): usage(me); return 0 ! if k in ('-Q', ): quiet_mode=1; verbose=0; continue ! if k in ('-q', '--quiet'): ! ignore_levels.append(INFO) ! continue if k in ('-v', '--verbose'): verbose=1; continue ! if k in ('-w', '--ignore_warnings'): ! ignore_levels.append(INFO) ! ignore_levels.append(WARNING) ! ignore_warnings=1 ! continue if len(args)!=1: usage(me) ; return 1 *************** *** 103,106 **** --- 113,117 ---- model_file=args[0] # load the model + if verbose: log("Loading the model...") ms=ModelSet() try: *************** *** 112,116 **** log(tracebackInfoFromStack(exc)) return 3 ! if verbose: log("Loading the model...") errors=validate_model(ms.models()[0], ignore_levels) if verbose: log("Done.") --- 123,128 ---- log(tracebackInfoFromStack(exc)) return 3 ! if verbose: log("Done.") ! if verbose: log("Validating...") errors=validate_model(ms.models()[0], ignore_levels) if verbose: log("Done.") |
From: <sbi...@us...> - 2003-04-22 09:36:54
|
Update of /cvsroot/modeling/ZModeling/ZEditingContextSessioning In directory sc8-pr-cvs1:/tmp/cvs-serv28737/ZEditingContextSessioning Modified Files: __init__.py Log Message: Added licence Index: __init__.py =================================================================== RCS file: /cvsroot/modeling/ZModeling/ZEditingContextSessioning/__init__.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** __init__.py 9 Mar 2003 20:55:04 -0000 1.2 --- __init__.py 22 Apr 2003 09:36:50 -0000 1.3 *************** *** 1,3 **** ! ## Licence """ --- 1,25 ---- ! #----------------------------------------------------------------------------- ! # ! # Modeling Framework: an Object-Relational Bridge for python ! # (c) 2001, 2002, 2003 Sebastien Bigaret ! # ! # This file is part of the Modeling Framework. ! # ! # The Modeling Framework is free software; you can redistribute it and/or ! # modify it under the terms of the GNU General Public License as published ! # by the Free Software Foundation; either version 2 of the License, or (at ! # your option) any later version. ! # ! # The Modeling Framework is distributed in the hope that it will be ! # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of ! # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! # General Public License for more details. ! # ! # You should have received a copy of the GNU General Public License along ! # with the Modeling Framework; if not, write to the Free Software ! # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! # ! #----------------------------------------------------------------------------- ! """ |
From: <sbi...@us...> - 2003-04-22 09:35:49
|
Update of /cvsroot/modeling/ZModeling/ZModelizationTool In directory sc8-pr-cvs1:/tmp/cvs-serv28055/ZModelizationTool Modified Files: ZModelizationTool.py Log Message: Updated ZModelizationTool: a field 'comment' was added for Model, Entity, Attribute & Relationship Index: ZModelizationTool.py =================================================================== RCS file: /cvsroot/modeling/ZModeling/ZModelizationTool/ZModelizationTool.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ZModelizationTool.py 14 Mar 2003 11:42:57 -0000 1.11 --- ZModelizationTool.py 22 Apr 2003 09:35:16 -0000 1.12 *************** *** 166,170 **** def setModelProperties(self, modelName, name, packageName, ! adaptorName='', connectionDictionary='', REQUEST=None): "..." --- 166,170 ---- def setModelProperties(self, modelName, name, packageName, ! adaptorName='', comment='', connectionDictionary='', REQUEST=None): "..." *************** *** 173,176 **** --- 173,177 ---- model.setPackageName(packageName) model.setAdaptorName(adaptorName) + model.setComment(comment) model.setConnectionDictionary(connectionDictionary) self._p_changed=1 *************** *** 451,457 **** manage_entityProperties=DTMLFile('entity_properties', _dtmldir) ! def manage_setEntityProperties(self, entityName, name, typeName, isAbstract=0, isReadOnly=0, ! moduleName='', className='', externalName=None, parentEntityName='', --- 452,458 ---- manage_entityProperties=DTMLFile('entity_properties', _dtmldir) ! def manage_setEntityProperties(self, entityName, name, typeName, isAbstract=0, isReadOnly=0, ! comment='', moduleName='', className='', externalName=None, parentEntityName='', *************** *** 471,474 **** --- 472,476 ---- parent.addSubEntity(_entity) _entity.setTypeName(typeName) + _entity.setComment(comment) _entity.setClassName(className) _entity.setModuleName(moduleName) *************** *** 587,591 **** name, displayLabel, typeName, defaultValue, isClassProperty=0, isRequired=0, ! columnName='', externalType='', precision=0, scale=0, width=0, REQUEST=None): --- 589,593 ---- name, displayLabel, typeName, defaultValue, isClassProperty=0, isRequired=0, ! comment='', columnName='', externalType='', precision=0, scale=0, width=0, REQUEST=None): *************** *** 594,598 **** _attribute=_entity.attributeNamed(attributeName) _attribute.setName(name) ! # DB related fields _attribute.setColumnName(columnName) _attribute.setExternalType(externalType) --- 596,601 ---- _attribute=_entity.attributeNamed(attributeName) _attribute.setName(name) ! _attribute.setComment(comment) ! # DB related field _attribute.setColumnName(columnName) _attribute.setExternalType(externalType) *************** *** 626,630 **** name, displayLabel, isClassProperty=0, ! definition='', REQUEST=None): "Changes the attribute's properties" --- 629,633 ---- name, displayLabel, isClassProperty=0, ! comment='', definition='', REQUEST=None): "Changes the attribute's properties" *************** *** 632,635 **** --- 635,639 ---- _attribute=_entity.attributeNamed(attributeName) _attribute.setName(name) + _attribute.setComment(comment) _attribute.setDefinition(definition) _attribute.setDisplayLabel(displayLabel) *************** *** 663,666 **** --- 667,671 ---- destinationAttribute, multLower, multUpper, deleteRule, + comment='', isClassProperty=0, REQUEST=None): "Changes the ``normal'' [i.e. non flattened] relationship's properties" *************** *** 668,671 **** --- 673,677 ---- _relationship=_entity.relationshipNamed(relationshipName) _relationship.setName(name) + _relationship.setComment(comment) if sourceAttribute!='Unset' and destinationAttribute!='Unset': # We just support single joins for now *************** *** 692,695 **** --- 698,702 ---- definition, multLower, multUpper, deleteRule, + comment='', isClassProperty=0, REQUEST=None): "Changes the flattened relationship's properties" *************** *** 697,700 **** --- 704,708 ---- _relationship=_entity.relationshipNamed(relationshipName) _relationship.setName(name) + _relationship.setComment(comment) _relationship.setDefinition(definition) _relationship.setDisplayLabel(displayLabel) |
From: <sbi...@us...> - 2003-04-22 09:35:49
|
Update of /cvsroot/modeling/ZModeling In directory sc8-pr-cvs1:/tmp/cvs-serv28055 Modified Files: CHANGES Log Message: Updated ZModelizationTool: a field 'comment' was added for Model, Entity, Attribute & Relationship Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ZModeling/CHANGES,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** CHANGES 14 Mar 2003 09:45:03 -0000 1.15 --- CHANGES 22 Apr 2003 09:35:16 -0000 1.16 *************** *** 1,5 **** -*- text -*- ! Current release is: 0.9-pre-4 0.9-pre-4 Second release candidate for 0.9 --- 1,8 ---- -*- text -*- ! Current release is: 0.9-pre-6 ! ! * Updated ZModelizationTool: a field 'comment' was added for Model, Entity, ! Attribute & Relationship 0.9-pre-4 Second release candidate for 0.9 |
From: <sbi...@us...> - 2003-04-22 09:35:32
|
Update of /cvsroot/modeling/ZModeling/ZModelizationTool/dtml In directory sc8-pr-cvs1:/tmp/cvs-serv28055/ZModelizationTool/dtml Modified Files: attribute_properties.dtml entity_properties.dtml flattenedRelationship_properties.dtml flattened_attribute_properties.dtml model_properties.dtml simpleRelationship_properties.dtml Log Message: Updated ZModelizationTool: a field 'comment' was added for Model, Entity, Attribute & Relationship Index: attribute_properties.dtml =================================================================== RCS file: /cvsroot/modeling/ZModeling/ZModelizationTool/dtml/attribute_properties.dtml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** attribute_properties.dtml 11 Sep 2002 13:01:12 -0000 1.2 --- attribute_properties.dtml 22 Apr 2003 09:35:17 -0000 1.3 *************** *** 26,29 **** --- 26,35 ---- </tr> <tr> + <th align="left">Comment</th> + <td colspan=2> + <textarea name="comment" cols="40" rows="3"><dtml-var comment></textarea> + </td> + </tr> + <tr> <th colspan=3>Database related params.</th> </tr> Index: entity_properties.dtml =================================================================== RCS file: /cvsroot/modeling/ZModeling/ZModelizationTool/dtml/entity_properties.dtml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** entity_properties.dtml 11 Sep 2002 13:28:23 -0000 1.4 --- entity_properties.dtml 22 Apr 2003 09:35:19 -0000 1.5 *************** *** 21,25 **** </tr> <tr> ! <td><input type="text" size=15 name="name" value="&dtml-name;"></font></td> <td><input type="text" size=15 name="moduleName" value="&dtml-moduleName;"></td> <td><input type="text" size=15 name="className" value="&dtml-className;"></td> --- 21,25 ---- </tr> <tr> ! <td><input type="text" size=15 name="name" value="&dtml-name;"></td> <td><input type="text" size=15 name="moduleName" value="&dtml-moduleName;"></td> <td><input type="text" size=15 name="className" value="&dtml-className;"></td> *************** *** 63,66 **** --- 63,71 ---- <input type="checkbox" name="isReadOnly" value="1"> </dtml-if> + </td> + </tr> + <tr> + <th align="left">comment</th> + <td colspan=6><textarea name="comment" cols="40" rows="3"><dtml-var comment></textarea> </td> </tr> Index: flattenedRelationship_properties.dtml =================================================================== RCS file: /cvsroot/modeling/ZModeling/ZModelizationTool/dtml/flattenedRelationship_properties.dtml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** flattenedRelationship_properties.dtml 30 Jul 2002 15:35:03 -0000 1.1.1.1 --- flattenedRelationship_properties.dtml 22 Apr 2003 09:35:22 -0000 1.2 *************** *** 23,26 **** --- 23,32 ---- </tr> <tr> + <th valign="top">Comment</th> + <td> + <textarea name="comment" cols="40" rows="3"><dtml-var comment></textarea> + </td> + </tr> + <tr> <th>Display Label</th> <td><input type="text" name="displayLabel:string" value="&dtml-displayLabel;"></td> Index: flattened_attribute_properties.dtml =================================================================== RCS file: /cvsroot/modeling/ZModeling/ZModelizationTool/dtml/flattened_attribute_properties.dtml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** flattened_attribute_properties.dtml 30 Jul 2002 15:35:03 -0000 1.1.1.1 --- flattened_attribute_properties.dtml 22 Apr 2003 09:35:22 -0000 1.2 *************** *** 42,46 **** </td> </tr> ! <tr> <td colspan=3 align=center><input type="submit" name="manage_setFlattenedAttributeProperties:method" value=" Change " /> --- 42,51 ---- </td> </tr> ! <tr> ! <th>comment</th> ! <td valign=top colspan=2> ! <textarea name="comment" cols="40" rows="3"><dtml-var comment></textarea> ! </td> ! </tr> <tr> <td colspan=3 align=center><input type="submit" name="manage_setFlattenedAttributeProperties:method" value=" Change " /> Index: model_properties.dtml =================================================================== RCS file: /cvsroot/modeling/ZModeling/ZModelizationTool/dtml/model_properties.dtml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** model_properties.dtml 21 Feb 2003 12:34:46 -0000 1.7 --- model_properties.dtml 22 Apr 2003 09:35:23 -0000 1.8 *************** *** 38,41 **** --- 38,45 ---- Template-dict.: <code>{'database': '', 'user': '', 'password': '', 'host': ''}</code></font></td></tr> </tr> + <tr> + <th align="left">comment</th> + <td colspan=2><textarea name="comment" cols="40" rows="3"><dtml-var comment></textarea></td> + </tr> </table> <input type="submit" name="submit" value="Save changes" /> Index: simpleRelationship_properties.dtml =================================================================== RCS file: /cvsroot/modeling/ZModeling/ZModelizationTool/dtml/simpleRelationship_properties.dtml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** simpleRelationship_properties.dtml 11 Sep 2002 13:01:14 -0000 1.2 --- simpleRelationship_properties.dtml 22 Apr 2003 09:35:23 -0000 1.3 *************** *** 24,27 **** --- 24,33 ---- </tr> <tr> + <th valign="top">Comment</th> + <td> + <textarea name="comment" cols="40" rows="3"><dtml-var comment></textarea> + </td> + </tr> + <tr> <th>Display Label</th> <td><input type="text" name="displayLabel:string" value="&dtml-displayLabel;"></td> |
From: <sbi...@us...> - 2003-04-22 09:32:03
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv26584 Modified Files: Model.py Entity.py Attribute.py Relationship.py CHANGES Log Message: Added a field 'comment' for Model, Entity, Attribute & Relationship, after a suggestion by Yannick Gingras Index: Model.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Model.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Model.py 10 Jan 2003 10:45:44 -0000 1.3 --- Model.py 22 Apr 2003 09:31:56 -0000 1.4 *************** *** 55,59 **** _connectionDictionary={} _packageName='' ! def __init__(self, aName=''): "Initializes a model. A name **must** be provided." --- 55,60 ---- _connectionDictionary={} _packageName='' ! _comment='' ! def __init__(self, aName=''): "Initializes a model. A name **must** be provided." *************** *** 95,98 **** --- 96,103 ---- anEntity._setModel(self) + def comment(self): + "Returns the comment field" + return self._comment + def connectionDictionary(self): "Returns the connection dictionary" *************** *** 191,194 **** --- 196,203 ---- self._adaptorName=adaptorName + def setComment(self, aComment): + "Sets the comment field" + self._comment=aComment + def setConnectionDictionary(self, aConnectionDictionary): "Sets the connection dictionary" *************** *** 315,320 **** 'connectionDictionary': ('string', self.setConnectionDictionary, ! self.connectionDictionary) ! } --- 324,331 ---- 'connectionDictionary': ('string', self.setConnectionDictionary, ! self.connectionDictionary), ! 'comment': ('string', ! self.setComment, ! self.comment), } Index: Entity.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Entity.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Entity.py 17 Mar 2003 10:27:09 -0000 1.10 --- Entity.py 22 Apr 2003 09:31:56 -0000 1.11 *************** *** 145,148 **** --- 145,149 ---- _attrsUsedForLocking=() _moduleName=None + _comment='' def __init__(self, name='', aModel=None): *************** *** 158,161 **** --- 159,163 ---- self._attrsUsedForLocking=() self._className=None + self._comment='' self._externalName='' self._model=None *************** *** 358,361 **** --- 360,367 ---- if rel.isClassProperty()]) + def comment(self): + "Returns the comment field" + return self._comment + def definedKeys(self): """ *************** *** 838,841 **** --- 844,851 ---- self._className=aName + def setComment(self, aComment): + "Sets the comment field" + self._comment=aComment + def setExternalName(self, externalName): "Sets the external name" *************** *** 1378,1381 **** --- 1388,1394 ---- self.setClassName, self.className ), + 'comment': ( 'string', + self.setComment, + self.comment), 'externalName': ( 'string', self.setExternalName, Index: Attribute.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Attribute.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Attribute.py 17 Mar 2003 11:15:11 -0000 1.11 --- Attribute.py 22 Apr 2003 09:31:56 -0000 1.12 *************** *** 100,103 **** --- 100,104 ---- _columnName='' _width=0 + _comment='' def __init__(self, aName='', anEntity=None): *************** *** 111,114 **** --- 112,116 ---- self._allowsNone=1 self._columnName='' + self._comment='' self._defaultValue=None self._definition='' *************** *** 165,168 **** --- 167,174 ---- return self._columnName + def comment(self): + "Returns the comment field" + return self._comment + def defaultValue(self): "Returns the default value associated to this attribute" *************** *** 323,326 **** --- 329,336 ---- self._columnName=columnName + def setComment(self, aComment): + "Sets the comment field" + self._comment=aComment + def convertStringToAttributeType(self, aValue): """ *************** *** 595,598 **** --- 605,611 ---- self.setColumnName, self.columnName), + 'comment' : ( 'string', + self.setComment, + self.comment), 'displayLabel' : ('string', self.setDisplayLabel, *************** *** 638,642 **** subList=('name', 'columnName', 'precision', 'scale', 'width', 'externalType', #DB ! 'displayLabel', 'isClassProperty', 'isRequired', 'defaultValue', 'type', ) dict=self.fullPropertySet() --- 651,655 ---- subList=('name', 'columnName', 'precision', 'scale', 'width', 'externalType', #DB ! 'comment', 'displayLabel', 'isClassProperty', 'isRequired', 'defaultValue', 'type', ) dict=self.fullPropertySet() *************** *** 647,651 **** def flattenedPropertySet(self): subList=('name', 'displayLabel', 'isClassProperty', 'definition', ! 'isFlattened', ) dict=self.fullPropertySet() deleteKeys=filter(lambda k, list=subList: k not in list, dict.keys()) --- 660,664 ---- def flattenedPropertySet(self): subList=('name', 'displayLabel', 'isClassProperty', 'definition', ! 'isFlattened', 'comment') dict=self.fullPropertySet() deleteKeys=filter(lambda k, list=subList: k not in list, dict.keys()) Index: Relationship.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Relationship.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Relationship.py 10 Feb 2003 12:12:15 -0000 1.7 --- Relationship.py 22 Apr 2003 09:31:56 -0000 1.8 *************** *** 69,72 **** --- 69,73 ---- # _isClassProperty=1 + _comment='' __implements__=(RelationshipInterface, XMLCapabilityInterface) *************** *** 76,79 **** --- 77,81 ---- self._deleteRule = DELETE_NULLIFY self._displayLabel = '' + self._comment = '' self._entity = None self._isClassProperty = 1 *************** *** 83,86 **** --- 85,92 ---- return + def comment(self): + "Returns the comment field" + return self._comment + def entity(self): "Return the relationship's source entity" *************** *** 146,149 **** --- 152,159 ---- return self._name + def setComment(self, aComment): + "Sets the comment field" + self._comment=aComment + def setDeleteRule(self, rule): """ *************** *** 280,283 **** --- 290,296 ---- "-" return { + 'comment' : ('string', + self.setComment, + self.comment), 'name' : ('string', lambda self=None,p=None: None, Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** CHANGES 21 Apr 2003 22:25:56 -0000 1.95 --- CHANGES 22 Apr 2003 09:31:57 -0000 1.96 *************** *** 8,11 **** --- 8,14 ---- -------------------------------------------------------- + * Added a field 'comment' for Model, Entity, Attribute & Relationship, after + a suggestion by Yannick Gingras + 0.9-pre-6 (2003/04/22) Project milestone -- no public release --------- Preparing 0.9 - ETA: 2003/04/28 |
Update of /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks In directory sc8-pr-cvs1:/tmp/cvs-serv6229a/ModelMasons/Python_bricks Modified Files: Tag: brch-0_9pre6-1-ModelMasons_base_generation_scheme base_module.tmpl init.tmpl module_base.tmpl Added Files: Tag: brch-0_9pre6-1-ModelMasons_base_generation_scheme init_base.tmpl Log Message: Added the 'MDL' sub-directory containing the files that are overwritten when mdl_generate_python_code.py (option: -B) regenerates a package First proposal. TODO: check the constraint for option -B: a package cannot be generated from a model where a class and at least one of its (direct or indirect) subclasses leave in the same module. --- NEW FILE: init_base.tmpl --- ## This template will build the __init__.py file in the 'base_dir' package ## (see ModelMasons.PyModelMason) #for entities in $entitiesSet: import $(entities[0].moduleName()) #end for Index: base_module.tmpl =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks/base_module.tmpl,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** base_module.tmpl 20 Apr 2003 16:10:40 -0000 1.1 --- base_module.tmpl 21 Apr 2003 22:53:05 -0000 1.1.2.1 *************** *** 1,12 **** ## This template will build the <module>Base.py module ! # Modeling ! #set $custom = 1 #for entity in $entities: #if $entity.parentEntity() and $entity.parentEntity() not in $entities: ! from $entity.parentEntity().moduleName() import $entity.parentEntity().className() #elif $custom: from Modeling.CustomObject import CustomObject #set $custom=0 #end if #end for from Modeling.Validation import ValidationException --- 1,18 ---- ## This template will build the <module>Base.py module ! # DO NOT MODIFY THIS FILE -- IT WILL BE OVERWRITTEN ! # Instead, modify $(model.packageName).$(entities[0].moduleName()) ! #set $custom=1 ! #set $imported=[] #for entity in $entities: + #if $entity.parentEntity() not in imported: #if $entity.parentEntity() and $entity.parentEntity() not in $entities: ! import $entity.parentEntity().className() # make sure we import in correct order ! from $(model.packageName()).$entity.parentEntity().moduleName() import $entity.parentEntity().className() ! $imported.append($entity.parentEntity())#slurp #elif $custom: from Modeling.CustomObject import CustomObject #set $custom=0 #end if + #end if #end for from Modeling.Validation import ValidationException *************** *** 22,28 **** $entity_props.sort(lambda x,y: cmp(x.name(), y.name())) #if $entity.parentEntity(): ! class $(class_name)Base($(entity.parentEntity().className())): #else ! class $(class_name)Base(CustomObject): #end if """ --- 28,34 ---- $entity_props.sort(lambda x,y: cmp(x.name(), y.name())) #if $entity.parentEntity(): ! class $(class_name)($(entity.parentEntity().className())): #else ! class $(class_name)(CustomObject): #end if """ *************** *** 84,92 **** self._$attr.name = $attr.name #end if - def validate$utils.capitalizeFirstLetter(attr.name())(self, value): - "Edit this to enforce custom business logic" - if 0: # your custom bizlogic - raise ValidationException - return #end if ##* isClassProperty *# #slurp #end for ##* Attributes *# #slurp --- 90,93 ---- Index: init.tmpl =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks/init.tmpl,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** init.tmpl 7 Aug 2002 22:18:48 -0000 1.3 --- init.tmpl 21 Apr 2003 22:53:05 -0000 1.3.4.1 *************** *** 5,9 **** --- 5,14 ---- from Modeling import ModelSet import os, warnings, StringIO, traceback + #if $base_dir: + from $(base_dir).model_$(model_name) import model_src + #else from model_$(model_name) import model_src + #end if + try: if ModelSet.defaultModelSet().modelNamed("$(model_name)") is None: Index: module_base.tmpl =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks/module_base.tmpl,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** module_base.tmpl 20 Apr 2003 16:10:40 -0000 1.1 --- module_base.tmpl 21 Apr 2003 22:53:05 -0000 1.1.2.1 *************** *** 1,6 **** ## This template will build the module ! #for entity in $entities: ! from $(entity.className())Base import $(entity.className())Base ! #end for from Modeling.Validation import ValidationException from mx.DateTime import DateTimeFrom --- 1,4 ---- ## This template will build the module ! import $(base_dir) from Modeling.Validation import ValidationException from mx.DateTime import DateTimeFrom *************** *** 8,16 **** #for entity in $entities: ! #set $class_name = str($entity.className) #if $entity.parentEntity(): ! class $(class_name)($(class_name)Base): #derive from $(entity.parentEntity().className()) #else ! class $(class_name)($(class_name)Base): #end if """ --- 6,17 ---- #for entity in $entities: ! #set $class_name = $entity.className() ! #set $module_name = $entity.moduleName() ! #set $entity_props=list($entity.newOrOverriddenPythonProperties()) ! $entity_props.sort(lambda x,y: cmp(x.name(), y.name())) #if $entity.parentEntity(): ! class $(class_name)($(base_dir).$(module_name).$(class_name)): #derive from $(entity.parentEntity().className()) #else ! class $(class_name)($(base_dir).$(module_name).$(class_name)): #end if """ *************** *** 23,27 **** # every parameter gets a default value, since the framework needs to be # able to instanciate an object with no parameter at all. ! $(class_name)Base.__init__(self) #end for --- 24,38 ---- # every parameter gets a default value, since the framework needs to be # able to instanciate an object with no parameter at all. ! $(base_dir).$(module_name).$(class_name).__init__(self) ! ! #for attr in $entity_props: ! #if $attr.isClassProperty() and not $attr in $entity.primaryKeyAttributes(): ! def validate$utils.capitalizeFirstLetter(attr.name())(self, value): ! "Edit this to enforce custom business logic" ! if 0: # your custom bizlogic ! raise ValidationException ! return ! #end if ##* isClassProperty *# ! #end for ##* Attributes *# #slurp #end for |
From: <sbi...@us...> - 2003-04-21 22:53:09
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv6229a Modified Files: Tag: brch-0_9pre6-1-ModelMasons_base_generation_scheme CHANGES Log Message: Added the 'MDL' sub-directory containing the files that are overwritten when mdl_generate_python_code.py (option: -B) regenerates a package First proposal. TODO: check the constraint for option -B: a package cannot be generated from a model where a class and at least one of its (direct or indirect) subclasses leave in the same module. Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v retrieving revision 1.95 retrieving revision 1.95.2.1 diff -C2 -d -r1.95 -r1.95.2.1 *** CHANGES 21 Apr 2003 22:25:56 -0000 1.95 --- CHANGES 21 Apr 2003 22:53:05 -0000 1.95.2.1 *************** *** 8,11 **** --- 8,22 ---- -------------------------------------------------------- + ModelMasons + + TODO: check the constraint for option -B: a package cannot be generated from + a model where a class and at least one of its (direct or indirect) + subclasses leave in the same module. + + * Added the 'MDL' sub-directory containing the files that are overwritten + when mdl_generate_python_code.py (option: -B) regenerates a package + + BRANCH: brch-0_9pre6-1-ModelMasons_base_generation_scheme begins here + 0.9-pre-6 (2003/04/22) Project milestone -- no public release --------- Preparing 0.9 - ETA: 2003/04/28 |
From: <sbi...@us...> - 2003-04-21 22:53:09
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons In directory sc8-pr-cvs1:/tmp/cvs-serv6229a/ModelMasons Modified Files: Tag: brch-0_9pre6-1-ModelMasons_base_generation_scheme PyModelMason.py Log Message: Added the 'MDL' sub-directory containing the files that are overwritten when mdl_generate_python_code.py (option: -B) regenerates a package First proposal. TODO: check the constraint for option -B: a package cannot be generated from a model where a class and at least one of its (direct or indirect) subclasses leave in the same module. Index: PyModelMason.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/PyModelMason.py,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -C2 -d -r1.8 -r1.8.2.1 *** PyModelMason.py 20 Apr 2003 16:10:39 -0000 1.8 --- PyModelMason.py 21 Apr 2003 22:53:05 -0000 1.8.2.1 *************** *** 40,44 **** from Cheetah.Template import Template ! from Python_bricks import init,model,base_module,module_base,module_compact,setup_tmpl class PyModelMason(ModelMason): --- 40,44 ---- from Cheetah.Template import Template ! from Python_bricks import init,init_base,model,base_module,module_base,module_compact,setup_tmpl class PyModelMason(ModelMason): *************** *** 68,71 **** --- 68,72 ---- self._entities=[] # used during build self.generation_scheme=generation_scheme + self.base_dir=generation_scheme=='base' and 'MDL' or '' def tmpl_namespace(self): *************** *** 77,80 **** --- 78,83 ---- 'model' : self.model, 'entities': self._entities, + 'base_dir': self.base_dir, + 'entitiesSet': self.entitiesSet, } return nameSpace *************** *** 83,86 **** --- 86,107 ---- def build(self): "-" + #----------------------------------------------------------------- + def create_model_files(self, xml_path, py_path): + # model_<modelName>.xml + self.log('Generating %s... '%xml_path) + self.model.saveModelAsXMLFile(xml_path) + self.log('done\n') + + # model_<modelName>.py + xml=open(xml_path) + modelStr=xml.read() + xml.close() + self.createFileFromTemplate(model.model(), + py_path, + namespace={'model_str':modelStr}, + overwrite=1) + del modelStr + #----------------------------------------------------------------- + # Build as many directories with __init__.py as needed self.build_package() *************** *** 93,113 **** self.createEmptyFile("DEPENDENCIES.txt",overwrite=0) - # model_<modelName>.xml - modelFileName='model_'+self.model.name()+'.xml' - modelFileName=self.fullPathForGeneratedFile(modelFileName) - self.log('Generating %s... '%modelFileName) - self.model.saveModelAsXMLFile(modelFileName) - self.log('done\n') - - # model_<modelName>.py - xml=open(modelFileName) - modelStr=xml.read() - xml.close() - self.createFileFromTemplate(model.model(), - "model_%s.py"%self.model.name(), - namespace={'model_str':modelStr}, - overwrite=1) - del modelStr - # package's __init__.py self.createFileFromTemplate(init.init(),"__init__.py",overwrite=0) --- 114,117 ---- *************** *** 117,120 **** --- 121,129 ---- # COMPACT generation scheme if self.generation_scheme=='compact': + # Create model files (.xml/.py) + xmlp=self.fullPathForGeneratedFile('model_'+self.model.name()+'.xml') + pyp="model_%s.py"%self.model.name() + create_model_files(self, xmlp, pyp) + # modules for self._entities in self.entitiesSet(): *************** *** 126,137 **** # BASE generation scheme elif self.generation_scheme=='base': ! # create 'Base' ! #basePath=self.fullPathForGeneratedFile('Base') ! #self.log("Creating directory %s... "%basePath) ! #try: ! # os.mkdir(basePath) ! #except: self.log('no\n') ! #else: self.log('ok\n') ! # modules for self._entities in self.entitiesSet(): --- 135,154 ---- # BASE generation scheme elif self.generation_scheme=='base': ! # create 'Base' and model files (.xml/.py) ! basePath=self.fullPathForGeneratedFile(self.base_dir) ! self.log("Creating directory %s... "%basePath) ! try: ! os.mkdir(basePath) ! except: self.log('no\n') ! else: self.log('ok\n') ! self.createFileFromTemplate(init_base.init_base(), ! os.path.join(self.base_dir,"__init__.py"), ! overwrite=0) ! ! create_model_files(self, ! os.path.join(basePath, ! 'model_'+self.model.name()+'.xml'), ! os.path.join(self.base_dir, ! "model_%s.py"%self.model.name())) # modules for self._entities in self.entitiesSet(): *************** *** 141,144 **** overwrite=0) self.createFileFromTemplate(base_module.base_module(), ! "%sBase.py" % module_name, overwrite=1) --- 158,162 ---- overwrite=0) self.createFileFromTemplate(base_module.base_module(), ! os.path.join(self.base_dir, ! "%s.py" % module_name), overwrite=1) |
From: <sbi...@us...> - 2003-04-21 22:26:06
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv28155/Modeling Modified Files: CHANGES Log Message: release-0_9pre6 Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -d -r1.94 -r1.95 *** CHANGES 20 Apr 2003 16:10:39 -0000 1.94 --- CHANGES 21 Apr 2003 22:25:56 -0000 1.95 *************** *** 8,11 **** --- 8,14 ---- -------------------------------------------------------- + 0.9-pre-6 (2003/04/22) Project milestone -- no public release + --------- Preparing 0.9 - ETA: 2003/04/28 + * ModelMasons: added a new generation scheme. The existing one is named 'compact', the new one, 'base'. The latter generates two different modules |
From: <sbi...@us...> - 2003-04-21 22:26:06
|
Update of /cvsroot/modeling/ProjectModeling In directory sc8-pr-cvs1:/tmp/cvs-serv28155 Modified Files: setup.py Log Message: release-0_9pre6 Index: setup.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/setup.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** setup.py 17 Mar 2003 11:53:49 -0000 1.21 --- setup.py 21 Apr 2003 22:25:55 -0000 1.22 *************** *** 46,50 **** setup(name="ModelingCore", ! version="0.9-pre-5", licence ="GNU General Public License", description=short_description, --- 46,50 ---- setup(name="ModelingCore", ! version="0.9-pre-6", licence ="GNU General Public License", description=short_description, |
From: <sbi...@us...> - 2003-04-20 16:11:13
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons In directory sc8-pr-cvs1:/tmp/cvs-serv30397/ModelMasons Modified Files: PyModelMason.py Log Message: ModelMasons: added a new generation scheme. The existing one is named 'compact', the new one, 'base'. The latter generates two different modules for a given entity, in modules <className> (which is not overwritten when re-generating) and <className>Base (which IS overwritten upon regeneration) Updated scripts/mdl_generate_python_code.py Index: PyModelMason.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/PyModelMason.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PyModelMason.py 20 Apr 2003 14:16:43 -0000 1.7 --- PyModelMason.py 20 Apr 2003 16:10:39 -0000 1.8 *************** *** 40,57 **** from Cheetah.Template import Template ! from Python_bricks import init, model, module, setup_tmpl class PyModelMason(ModelMason): ! def __init__(self, model, rootPath=None, verbose_mode=0): """ Initializes the ModelMason so that the built files are based on the supplied model. """ import Modeling ModelMason.__init__(self, model, rootPath, Modeling.ModelMasons.PyModelMason, 'Python_bricks', verbose_mode) self._entities=[] # used during build ! def tmpl_namespace(self): """ --- 40,72 ---- from Cheetah.Template import Template ! from Python_bricks import init,model,base_module,module_base,module_compact,setup_tmpl class PyModelMason(ModelMason): ! def __init__(self, model, rootPath=None, verbose_mode=0, ! generation_scheme='compact'): """ Initializes the ModelMason so that the built files are based on the supplied model. + + Parameters: + + model -- + + rootPath -- + + verbode_mode -- + + use_scheme -- 'compact' or 'base' + """ import Modeling + if generation_scheme not in ('compact', 'base'): + raise ValueError,"Parameter generation_scheme can be either 'compact' or 'base'" ModelMason.__init__(self, model, rootPath, Modeling.ModelMasons.PyModelMason, 'Python_bricks', verbose_mode) self._entities=[] # used during build ! self.generation_scheme=generation_scheme ! def tmpl_namespace(self): """ *************** *** 100,106 **** self.createFileFromTemplate(setup_tmpl.setup_tmpl(),"setup.py") ! # modules ! for self._entities in self.entitiesSet(): ! module_name = self._entities[0].moduleName() ! self.createFileFromTemplate(module.module(),"%s.py" % module_name) --- 115,144 ---- self.createFileFromTemplate(setup_tmpl.setup_tmpl(),"setup.py") ! # COMPACT generation scheme ! if self.generation_scheme=='compact': ! # modules ! for self._entities in self.entitiesSet(): ! module_name = self._entities[0].moduleName() ! self.createFileFromTemplate(module_compact.module_compact(), ! "%s.py" % module_name, ! overwrite=0) + # BASE generation scheme + elif self.generation_scheme=='base': + # create 'Base' + #basePath=self.fullPathForGeneratedFile('Base') + #self.log("Creating directory %s... "%basePath) + #try: + # os.mkdir(basePath) + #except: self.log('no\n') + #else: self.log('ok\n') + + # modules + for self._entities in self.entitiesSet(): + module_name = self._entities[0].moduleName() + self.createFileFromTemplate(module_base.module_base(), + "%s.py" % module_name, + overwrite=0) + self.createFileFromTemplate(base_module.base_module(), + "%sBase.py" % module_name, + overwrite=1) |
From: <sbi...@us...> - 2003-04-20 16:11:12
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv30397 Modified Files: CHANGES Log Message: ModelMasons: added a new generation scheme. The existing one is named 'compact', the new one, 'base'. The latter generates two different modules for a given entity, in modules <className> (which is not overwritten when re-generating) and <className>Base (which IS overwritten upon regeneration) Updated scripts/mdl_generate_python_code.py Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v retrieving revision 1.93 retrieving revision 1.94 diff -C2 -d -r1.93 -r1.94 *** CHANGES 20 Apr 2003 14:35:44 -0000 1.93 --- CHANGES 20 Apr 2003 16:10:39 -0000 1.94 *************** *** 8,11 **** --- 8,17 ---- -------------------------------------------------------- + * ModelMasons: added a new generation scheme. The existing one is named + 'compact', the new one, 'base'. The latter generates two different modules + for a given entity, in modules <className> (which is not overwritten when + re-generating) and <className>Base (which IS overwritten upon + regeneration) + * Refactored ModelMasons: ModelMason and PyModelMason are now clearer than they used to be. See PyModelMason for an example of use. |
From: <sbi...@us...> - 2003-04-20 16:10:45
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv30397/scripts Modified Files: mdl_generate_python_code.py Log Message: ModelMasons: added a new generation scheme. The existing one is named 'compact', the new one, 'base'. The latter generates two different modules for a given entity, in modules <className> (which is not overwritten when re-generating) and <className>Base (which IS overwritten upon regeneration) Updated scripts/mdl_generate_python_code.py Index: mdl_generate_python_code.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/scripts/mdl_generate_python_code.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** mdl_generate_python_code.py 20 Apr 2003 14:16:41 -0000 1.3 --- mdl_generate_python_code.py 20 Apr 2003 16:10:41 -0000 1.4 *************** *** 55,60 **** del tb ! def build_python_code(model, rootPath=None, typeOfCode='python', ! verbose_mode=0): """ Builds the python-code templates for the supplied model --- 55,60 ---- del tb ! def build_python_code(model, generation_scheme, ! rootPath=None, typeOfCode='python', verbose_mode=0): """ Builds the python-code templates for the supplied model *************** *** 64,67 **** --- 64,69 ---- model -- an instance of Modeling.Model + generation_scheme -- + rootPath -- where the files should be dropped *************** *** 83,87 **** if typeOfCode=='python': from Modeling.ModelMasons.PyModelMason import PyModelMason ! mason = PyModelMason(model, rootPath, verbose_mode=verbose_mode) mason.build() --- 85,90 ---- if typeOfCode=='python': from Modeling.ModelMasons.PyModelMason import PyModelMason ! mason = PyModelMason(model, rootPath, verbose_mode=verbose_mode, ! generation_scheme=generation_scheme) mason.build() *************** *** 99,109 **** ! Options: ! -------- -h --help gives this help -v --verbose verbose mode (default) -q --quiet quiet mode """ % prgName sys.stderr.write(_usage) --- 102,120 ---- ! General options: ! ---------------- -h --help gives this help -v --verbose verbose mode (default) -q --quiet quiet mode + Generation options: + ------------------- + -B --base-generation-scheme use the 'base' scheme + -C --compact-generation-scheme use the 'compact' scheme (default) + -g<scheme> + --generation_scheme=<scheme> use <scheme> as the generation scheme + (either 'base' or 'compact') + """ % prgName sys.stderr.write(_usage) *************** *** 115,126 **** me=args[0] try: options, args = getopt.getopt(sys.argv[1:], ! 'hqv', ! ["help", "quiet", "verbose"]) except: usage(me); return 1 global verbose for k, v in options: if k in ('-h', '--help'): usage(me); return 0 if k in ('-q', '--quiet'): verbose=0; continue ! if k in ('-v', '--verbose'): verbose=1; continue if len(args) not in (1,2): usage(me) ; return 1 --- 126,143 ---- me=args[0] try: options, args = getopt.getopt(sys.argv[1:], ! 'BCg:hqv', ! ["help", "quiet", "verbose", ! "generation_scheme=", ! "compact-generation-scheme", ! "base-generation-scheme"]) except: usage(me); return 1 global verbose + generation_scheme='compact' for k, v in options: if k in ('-h', '--help'): usage(me); return 0 if k in ('-q', '--quiet'): verbose=0; continue ! if k in ('-g', '--generation-scheme'): generation_scheme=v; continue ! if k in ('-C', '--compact-generation-scheme'): generation_scheme='compact'; continue ! if k in ('-B', '--base-generation-scheme'): generation_scheme='base'; continue if len(args) not in (1,2): usage(me) ; return 1 *************** *** 142,146 **** model=ms.models()[0] try: ! build_python_code(model, rootPath, verbose_mode=verbose) except TargetDirectoryAlreadyExists, exc: sys.stderr.write(str(sys.exc_info()[1])+'\n') --- 159,163 ---- model=ms.models()[0] try: ! build_python_code(model, generation_scheme, rootPath, verbose_mode=verbose) except TargetDirectoryAlreadyExists, exc: sys.stderr.write(str(sys.exc_info()[1])+'\n') |