[Modeling-cvs] ProjectModeling/Modeling CHANGES,1.131,1.132 ModelSet.py,1.9,1.10 Model.py,1.8,1.9 Cl
Status: Abandoned
Brought to you by:
sbigaret
From: <sbi...@us...> - 2003-07-23 21:09:30
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv29304 Modified Files: CHANGES ModelSet.py Model.py ClassDescription.py Log Message: Simple methods for models, entities, attributes, relationships and ClassDescriptions are now automatically cached. This speeds up operations where model introspection is needed (when saving changes, when using RelationshipManipulation interface, etc.) Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v retrieving revision 1.131 retrieving revision 1.132 diff -C2 -d -r1.131 -r1.132 *** CHANGES 23 Jul 2003 14:50:50 -0000 1.131 --- CHANGES 23 Jul 2003 21:09:25 -0000 1.132 *************** *** 8,13 **** -------------------------------------------------------- * Module RelationshipManipulation has been optimized and is now about 1.2x ! faster. * Model, Entity, Attribute, Relationship, Join: replaced 'Unimplemented' --- 8,19 ---- -------------------------------------------------------- + * Simple methods for models, entities, attributes, relationships and + ClassDescriptions are now automatically cached. This speeds up operations + where model introspection is needed (when saving changes, when using + RelationshipManipulation interface, etc.) + * Module RelationshipManipulation has been optimized and is now about 1.2x ! faster (2x faster with caching of models and class descriptions, see ! above) * Model, Entity, Attribute, Relationship, Join: replaced 'Unimplemented' *************** *** 39,43 **** [Merged branch brch-0_9pre7-1-PyModel] ! Note: PyModel are not officially announced w/ this release, because there's no documentation yet. See mailing-list archives for details, or go there and ask. --- 45,49 ---- [Merged branch brch-0_9pre7-1-PyModel] ! Note: PyModels are not officially announced w/ this release, because there's no documentation yet. See mailing-list archives for details, or go there and ask. Index: ModelSet.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelSet.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ModelSet.py 7 Jul 2003 14:57:13 -0000 1.9 --- ModelSet.py 23 Jul 2003 21:09:26 -0000 1.10 *************** *** 159,163 **** from Model import updateModelWithCFG updateModelWithCFG(aModel, cfg_path) ! # XML Import/Export facilities def addModelFromXML(self, xmlSource): --- 159,165 ---- from Model import updateModelWithCFG updateModelWithCFG(aModel, cfg_path) ! ! aModel.cacheSimpleMethods() ! # XML Import/Export facilities def addModelFromXML(self, xmlSource): Index: Model.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Model.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Model.py 23 Jul 2003 12:17:41 -0000 1.8 --- Model.py 23 Jul 2003 21:09:26 -0000 1.9 *************** *** 267,270 **** --- 267,293 ---- + def cacheSimpleMethods(self): + """ + Iterates on entities, entities' attributes and relationships, and self, + and caches the result of methods taking only one argument ('self'). + + This can be disabled by setting the environment variable + MDL_DISABLE_SIMPLE_METHOD_CACHE to any non-empty string; you want to + disable it when you manipulate models at runtime, for example in a model + designer. + + See: Modeling.utils.cache_simple_methods + """ + from utils import cache_simple_methods + for e in self.entities(): + for a in e.attributes(): + cache_simple_methods(a) + for r in e.relationships(): + for j in r.joins(): + cache_simple_methods(j) + cache_simple_methods(r) + cache_simple_methods(e) + cache_simple_methods(self, ['cacheSimpleMethods']) + def adaptorName(self): "Returns the DB adaptor name. It may be None." Index: ClassDescription.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ClassDescription.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ClassDescription.py 16 Jul 2003 18:41:37 -0000 1.11 --- ClassDescription.py 23 Jul 2003 21:09:27 -0000 1.12 *************** *** 47,51 **** from logging import info, warn from delegation import DelegateWrapper ! from utils import staticmethod # interfaces --- 47,51 ---- from logging import info, warn from delegation import DelegateWrapper ! from utils import staticmethod, cache_simple_methods # interfaces *************** *** 126,132 **** def registerClassDescription(aClassDescription, name): ! "Assigns the supplied classDescription to 'name'" lock() try: __classDescriptionCache__[name]=aClassDescription finally: --- 126,139 ---- def registerClassDescription(aClassDescription, name): ! """ ! Assigns the supplied classDescription to 'name'. ! ! The supplied ClassDescription's simple methods are cached, unless ! MDL_DISABLE_SIMPLE_METHOD_CACHE is set to any non-empty string. See ! utils.cache_simple_methods() for details. ! """ lock() try: + cache_simple_methods(aClassDescription, ['rootClassDescription']) __classDescriptionCache__[name]=aClassDescription finally: |