modeling-cvs Mailing List for Object-Relational Bridge for python (Page 7)
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...> - 2004-02-17 19:21:27
|
Update of /cvsroot/modeling/ProjectModeling In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26994 Modified Files: setup.py vertoo.data CHANGES Log Message: Release 0.9pre17 Index: setup.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/setup.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** setup.py 16 Nov 2003 17:08:00 -0000 1.36 --- setup.py 17 Feb 2004 19:12:27 -0000 1.37 *************** *** 1,7 **** #!/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. --- 1,8 ---- #!/usr/bin/env python + # -*- coding: iso-8859-1 -*- #----------------------------------------------------------------------------- # # Modeling Framework: an Object-Relational Bridge for python ! # (c) 2001, 2002, 2003 Sébastien Bigaret # # This file is part of the Modeling Framework. *************** *** 81,85 **** setup(name="ModelingCore", ! version="0.9-pre-16", license ="GNU General Public License", description=short_description, --- 82,86 ---- setup(name="ModelingCore", ! version="0.9-pre-17", license ="GNU General Public License", description=short_description, Index: vertoo.data =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/vertoo.data,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** vertoo.data 16 Nov 2003 17:41:22 -0000 1.10 --- vertoo.data 17 Feb 2004 19:12:27 -0000 1.11 *************** *** 1,2 **** ! mdl-code = major:0; minor:9; pre:16; release:x; date:Nov 16, 2003; ! mdl_doc = major:0; minor:9; pre:16; release:x; date:Nov 16, 2003; \ No newline at end of file --- 1,2 ---- ! mdl-code = major:0; minor:9; pre:17; release:x; date:Feb 17, 2004; ! mdl_doc = major:0; minor:9; pre:17; release:x; date:Feb 17, 2004; \ No newline at end of file Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/CHANGES,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** CHANGES 17 Feb 2004 18:53:39 -0000 1.41 --- CHANGES 17 Feb 2004 19:12:27 -0000 1.42 *************** *** 3,11 **** Module Modeling --------------- ! Current release is: 0.9-pre-16 / See also: TODO, INSTALL and doc/ * ** Distributed under the GNU General Public License ** -------------------------------------------------------- * Integrated patch #814055: Dynamic creation of packages/modules/classes. Not publicly announced, it is not documented yet. Till then, the file --- 3,13 ---- Module Modeling --------------- ! Current release is: 0.9-pre-17 / See also: TODO, INSTALL and doc/ * ** Distributed under the GNU General Public License ** -------------------------------------------------------- + 0.9-pre-17 (2004/02/17) + ----------------------- * Integrated patch #814055: Dynamic creation of packages/modules/classes. Not publicly announced, it is not documented yet. Till then, the file |
From: <sbi...@us...> - 2004-02-17 19:21:27
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26994/Modeling Modified Files: __init__.py Log Message: Release 0.9pre17 Index: __init__.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/__init__.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** __init__.py 14 Feb 2004 18:27:04 -0000 1.6 --- __init__.py 17 Feb 2004 19:12:28 -0000 1.7 *************** *** 37,41 **** """ ! __version__="0.9-pre-16" import DatabaseContext # make it register itself for notifications --- 37,41 ---- """ ! __version__="0.9-pre-17" import DatabaseContext # make it register itself for notifications |
From: <sbi...@us...> - 2004-02-17 19:12:16
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25350/Modeling Modified Files: Model.py Log Message: Removed Modeling.mems_lib, we'll use the one in NotificationFramework instead Index: Model.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Model.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Model.py 14 Feb 2004 18:27:03 -0000 1.14 --- Model.py 17 Feb 2004 19:03:16 -0000 1.15 *************** *** 161,165 **** 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 --- 161,165 ---- if hasattr(module, 'model'): model=module.model ! from NotificationFramework.mems_lib import isinstance if callable(model) and not isinstance(model, Model): # Model.Model derives from ZODB.Persistent, hence it is callable |
From: <sbi...@us...> - 2004-02-17 19:09:27
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24730 Removed Files: mems_lib.py Log Message: Removed, we'll use the one in NotificationFramework instead --- mems_lib.py DELETED --- |
From: <sbi...@us...> - 2004-02-17 19:02:38
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23227/Modeling/DatabaseAdaptors/MySQLAdaptorLayer Modified Files: MySQLAdaptorChannel.py Log Message: Fixed generation of PK: two threads could get the same id Index: MySQLAdaptorChannel.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer/MySQLAdaptorChannel.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MySQLAdaptorChannel.py 10 Jan 2003 10:45:45 -0000 1.1 --- MySQLAdaptorChannel.py 17 Feb 2004 18:53:40 -0000 1.2 *************** *** 80,84 **** pkRootName=anEntity.primaryKeyRootName() statements=["UPDATE PK_SEQ_%s SET id=LAST_INSERT_ID(id+1)"%pkRootName, ! "select id FROM PK_SEQ_%s"%pkRootName] result=[] for idx in range(count): --- 80,84 ---- pkRootName=anEntity.primaryKeyRootName() statements=["UPDATE PK_SEQ_%s SET id=LAST_INSERT_ID(id+1)"%pkRootName, ! "select LAST_INSERT_ID()"] result=[] for idx in range(count): |
From: <sbi...@us...> - 2004-02-17 19:02:38
|
Update of /cvsroot/modeling/ProjectModeling In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23227 Modified Files: CHANGES Log Message: Fixed generation of PK: two threads could get the same id Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/CHANGES,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** CHANGES 16 Feb 2004 20:01:06 -0000 1.40 --- CHANGES 17 Feb 2004 18:53:39 -0000 1.41 *************** *** 12,16 **** doc/README.dynamic.txt contains further details. ! * MySQL: added DOUBLE to the list of supported SQL types * Applied patch #771009: DatabaseContext.batchFetchRelationship() --- 12,20 ---- doc/README.dynamic.txt contains further details. ! * MySQL: ! ! - added DOUBLE to the list of supported SQL types ! ! - fixed the generation of primary keys: two threads could get the same id * Applied patch #771009: DatabaseContext.batchFetchRelationship() |
From: <sbi...@us...> - 2004-02-16 20:09:24
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19962/Modeling Modified Files: ClassDescription.py CustomObject.py Database.py EditingContext.py Entity.py SQLExpression.py SnapshotsHandling.py utils.py Added Files: dynamic.py Log Message: Integrated patch #814055: Dynamic creation of packages/modules/classes --- NEW FILE: dynamic.py --- #! /usr/bin/env python # -*- coding: iso-8859-1 -*- #----------------------------------------------------------------------------- # # Modeling Framework: an Object-Relational Bridge for python # (c) 2001, 2002, 2003 Sébastien 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 # #----------------------------------------------------------------------------- """ Documentation not written yet --see doc/README.dynamic.txt for details. """ import code, new, sys from Modeling.CustomObject import CustomObject from Modeling.ModelSet import defaultModelSet from Modeling.utils import capitalizeFirstLetter def function_for_code(c, func_name): c+='\nfunc='+func_name+'\n' exec(c) return func def instance_method(aClass, c, func_name): func=function_for_code(c, func_name) meth=new.instancemethod(func, None, aClass) return meth def init_code(entity, init=None): """ init: the original __init__, if available """ c="def __init__(self, **kw):\n" for p in entity.classProperties(): c+=" self._"+p.name()+"=" if hasattr(p,'isToMany'): # rel if p.isToMany(): c+="()" else: c+="None" else: c+=repr(p.defaultValue()) c+="\n" c+=""" for k,v in kw.items(): self.takeValueForKey(v, k) """ if init: c+=" apply(self.%s, (), kw)"%init return c def add_init(aClass, entity): "Adds to the class the method __init__() suitable for entity" c=init_code(entity) m=instance_method(aClass, c, "__init__") setattr(aClass,'__init__',m) def define_entityName(aClass, entity): c="""def entityName(self): "Used by the framework to link this object to its entity" return "%s" # do not change """%entity.name() return c def add_entityName(aClass, entity): "Adds to the new class the method entityName() suitable for entity" c=define_entityName(aClass, entity) m=instance_method(aClass, c, "entityName") setattr(aClass,'entityName',m) def add_getters(aClass, entity): "Adds getters to aClass, one for each entity.classProperties()" for p in entity.classProperties(): add_getter(aClass, p) def add_setters(aClass, entity): "Adds setters to aClass, one for each entity.classProperties()" for p in entity.classProperties(): add_setter(aClass, p) def getter_code(prop): func_name="get"+capitalizeFirstLetter(prop.name()) c='def %s(self):\n self.willRead()\n'%func_name c+=" return self._"+prop.name() return func_name, c def add_getter(aClass, prop): "Builds and adds to aClass the getter for property prop" func_name, c=getter_code(prop) m=instance_method(aClass, c, func_name) setattr(aClass, m.__name__, m) def setters_code(prop): "returns: ( (name, code_string), ... )" names_n_funcs=[] part_func_name=capitalizeFirstLetter(prop.name()) if hasattr(prop,'isToMany') and prop.isToMany(): func_name="addTo"+part_func_name c='''def %(func_name)s(self, obj): if obj not in self._%(name)s: self.willChange() _list=list(self._%(name)s) _list.append(obj) self._%(name)s=tuple(_list) '''%{'func_name': func_name, 'name': prop.name()} names_n_funcs.append( (func_name, c) ) func_name="removeFrom"+part_func_name c='''def %(func_name)s(self, obj): self.willChange() _list=list(self._%(name)s) _list.remove(obj) self._%(name)s=tuple(_list) '''%{'func_name': func_name, 'name': prop.name()} names_n_funcs.append( (func_name, c) ) func_name="set"+part_func_name c='def %s(self, obj):\n self.willChange()\n'%func_name c+=" self._"+prop.name()+"=obj" names_n_funcs.append( (func_name, c) ) return names_n_funcs def add_setter(aClass, prop): "Builds and adds to aClass the setter for property prop" names_n_funcs=setters_code(prop) for func_name, c in names_n_funcs: m=instance_method(aClass, c, func_name) setattr(aClass, m.__name__, m) def add_properties(aClass, entity): for p in entity.classProperties(): #print 'defining prop: ', p.name() part_func_name=capitalizeFirstLetter(p.name()) prop=property(getattr(aClass, 'get'+part_func_name), getattr(aClass, 'set'+part_func_name), None) setattr(aClass, p.name(), prop) def build(model, define_properties=0): module_name=model.packageName() classes={} modules={} for e in model.entities(): c=new.classobj(e.name(), (CustomObject,), {}) m=new.module(e.name()) setattr(m, e.name(),c) classes[e.name()]=c modules[e.name()]=m m.__name__='AB.'+e.name() # Not required? but in accordance to observations add_init(c, e) add_entityName(c, e) add_getters(c, e) add_setters(c, e) if define_properties: add_properties(c, e) p=new.module(module_name) #m.Book=classes['Book'] import sys for name,m in modules.items(): setattr(p,name,m) sys.modules[module_name]=p # the following is needed if we want to "from AB.Book import Book" for name,m in modules.items(): sys.modules[module_name+'.'+name]=m ## ## Examples of use follow ## if __name__ == "__main__": from Modeling import ModelSet, Model model_name="AuthorBooks" if ModelSet.defaultModelSet().modelNamed(model_name) is None: import os model=Model.searchModel(model_name, 'xmlmodels', verbose=1) if not model: raise RuntimeError, "Couldn't load model '%s'"%model_name else: ModelSet.defaultModelSet().addModel(model) build(model) from Modeling.EditingContext import EditingContext ec=EditingContext() print [b.getTitle() for b in ec.fetch('Book')] from AuthorBooks import Book from AuthorBooks.Book import Book print Book b=Book(title='mon titre') print repr(b.getTitle()) sys.exit(0) ######################################################################## # metaclass # def info(classdict, msg): if classdict.get('mdl_verbose_metaclass', None): sys.stderr.write("[CustomObjectMeta] "+msg+'\n') def checkEntityName(classname, bases, classdict): entityName=classdict.get('entityName', None) if entityName is None: info(classdict, 'entityName is not present: searching base classes') for b in bases: if b==CustomObject: continue; entityName=getattr(b, 'entityName',None) if entityName: info(classdict, 'Found in %s'%b.__name__) if entityName is None: info(classdict, 'entityName is not present: using default: %s'%classname) entityName=classname if not callable(entityName): classdict['entityName']=lambda self, n=entityName: n else: entityName=entityName.im_func(None) return entityName def addCustomObject(bases): from Modeling.CustomObject import CustomObject if CustomObject not in bases: bases=list(bases) bases.append(CustomObject) bases=tuple(bases) return bases def check_oldinit(classname, oldinit, entity): "Check that the already defined __init__ can be called without any arguments" import inspect args, varargs, varkw, defaults=inspect.getargspec(oldinit) if len(args)-len(defaults)>1: raise RuntimeError,'%s.__init__() cannot be called without arguments'%classname # to be continued: on veut pouvoir appeler init() avec les bons arguments, # tout en récupérant ceux qui peuvent nous servir (les attributs) # e.g. init(self, attr1='t') ou init(self, attr1='x', non_attr='xx') etc. def define_init(entity, classname, classdict): oldinit=classdict.get('__init__', None) if oldinit: classdict['__original_init__']=oldinit check_oldinit(classname, oldinit, entity) c=init_code(entity, oldinit) init=function_for_code(c, '__init__') classdict['__init__']=init def define_getter(prop, classdict): func_name, c=getter_code(prop) info(classdict, "adding getter: %s"%func_name) getter=function_for_code(c, func_name) classdict[func_name]=getter def define_getters(entity, classname, classdict): info(classdict, "setting getters") for p in entity.classProperties(): define_getter(p, classdict) def define_setter(prop, classdict): names_and_funcs=setters_code(prop) for func_name, c in names_and_funcs: info(classdict, "adding setter: %s"%func_name) setter=function_for_code(c, func_name) classdict[func_name]=setter def define_setters(entity, classname, classdict): info(classdict, "setting setters") for p in entity.classProperties(): define_setter(p, classdict) def define_properties(entity, classname, classdict): #info(classdict, "defining properties for class %s"%classname) for p in entity.classProperties(): info(classdict, "adding properties '%s' for class %s"%(p.name(),classname)) part_func_name=capitalizeFirstLetter(p.name()) prop=property(classdict['get'+part_func_name], classdict['set'+part_func_name], None) classdict[p.name()]=prop try: class A(type): pass metaclass_available=1 del A except TypeError: metaclass_available=0 class EntityNotFound(RuntimeError): pass if metaclass_available: class CustomObjectMeta(type): def __new__(meta,classname,bases,classdict): info(classdict, 'meta: %s'%meta) info(classdict, 'classname: '+classname) info(classdict, 'bases: %s'%(bases,)) info(classdict, 'classdict: %s'%classdict) entityName=checkEntityName(classname, bases, classdict) bases=addCustomObject(bases) from Modeling.ModelSet import defaultModelSet entity=defaultModelSet().entityNamed(entityName) if entity is None: raise EntityNotFound, 'Unable to initialize class %s: entity %s not found'%(classname, entityName) else: define_init(entity, classname, classdict) define_getters(entity, classname, classdict) define_setters(entity, classname, classdict) if classdict.get('mdl_define_properties', None): define_properties(entity, classname, classdict) return super(CustomObjectMeta,meta).__new__(meta,classname, bases,classdict) def build_with_metaclass(model, define_properties=0, verbose=0): module_name=model.packageName() classes={} modules={} for e in model.entities(): c=CustomObjectMeta(e.className(), (), {'mdl_verbose_metaclass': verbose, 'mdl_define_properties': define_properties}) m=new.module(e.name()) setattr(m, e.name(),c) classes[e.name()]=c modules[e.name()]=m m.__name__=model.packageName()+'.'+e.name() # pas requis? mais conforme p=new.module(module_name) #m.Book=classes['Book'] import sys for name,m in modules.items(): setattr(p,name,m) sys.modules[module_name]=p # the following is needed if we want to "from AuthorBooks.Book import Book" for name,m in modules.items(): sys.modules[module_name+'.'+name]=m else: def build_with_metaclass(model, define_properties=0, verbose=0): raise NotImplementedError, "metaclass are not available" ## ## Two examples of use follow ## if __name__ == "__main__2": from Modeling import ModelSet, Model model_name="AuthorBooks" if ModelSet.defaultModelSet().modelNamed(model_name) is None: import os mydir = '.' model=Model.searchModel(model_name, mydir, verbose=1) if not model: raise RuntimeError, "Couldn't load model '%s'"%model_name else: ModelSet.defaultModelSet().addModel(model) class Book: __metaclass__=CustomObjectMeta mdl_verbose_metaclass=1 mdl_define_properties=1 entityName='Book' #def entityName(self): # return 'Book' #def __init__(self): # print 'PPP' def willRead(self): print '[willRead]', def willChange(self): print '[willChange]', def _getTitle(self): print '[_getTitle()]', return self._title def _setTitle(self, title): print '[_setTitle()]', self._title=title #__metaclass__=CustomObjectMeta #c=type('Writer', (), {'__metaclass__': CustomObjectMeta, # 'mdl_verbose_metaclass': 1, # 'mdl_define_properties': 1}) Writer=CustomObjectMeta('Writer', (), {'mdl_verbose_metaclass': 1, 'mdl_define_properties': 0}) #Book=CustomObjectMeta('Book', (), {'mdl_verbose_metaclass': 1}) print Writer, Writer.__bases__ from Modeling.EditingContext import EditingContext ec=EditingContext() print Book.__bases__ b=Book(title='glop') ec.insert(b) print b.entityName() print b._title b.setTitle('title test') print b.getTitle() print ec.allInsertedObjects(), b print 'trying properties' print b.title print '## KVC' print 'storedValue ',b.storedValueForKey('title') print 'takestored ',b.takeStoredValueForKey('takeStoredValueForKey','title') print 'value ',b.valueForKey('title') print 'takeValue ',b.takeValueForKey('takeStoredValueForKey','title') print 'title: ', b.title sys.exit(0) if __name__ == "__main__": from Modeling import ModelSet, Model model_name="AuthorBooks" if ModelSet.defaultModelSet().modelNamed(model_name) is None: import os mydir = '.' model=Model.searchModel(model_name, mydir, verbose=1) if not model: raise RuntimeError, "Couldn't load model '%s'"%model_name else: ModelSet.defaultModelSet().addModel(model) build_with_metaclass(model, define_properties=0) from Modeling.EditingContext import EditingContext ec=EditingContext() print [b.getTitle() for b in ec.fetch('Book')] from AuthorBooks import Book from AuthorBooks.Book import Book print Book b=Book(title='mon titre') print repr(b.getTitle()), b.title sys.exit(0) Index: ClassDescription.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ClassDescription.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ClassDescription.py 14 Feb 2004 18:30:33 -0000 1.14 --- ClassDescription.py 16 Feb 2004 20:01:06 -0000 1.15 *************** *** 155,159 **** ## ClassDescription ## ! class ClassDescription: """ This class is an *abstract* class ; all methods defined in --- 155,160 ---- ## ClassDescription ## ! from Modeling.utils import base_object ! class ClassDescription(base_object): """ This class is an *abstract* class ; all methods defined in Index: CustomObject.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CustomObject.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** CustomObject.py 14 Feb 2004 18:27:03 -0000 1.19 --- CustomObject.py 16 Feb 2004 20:01:06 -0000 1.20 *************** *** 91,96 **** return ec.arrayFaultWithSourceGlobalID(self.sourceGlobalID, self.key, ec) ! ! class CustomObject(RelationshipManipulation, DatabaseObject): """ --- 91,97 ---- return ec.arrayFaultWithSourceGlobalID(self.sourceGlobalID, self.key, ec) ! ! from Modeling.utils import base_object ! class CustomObject(base_object, RelationshipManipulation, DatabaseObject): """ Index: Database.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Database.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Database.py 14 Feb 2004 18:27:03 -0000 1.9 --- Database.py 16 Feb 2004 20:01:06 -0000 1.10 *************** *** 113,117 **** unlock() ! class Database: """ Key features: --- 113,118 ---- unlock() ! from Modeling.utils import base_object ! class Database(base_object): """ Key features: Index: EditingContext.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/EditingContext.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** EditingContext.py 14 Feb 2004 18:27:03 -0000 1.31 --- EditingContext.py 16 Feb 2004 20:01:06 -0000 1.32 *************** *** 124,128 **** ## recordObject(), deleteObject(), objectWillChange()] ! class EditingContext(ObjectStore): # ??? """ EditingContext: an in-memory world/graph of objects, with the ability --- 124,129 ---- ## recordObject(), deleteObject(), objectWillChange()] ! from Modeling.utils import base_object ! class EditingContext(base_object, ObjectStore): # ??? """ EditingContext: an in-memory world/graph of objects, with the ability *************** *** 149,153 **** # see: __init__() ######## ! class UniquingTable: """ The uniquing table - encapsulate the dictionary structure --- 150,154 ---- # see: __init__() ######## ! class UniquingTable(base_object): """ The uniquing table - encapsulate the dictionary structure Index: Entity.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Entity.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Entity.py 14 Feb 2004 18:27:03 -0000 1.20 --- Entity.py 16 Feb 2004 20:01:06 -0000 1.21 *************** *** 118,122 **** from Persistent import Persistent ! class Entity(XMLCapability, Persistent, KeyValueCoding): """ Describes an entity --- 118,123 ---- from Persistent import Persistent ! from Modeling.utils import base_object ! class Entity(base_object, XMLCapability, Persistent, KeyValueCoding): """ Describes an entity Index: SQLExpression.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/SQLExpression.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** SQLExpression.py 14 Feb 2004 18:27:04 -0000 1.27 --- SQLExpression.py 16 Feb 2004 20:01:06 -0000 1.28 *************** *** 85,89 **** pass ! class SQLExpression: """ """ --- 85,90 ---- pass ! from Modeling.utils import base_object ! class SQLExpression(base_object): """ """ Index: SnapshotsHandling.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/SnapshotsHandling.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SnapshotsHandling.py 14 Feb 2004 18:27:04 -0000 1.6 --- SnapshotsHandling.py 16 Feb 2004 20:01:06 -0000 1.7 *************** *** 34,38 **** DistantPastTimeInterval = 0 ! class SnapshotsTable: """ __TBD --- 34,39 ---- DistantPastTimeInterval = 0 ! from Modeling.utils import base_object ! class SnapshotsTable(base_object): """ __TBD Index: utils.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/utils.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** utils.py 14 Feb 2004 18:27:04 -0000 1.18 --- utils.py 16 Feb 2004 20:01:06 -0000 1.19 *************** *** 39,42 **** --- 39,50 ---- from time import strftime + import types + try: + base_object = types.ObjectType + newclass = 1 + except AttributeError: + class base_object : pass + newclass = 0 + _validFirstLetter = "_"+string.letters |
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19962/Modeling/tests Modified Files: run.py test_EditingContext_Global.py test_EditingContext_Global_Inheritance.py test_EditingContext_ParentChild.py utils.py Log Message: Integrated patch #814055: Dynamic creation of packages/modules/classes Index: run.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/run.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** run.py 14 Feb 2004 18:17:21 -0000 1.8 --- run.py 16 Feb 2004 20:01:08 -0000 1.9 *************** *** 33,37 **** if __name__ == "__main__": utils.disable_model_cache() # test_EntityClassDescription requires it ! # Modeling Layer import test_Model --- 33,44 ---- if __name__ == "__main__": utils.disable_model_cache() # test_EntityClassDescription requires it ! if '-c' in sys.argv or '-C' in sys.argv \ ! or '-m' in sys.argv or '-M' in sys.argv: ! utils.fixpath(include_testPackages=0) ! utils.dynamically_build_test_packages(sys.argv) ! else: ! utils.fixpath(include_testPackages=1) ! ! # Modeling Layer import test_Model Index: test_EditingContext_Global.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** test_EditingContext_Global.py 14 Feb 2004 19:19:48 -0000 1.48 --- test_EditingContext_Global.py 16 Feb 2004 20:01:08 -0000 1.49 *************** *** 39,47 **** import unittest, sys import utils if __name__ == "__main__": utils.disable_model_cache() ! utils.fixpath() from Modeling import ModelSet, Model from Modeling.EditingContext import EditingContext from Modeling.FetchSpecification import FetchSpecification --- 39,57 ---- import unittest, sys import utils + if __name__ == "__main__": utils.disable_model_cache() ! if '-c' in sys.argv or '-C' in sys.argv \ ! or '-m' in sys.argv or '-M' in sys.argv: ! utils.fixpath(include_testPackages=0) ! utils.dynamically_build_test_packages(sys.argv) ! else: ! utils.fixpath(include_testPackages=1) from Modeling import ModelSet, Model + + from AuthorBooks.Writer import Writer + from AuthorBooks.Book import Book + from Modeling.EditingContext import EditingContext from Modeling.FetchSpecification import FetchSpecification *************** *** 52,57 **** from Modeling import Database - from testPackages.AuthorBooks.Writer import Writer - from testPackages.AuthorBooks.Book import Book class Writer_test07(Writer): --- 62,65 ---- Index: test_EditingContext_Global_Inheritance.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global_Inheritance.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** test_EditingContext_Global_Inheritance.py 14 Feb 2004 19:00:28 -0000 1.23 --- test_EditingContext_Global_Inheritance.py 16 Feb 2004 20:01:08 -0000 1.24 *************** *** 40,44 **** if __name__ == "__main__": utils.disable_model_cache() ! utils.fixpath() from Modeling import ModelSet, Model --- 40,49 ---- if __name__ == "__main__": utils.disable_model_cache() ! if '-c' in sys.argv or '-C' in sys.argv \ ! or '-m' in sys.argv or '-M' in sys.argv: ! utils.fixpath(include_testPackages=0) ! utils.dynamically_build_test_packages(sys.argv) ! else: ! utils.fixpath(include_testPackages=1) from Modeling import ModelSet, Model *************** *** 926,930 **** suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestEditingContext_Global_Inheritance, ! "test")) return suite --- 931,935 ---- suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestEditingContext_Global_Inheritance, ! "test_")) return suite Index: test_EditingContext_ParentChild.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_ParentChild.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_EditingContext_ParentChild.py 14 Feb 2004 18:17:21 -0000 1.15 --- test_EditingContext_ParentChild.py 16 Feb 2004 20:01:08 -0000 1.16 *************** *** 40,44 **** if __name__ == "__main__": utils.disable_model_cache() ! utils.fixpath() from Modeling import ModelSet, Model --- 40,49 ---- if __name__ == "__main__": utils.disable_model_cache() ! if '-c' in sys.argv or '-C' in sys.argv \ ! or '-m' in sys.argv or '-M' in sys.argv: ! utils.fixpath(include_testPackages=0) ! utils.dynamically_build_test_packages(sys.argv) ! else: ! utils.fixpath(include_testPackages=1) from Modeling import ModelSet, Model *************** *** 51,56 **** from Modeling import Database ! from testPackages.AuthorBooks.Writer import Writer ! from testPackages.AuthorBooks.Book import Book from StoreEmployees import Employee --- 56,61 ---- from Modeling import Database ! from AuthorBooks.Writer import Writer ! from AuthorBooks.Book import Book from StoreEmployees import Employee Index: utils.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/utils.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** utils.py 14 Feb 2004 18:17:21 -0000 1.9 --- utils.py 16 Feb 2004 20:01:08 -0000 1.10 *************** *** 34,42 **** __version__='$Revision$'[11:-2] ! import os, sys # ! # mydir is where this file is, codedir is 2 level up ! def fixpath(): mydir = os.path.abspath(os.path.dirname(__file__)) codedir = os.path.dirname(os.path.dirname(mydir)) --- 34,50 ---- __version__='$Revision$'[11:-2] ! import os, sys, unittest # ! def fixpath(include_testPackages=1): ! """ ! Prepends directory ../.. to sys.path, so that any import from Modeling ! imports the modules in this directory, rather then the possibly installed ! one: we want to test the framework in this directory. ! ! If include_testPackages is true, we also prepends the testPackages/ ! directory to sys.path ! """ ! # mydir is where this file is, codedir is 2 level up mydir = os.path.abspath(os.path.dirname(__file__)) codedir = os.path.dirname(os.path.dirname(mydir)) *************** *** 44,53 **** sys.path=[codedir]+sys.path # add the testPackages directory to the python path ! testPackageDir=os.path.join(mydir, 'testPackages') ! if testPackageDir not in sys.path: ! sys.path=[testPackageDir]+sys.path ! fixpath() ! import unittest def run_suite(suite, outf=sys.stdout, errf=None, verbosity=0): --- 52,110 ---- sys.path=[codedir]+sys.path # add the testPackages directory to the python path ! if include_testPackages: ! testPackageDir=os.path.join(mydir, 'testPackages') ! if testPackageDir not in sys.path: ! sys.path=[testPackageDir]+sys.path ! def dynamically_build_test_packages(argv): ! """ ! Uses Modeling.dynamic to dynamically create the test packages, depending on ! the values stored in the list 'argv': ! ! - if argv contains neither '-c', '-m' nor '-M', simply return ! ! - otherwise, load the models AuthorBooks and StoreEmployees, then: ! ! - if '-c' is in argv, dynamic.build(define_properties=0) the package ! ! - if '-C' is in argv, dynamic.build(define_properties=1) the package ! ! - if '-m' is in argv, dynamic.build_with_metaclass(define_properties=0) ! the package ! ! - if '-M' is in argv, dynamic.build_with_metaclass(define_properties=1) ! the package ! ! when this method returns, either '-c', '-C', '-m' or '-M' is removed from ! the list 'argv'. ! ! See the tests usage(), dynamic.build(), dynamic.build_with_metaclass() ! """ ! if '-c' not in argv and '-C' not in argv \ ! and '-m' not in argv and '-M' not in argv: ! return ! from Modeling import ModelSet, Model ! from Modeling.dynamic import build, build_with_metaclass ! verbose='-v' in argv or '-V' in argv ! model1=Model.searchModel('AuthorBooks', 'xmlmodels', verbose=verbose) ! model2=Model.searchModel('StoreEmployees', 'xmlmodels', verbose=verbose) ! ModelSet.defaultModelSet().addModel(model1) ! ModelSet.defaultModelSet().addModel(model2) ! if '-c' in argv: ! build(model1, define_properties=0) ! build(model2, define_properties=0) ! argv.remove('-c') ! if '-C' in argv: ! build(model1, define_properties=1) ! build(model2, define_properties=1) ! argv.remove('-C') ! elif '-m' in argv: ! build_with_metaclass(model1, define_properties=0, verbose=verbose) ! build_with_metaclass(model2, define_properties=0, verbose=verbose) ! argv.remove('-m') ! elif '-M' in argv: ! build_with_metaclass(model1, define_properties=1, verbose=verbose) ! build_with_metaclass(model2, define_properties=1, verbose=verbose) ! argv.remove('-M') def run_suite(suite, outf=sys.stdout, errf=None, verbosity=0): *************** *** 73,77 **** try: del os.environ['MDL_ENABLE_SIMPLE_METHOD_CACHE'] ! except: pass --- 130,134 ---- try: del os.environ['MDL_ENABLE_SIMPLE_METHOD_CACHE'] ! except KeyError: pass |
From: <sbi...@us...> - 2004-02-16 20:09:22
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests/xmlmodels In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19962/Modeling/tests/xmlmodels Added Files: pymodel_AuthorBooks.py pymodel_StoreEmployees.py Log Message: Integrated patch #814055: Dynamic creation of packages/modules/classes --- NEW FILE: pymodel_AuthorBooks.py --- #! /usr/bin/env python ''' A sample Pythonic OO-RDB Model (re-expressing testPackages/AuthorBooks/model_AuthorBooks.xml) -- A PyModel must define a global variable called 'model', that is of type Model ''' from Modeling.PyModel import * ## # Set preferred defaults for this model (when different from # standard defaults, or if we want to make things explicit) AFloat.defaults['precision'] = 10 AFloat.defaults['scale'] = 2 AString.defaults['width'] = 40 Association.defaults['delete']=['nullify', 'nullify'] Entity.defaults['properties'] = [ APrimaryKey('id', isClassProperty=0, isRequired=1, doc='PK') ] ## _connDict = {'database': 'AUTHOR_BOOKS'} _connDict = {'database': 'AUTHOR_BOOKS', 'host':'localhost','user':'postgres','password':''} model = Model('AuthorBooks',adaptorName='Postgresql', connDict=_connDict) model.doc = ' ... ' model.version='0.1' model.entities = [ # Entity('Book', properties=[ APrimaryKey('id', isClassProperty=1, columnName='id'), AString('title', isRequired=1, columnName='title'), AFloat('price', externalType='NUMERIC', width=0,precision=0), AForeignKey('FK_Writer_Id', isClassProperty=1), ], ), Entity('Writer', properties=[ AString('lastName',isRequired=1, width=30, displayLabel='Last Name', ), AString('firstName', displayLabel='First Name', ), AInteger('age', displayLabel='Age', ), ADateTime('birthday', usedForLocking=0, displayLabel='birthday', ), ] ), ] #--- model.associations=[ Association('Book', 'Writer', relations=['author', 'books'], delete=['nullify', 'cascade'], keys=['FK_Writer_Id', 'id']), Association('Writer', 'Writer', relations=['pygmalion', None], delete=['nullify', None], keys=['FK_Writer_id', 'id']), ] model.build() --- NEW FILE: pymodel_StoreEmployees.py --- #! /usr/bin/env python ''' A sample Pythonic OO-RDB Model (re-expressing testPackages/StoreEmployees/model_StoreEmployees.xml) -- A PyModel must define a global variable called 'model', that is of type Model ''' from Modeling.PyModel import * ## # Set preferred defaults for this model (when different from # standard defaults, or if we want to make things explicit) AFloat.defaults['precision'] = 10 AFloat.defaults['scale'] = 10 AString.defaults['width'] = 30 Association.defaults['delete']=['nullify', 'nullify'] Entity.defaults['properties'] = [ APrimaryKey('id', isClassProperty=0, isRequired=1, doc='Primary key!') ] ## _connDict = {'database': 'STORE_EMPLOYEES'} model = Model('StoreEmployees', adaptorName='', connDict=_connDict) model.doc = ' ... ' model.version='0.1' model.entities = [ # Entity('Store', properties=[ AString('corporateName', isRequired=1), ], ), Entity('Employee', properties=[ AString('lastName',isRequired=1,usedForLocking=1, width=20), AString('firstName', isRequired=1, width=50, usedForLocking=1), ] ), Entity('SalesClerk', parent='Employee', properties=[ AString('storeArea', width=20) ] ), Entity('Executive', parent='Employee', properties=[ AString('officeLocation', width=5) ] ), Entity('Address', properties=[ AString('street', width=80), AString('zipCode', width=10), AString('town'), ] ), Entity('Mark', properties=[ AInteger('month', isRequired=1), AInteger('mark', isRequired=1), ] ), Entity('Holidays', properties=[ ADateTime('startDate', isRequired=1), ADateTime('endDate', isRequired=1), ] ), ] model.associations=[ Association('Mark', 'Executive', relations=['executive', 'marks'], delete=['nullify', 'cascade'], keys=['FK_Executive_id', 'id']), Association('Address', 'Employee', relations=['toEmployee', 'toAddresses'], delete=['deny', 'cascade'], keys=['fkEmployeeId', 'id'], ), Association('Employee', 'Store', relations=['toStore', 'employees'], delete=['nullify', 'deny'], keys=['fkStoreId', 'id']), Association('Holidays', 'Employee', relations=[None, 'holidays'], delete=[None, 'cascade'], keys=['fkEmployeeId', 'id']), ] |
From: <sbi...@us...> - 2004-02-16 20:09:21
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19962/Modeling/doc Added Files: README.dynamic.txt Log Message: Integrated patch #814055: Dynamic creation of packages/modules/classes --- NEW FILE: README.dynamic.txt --- --------------------------- Dynamic creation of classes --------------------------- :Authors: Sébastien Bigaret <sbi...@us...> Principles ---------- The module Modeling.dynamic has been added. It can be used in three different ways: * method build(model): dynamically build the package derived from the model. The generated package and its modules have the very same functionality as the ones generated by the script mdl_generate_python_code.py (in "base" mode, option ``-B``). * metaclass ``CustomObjectMeta``: automatically adds all the necessary methods to a class for integration with the modeling framework. It looks for the following attributes in the class: - ``entityName``: mandatory, this is the name of the class' entity. The corresponding model should have been loaded prior to the class declaration, or you'll get a dynamic.EntityNotFound exception. - ``verbose_metaclass``: if set, the metaclass prints on sys.stderr some info while building the class. - ``mdl_define_properties``: if set, the metaclass will also add properties for each attribute on relationship in the entity, so that you do not need anymore to use e.g. ``book.getTitle()`` or ``book.setTitle``, but simply ``print book.title`` or ``book.title="my title"`` Note: this name is not definitive and will probably be changed before this is integrated into the core (same for metaclass, methods' names, etc.). Suggestions are welcome! * method ``build_with_metaclass(model, define_properties)``: builds the package and its module from a model. The generated modules and classes uses the ``CustomObjectMeta`` metaclass. Parameter ``define_properties`` triggers the creation of properties by the metaclass. This method raises ``NotImplementedError`` under python2.1, as expected. Note: The model will be loaded, as usually, from XML or PyModels, for example with Model.searchModel(). See e.g. tests/test_EditingContext_Global.py for an example. Example of use -------------- You find there three different examples on how these new features can be used:: ### Common to exs 1, 2 & 3: load the model from Modeling import ModelSet, Model, dynamic model=Model.searchModel('AuthorBooks', '.', verbose=1) ModelSet.defaultModelSet().addModel(model) ### 1. example with dynamic.build() dynamic.build(model) from Modeling.EditingContext import EditingContext from AuthorBooks.Book import Book # fetch ec=EditingContext() print [b.getTitle() for b in ec.fetch('Book')] # create a new book b=Book(title='mon titre') ec.insert(b) ec.saveChanges() ### 2. example with dynamic.build_metaclass() dynamic.build_with_metaclass(model, define_properties=1) from Modeling.EditingContext import EditingContext ec=EditingContext() print [b.title for b in ec.fetch('Book')] from AuthorBooks.Book import Book b=Book(title='mon titre7.2') ec.insert(b) ec.saveChanges() b.price=7.21 ### 3. example with the metaclass class Book: __metaclass__=dynamic.CustomObjectMeta entityName='Book' mdl_define_properties=1 class Writer: __metaclass__=dynamic.CustomObjectMeta entityName='Writer' mdl_define_properties=1 # fetch and insert etc., as usual: from Modeling.EditingContext import EditingContext ec=EditingContext() b=Book(title='book_w1') ; w1=Writer(lastName='w1') ec.insert(b) ; ec.insert(w1) b.author=w1 w1.addToBooks(b) ec.saveChanges() Tests ----- All three tests test_EC_Global.py, test_EC_Global_Inheritance.py and test_EC_ParentChild.py now accepts new options: * ``-c`` uses ``dynamic.build(model, define_properties=0)`` * ``-C`` uses ``dynamic.build(model, define_properties=1)`` * ``-m`` uses ``dynamic.build_with_metaclass(model, define_properties=0)`` * ``-M`` uses ``dynamic.build_with_metaclass(model, define_properties=1)`` * without any of these options, they use the test packages in tests/testPackages as in the standard distribution. Note: they all require that you copy the pymodels pymodel_AuthorBooks.py (in testPackages/AuthorBooks/) and pymodel_StoreEmployees.py (in (testPackages/StoreEmployees/) in the tests/ directory. Changes ------- Some classes have been changed to derive from ``object``, when available (python v2.2+), just because I've noted that this results in slightly better performance; however, this has nothing to do with the dynamic creation of classes. Among those classes that are now new-style classes: CustomObject. When it is integrated into the framework, this will probably be left as a choice for the user: since this transforms any user-class inheriting from CustomObject into new-style classes, this can have unexpected side-effects in other portions of the user's code (for example, ``type(object)==InstanceType`` for classic-style classes, while it equals to ``obj.__class__`` for new-style classes). Known issues ------------ If you get errors such as: ".../Modeling/dynamic.py", line 39, in instance_method meth=new.instancemethod(func, None, aClass) TypeError: instancemethod() argument 3 must be class, not type with python 2.2 you've probably been bitten by a bug in python 2.2 final, that has been fixed from version 2.2.1c1. See in particular: http://sf.net/tracker/index.php?func=detail&aid=503091&group_id=5470&atid=105470 http://www.python.org/2.2.2/NEWS.txt In this case, you should upgrade your python version. Note: python2.2 shipped w/ MacOS X has this bug. Thanks to Mario Ruggier for reporting the problem. |
From: <sbi...@us...> - 2004-02-16 20:09:20
|
Update of /cvsroot/modeling/ProjectModeling In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19962 Modified Files: CHANGES Log Message: Integrated patch #814055: Dynamic creation of packages/modules/classes Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/CHANGES,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** CHANGES 15 Feb 2004 20:30:35 -0000 1.39 --- CHANGES 16 Feb 2004 20:01:06 -0000 1.40 *************** *** 8,11 **** --- 8,15 ---- -------------------------------------------------------- + * Integrated patch #814055: Dynamic creation of packages/modules/classes. + Not publicly announced, it is not documented yet. Till then, the file + doc/README.dynamic.txt contains further details. + * MySQL: added DOUBLE to the list of supported SQL types |
From: <sbi...@us...> - 2004-02-15 20:38:54
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17171/Modeling/DatabaseAdaptors/MySQLAdaptorLayer Modified Files: __init__.py Log Message: MySQL: added DOUBLE to the list of supported SQL types Index: __init__.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer/__init__.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** __init__.py 20 Jan 2004 19:43:32 -0000 1.5 --- __init__.py 15 Feb 2004 20:31:27 -0000 1.6 *************** *** 46,50 **** VARCHAR, CHAR, TEXT, ! FLOAT, INT, INTEGER, NUMERIC, DATE, TIME, DATETIME --- 46,50 ---- VARCHAR, CHAR, TEXT, ! DOUBLE, FLOAT, INT, INTEGER, NUMERIC, DATE, TIME, DATETIME |
From: <sbi...@us...> - 2004-02-15 20:38:03
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16859/Modeling/DatabaseAdaptors/MySQLAdaptorLayer Modified Files: MySQLSQLExpression.py Log Message: MySQL: added DOUBLE to the list of supported SQL types Index: MySQLSQLExpression.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer/MySQLSQLExpression.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MySQLSQLExpression.py 15 Dec 2003 15:05:00 -0000 1.8 --- MySQLSQLExpression.py 15 Feb 2004 20:30:36 -0000 1.9 *************** *** 35,39 **** from Modeling.DatabaseAdaptors.MySQLAdaptorLayer.mysql_utils import * ! from Modeling.SQLExpression import SQLExpression, DateType, CharacterType from Modeling.logging import trace, db_trace import string --- 35,40 ---- from Modeling.DatabaseAdaptors.MySQLAdaptorLayer.mysql_utils import * ! from Modeling.SQLExpression import SQLExpression ! from Modeling.SQLExpression import DateType, CharacterType, NumericType from Modeling.logging import trace, db_trace import string *************** *** 118,122 **** del values['timestamp'] values.update({ 'datetime': DateType, ! 'text': CharacterType }) return values --- 119,124 ---- del values['timestamp'] values.update({ 'datetime': DateType, ! 'text': CharacterType, ! 'double': NumericType }) return values |
From: <sbi...@us...> - 2004-02-15 20:38:03
|
Update of /cvsroot/modeling/ProjectModeling In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16859 Modified Files: CHANGES Log Message: MySQL: added DOUBLE to the list of supported SQL types Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/CHANGES,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** CHANGES 15 Feb 2004 14:17:57 -0000 1.38 --- CHANGES 15 Feb 2004 20:30:35 -0000 1.39 *************** *** 8,11 **** --- 8,13 ---- -------------------------------------------------------- + * MySQL: added DOUBLE to the list of supported SQL types + * Applied patch #771009: DatabaseContext.batchFetchRelationship() Not publicly announced because it's not documented yet --and there a need |
From: <sbi...@us...> - 2004-02-15 14:26:58
|
Update of /cvsroot/modeling/ProjectModeling In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6868 Modified Files: vertoo.config Log Message: Updated: __version__ attribute added to package Index: vertoo.config =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/vertoo.config,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** vertoo.config 1 Sep 2003 21:16:34 -0000 1.5 --- vertoo.config 15 Feb 2004 14:19:36 -0000 1.6 *************** *** 18,21 **** --- 18,23 ---- mdl_code.addAnchors("setup.py", arguments(pattern="version=%Q", format='@full')) + mdl_code.addAnchors("Modeling/__init__.py", + arguments(pattern="__version__=%Q", format='@full')) mdl_doc=addModule('mdl_doc') |
From: <sbi...@us...> - 2004-02-15 14:25:13
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6460/Modeling Modified Files: DatabaseContext.py Log Message: Applied patch #771009: DatabaseContext.batchFetchRelationship() Index: DatabaseContext.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseContext.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** DatabaseContext.py 14 Feb 2004 18:27:03 -0000 1.20 --- DatabaseContext.py 15 Feb 2004 14:17:57 -0000 1.21 *************** *** 347,351 **** """ """ ! self.__unimplemented__() def database(self): --- 347,402 ---- """ """ ! #- fetch the objects / fire the faults, whatever ! #- get their Gids ! #- build qualifier to fetch related objects 'pk in %s'%pks ! # (cf. msg Lazy Initialization Part II) ! #- fetch related objects ! #- now we *know* we've got them all: populate them in the db cache w/ ! # Database.recordSnapshotForSourceGlobalID() ! #--> logically AccessArrayFaultHandler do not need to fetch the db any more ! if not objects: return ! ec=anEditingContext ! ! if aRelationship.isToOne(): ! src_entityName=objects[0].entityName() ! dst_pk_name=aRelationship.destinationAttributes()[0].name() ! src_gids=[o.globalID() for o in objects] ! src_fk_name=aRelationship.sourceAttributes()[0].name() ! src_fks=[self.database().snapshotForGlobalID(gid)[src_fk_name] ! for gid in src_gids] ! from Modeling.Qualifier import KeyValueQualifier, QualifierOperatorIn ! q=KeyValueQualifier(dst_pk_name, ! QualifierOperatorIn, ! src_fks) ! dst_objs=ec.fetch(aRelationship.destinationEntityName(), q) ! ! else: # to many ! src_entityName=objects[0].entityName() ! dst_attr_name=aRelationship.destinationAttributes()[0].name() ! src_gids=[o.globalID() for o in objects] ! src_pk_name=aRelationship.sourceAttributes()[0].name() ! src_pks=[gid.keyValues()[src_pk_name] for gid in src_gids] ! ! inv_rel=aRelationship.inverseRelationship() ! if inv_rel is None: # TBD: anyInverseRelationship ! raise 'aRelationship should have an inverse' ! ! from Modeling.Qualifier import KeyValueQualifier, QualifierOperatorIn ! q=KeyValueQualifier(inv_rel.name()+'.'+src_pk_name, ! QualifierOperatorIn, ! src_pks) ! dst_objs=ec.fetch(aRelationship.destinationEntityName(), q) ! db=self.database() ! d={} #key: srcGlobalID, rel: [list of rel_objs] ! for dst_obj in dst_objs: ! dst_gid=dst_obj.globalID() ! snap=db.snapshotForGlobalID(dst_gid) ! src_gid=KeyGlobalID(src_entityName, {src_pk_name: snap[dst_attr_name]}) ! l=d.setdefault(src_gid, []) ! l.append(dst_gid) ! ! rel_name=aRelationship.name() ! for src_gid in d.keys(): ! db.recordSnapshotForSourceGlobalID(d[src_gid], src_gid, rel_name) def database(self): |
From: <sbi...@us...> - 2004-02-15 14:25:13
|
Update of /cvsroot/modeling/ProjectModeling In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6460 Modified Files: CHANGES Log Message: Applied patch #771009: DatabaseContext.batchFetchRelationship() Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/CHANGES,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** CHANGES 9 Feb 2004 21:06:05 -0000 1.37 --- CHANGES 15 Feb 2004 14:17:57 -0000 1.38 *************** *** 8,11 **** --- 8,21 ---- -------------------------------------------------------- + * Applied patch #771009: DatabaseContext.batchFetchRelationship() + Not publicly announced because it's not documented yet --and there a need + for a more user-friendly API at the EditingContext level! + + * ObserverCenter: internals changed: no more variables or functions whose + names are surrounded by double-underscores (these names are normally + reserved for python use) + + * Updated the files to conform to PEP-0263: source encoding is iso-8859-1 + * Fixed SortOrdering.sortOrderingsWithString() |
From: <sbi...@us...> - 2004-02-15 14:11:26
|
Update of /cvsroot/modeling/NotificationFramework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4053 Modified Files: CHANGES Notification.py NotificationCenter.py __init__.py log.py mems_lib.py Log Message: All docstrings updated for epydoc + reStructuredText Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/CHANGES,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CHANGES 14 Feb 2004 19:44:11 -0000 1.10 --- CHANGES 15 Feb 2004 14:03:56 -0000 1.11 *************** *** 1,3 **** --- 1,5 ---- + - All docstrings updated for epydoc + reStructuredText + - Added attribute __version__ to package NotificationFramework Index: Notification.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/Notification.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Notification.py 14 Feb 2004 19:44:11 -0000 1.6 --- Notification.py 15 Feb 2004 14:03:56 -0000 1.7 *************** *** 23,28 **** #----------------------------------------------------------------------------- ! """ ! Notifications are the messages transmitted by the NotificationCenter. $Id$ --- 23,28 ---- #----------------------------------------------------------------------------- ! """A `Notification` object is a message transmitted by the ! `NotificationCenter`. $Id$ *************** *** 34,43 **** """ Notification objects are generally encountered when supplied by the ! NotificationCenter to its listener's callback method. ! A Notification object is designed as an immutable object. ! You should not need to directly instanciate Notification objects: rather, ! use NotificationCenter methods to add or remove observers and to post notifications. """ --- 34,43 ---- """ Notification objects are generally encountered when supplied by the ! `NotificationCenter` to its listener's callback method. ! A `Notification` object is designed as an immutable object. ! You should not need to directly instanciate `Notification` objects: rather, ! use `NotificationCenter` methods to add or remove observers and to post notifications. """ *************** *** 45,49 **** """ This is the Notification initializer -- you should not directly instanciate ! a Notification object: rather, use NoticationCenter methods to add observers or to post notifications """ --- 45,49 ---- """ This is the Notification initializer -- you should not directly instanciate ! a `Notification` object: rather, use `NotificationCenter` methods to add observers or to post notifications """ *************** *** 84,88 **** def __setattr__(self, name, value): ! "Raises TypeError since this is an immutable object" raise TypeError, 'object has read-only attributes' --- 84,88 ---- def __setattr__(self, name, value): ! "Raises ``TypeError`` since this is an immutable object" raise TypeError, 'object has read-only attributes' Index: NotificationCenter.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/NotificationCenter.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** NotificationCenter.py 14 Feb 2004 19:44:11 -0000 1.10 --- NotificationCenter.py 15 Feb 2004 14:03:56 -0000 1.11 *************** *** 24,30 **** ! """ ! NotificationCenter is the central object of the framework --full documentation ! is here. This module acts as a NotificationCenter. --- 24,29 ---- ! """NotificationCenter is the central object of the framework --full ! documentation is here. This module acts as a NotificationCenter. *************** *** 35,166 **** notification are automatically notified. ! Listeners and callbacks ! ! First at all, the Notification Center needs to have a mean to notify ! objects that a notification they are listening to was posted. To achieve ! this, objects should supply their reference, as well as a callback method ! at registration time (Note: by default only one callback is accepted per ! object; see discussion below). ! ! The possible listeners are: class instances ('types.InstanceType'), code ! objects or functions (such as functions defined in a module). See method ! 'addObserver' for full details ; we will focus in the following on class ! instances. ! ! For listeners being class instances, callbacks' signature should minimally ! be one of these:: ! ! def callback(self, notification) ! def callback(self, *arg) ! ! Hence, any of the following signatures are okay: ! ! def callback(self, notification, param1='param1') ! def callback(self, notification, *arg) ! def callback(self, notification, **kw) ! etc. ! ! Please note that the callback method must be supplied as a unbound ! method, e.g.: 'ObjectClass.callback'. ! ! When called by the NotificationCenter upon notification post, callback's ! parameter 'notification' is a Notification instance. ! ! Registration: Generic- and Specific- listeners ! ! Object can register as "generic observers" or "specific observers". ! ! Generic observers listens all notifications coming with a given ! name. They register themselves with:: ! ! NotificationCenter.addObserver(object, ObjectClass.method, 'NewMessage') ! Generic observers will be notified each time a notification with that name ! is posted, whatever the accompaying object can be (including None). ! ! Specific observers only listens notifications which have a given name ! *and* a given value. They register themselves with:: ! NotificationCenter.addObserver(object, ObjectClass.method, ! 'NewMessage', 'email') ! NotificationCenter.addObserver(object, ObjectClass.method, ! 'NewMessage', 'news') ! etc. ! Specific observers are only notified when a notification with these name ! and object is posted. ! Registering more than one callback per object ! By default, addObserver() checks that only one callback is registered per ! object; if you try to register a different one, you'll get a ValueError. ! Of course, a single object can listen to multiple notifications. In that ! case, you'll probably register a given method, say, handleNotification(), ! dedicated to this task:: ! def handleNotification(self, notification): ! notification_name=notification.name() ! if notification_name == "NOTIFICATION_ONE": ! # code for notification one ! elif notification_name == "NOTIFICATION_TWO" ! # code for notification two ! else: ! # Unhandled notification ! However, sometimes you do not want this; for example, you want to bind ! several methods of an object defined by a third-party module, and you do ! not want to modify its code. Registering multiple callbacks is possible ! when the environment variable ! 'NOTIFICATION_CENTER_MULTIPLE_CALLBACKS_PER_OBSERVER' is defined and ! its value is not an empty string. ! IMPORTANT: this variable should be set *prior* to any import statement ! importing the NotificationCenter module, or it wont have any ! effect at all. ! Example: - bash -- - export NOTIFICATION_CENTER_MULTIPLE_CALLBACKS_PER_OBSERVER='y' - - python -- ! import os ! os.environ['NOTIFICATION_CENTER_MULTIPLE_CALLBACKS_PER_OBSERVER']='y' ! from NotificationFramework import NotificationCenter ! Why is it not the default/only behaviour? ! Handling multiple callbacks per object implies a performance ! penalty. You can test which are the consequences on your platform with ! the supplied script 'compare_perfs.py' in directory tests/ On my ! machine, postNotification() is about 2.4x slower when the handling of ! multiple callbacks per object is activated. ! Notification names and objects ! Notifications names should be strings, even if this is not enforced by the ! framework. ! Notifications objects and info can be (almost: see below) everything. ! Restricting their type to existing python types will save you ! fighting against some strange behaviour, however, and should be sufficient ! for most situations --hopefully! - Zope: some important notes ! TBD!!! In the meantime you can look at the code for methods ! observerCodeForZopePersistentObject() and ! observerCodeForZopeTemporaryObject(), and to ! tests/test_NotificationCenter. test_7_codeObjectObservers(). ! MT status: This library was designed to be MT-safe. $Id$ """ --- 34,176 ---- notification are automatically notified. ! Listeners and callbacks ! ----------------------- ! First at all, the Notification Center needs to have a mean to notify ! objects that a notification they are listening to was posted. To achieve ! this, objects should supply their reference, as well as a callback method ! at registration time (Note: by default only one callback is accepted per ! object; see discussion below). ! The possible listeners are: class instances (`types.InstanceType`), code ! objects or functions (such as functions defined in a module). See method ! `addObserver` for full details ; we will focus in the following on class ! instances. ! ! For listeners being class instances, callbacks' signature should minimally ! be one of these:: ! ! def callback(self, notification) ! def callback(self, *arg) ! Hence, any of the following signatures are okay:: ! def callback(self, notification, param1='param1') ! def callback(self, notification, *arg) ! def callback(self, notification, **kw) ! etc. ! Please note that the callback method must be supplied as a unbound ! method, e.g.: ``ObjectClass.callback``. ! When called by the NotificationCenter upon notification post, callback's ! parameter ``notification`` is a `Notification` instance. ! Registration: Generic- and Specific- listeners ! ---------------------------------------------- ! Object can register as "generic observers" or "specific observers". ! Generic observers listens all notifications coming with a given ! name. They register themselves with:: ! NotificationCenter.addObserver(object, ObjectClass.method, 'NewMessage') ! Generic observers will be notified each time a notification with that name ! is posted, whatever the accompaying object can be (including None). ! Specific observers only listens notifications which have a given name ! *and* a given value. They register themselves with:: ! ! NotificationCenter.addObserver(object, ObjectClass.method, ! 'NewMessage', 'email') ! NotificationCenter.addObserver(object, ObjectClass.method, ! 'NewMessage', 'news') ! etc. ! ! Specific observers are only notified when a notification with these name ! and object is posted. ! ! Registering more than one callback per object ! --------------------------------------------- ! ! By default, `addObserver()` checks that only one callback is registered per ! object; if you try to register a different one, you'll get a ValueError. ! ! Of course, a single object can listen to multiple notifications. In that ! case, you'll probably register a given method, say, handleNotification(), ! dedicated to this task:: ! ! def handleNotification(self, notification): ! notification_name=notification.name() ! if notification_name == "NOTIFICATION_ONE": ! # code for notification one ! elif notification_name == "NOTIFICATION_TWO" ! # code for notification two ! else: ! # Unhandled notification ! ! However, sometimes you do not want this; for example, you want to bind ! several methods of an object defined by a third-party module, and you do ! not want to modify its code. Registering multiple callbacks is possible ! when the environment variable ! ``NOTIFICATION_CENTER_MULTIPLE_CALLBACKS_PER_OBSERVER`` is defined and ! its value is not an empty string. ! ! .. IMPORTANT:: ! ! This variable should be set *prior* to any import statement importing the ! `NotificationCenter` module, or it wont have any effect at all. ! ! Example ! ~~~~~~~ ! bash ! :: ! export NOTIFICATION_CENTER_MULTIPLE_CALLBACKS_PER_OBSERVER='y' ! ! python ! :: ! ! import os ! os.environ['NOTIFICATION_CENTER_MULTIPLE_CALLBACKS_PER_OBSERVER']='y' ! from NotificationFramework import NotificationCenter ! Why is it not the default/only behaviour? ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Handling multiple callbacks per object implies a performance penalty. You ! can test which are the consequences on your platform with the supplied ! script 'compare_perfs.py' in directory tests/ On my machine, ! postNotification() is about 2.4x slower when the handling of multiple ! callbacks per object is activated. ! Notification names and objects ! ------------------------------ ! Notifications names should be strings, even if this is not enforced by the ! framework. + Notifications objects and info can be (almost: see below) everything. + Restricting their type to existing python types will save you fighting against + some strange behaviour, however, and should be sufficient for most situations + --hopefully! ! Zope: some important notes ! -------------------------- ! ! TBD!!! In the meantime you can look at the code for methods ! `observerCodeForZopePersistentObject()` and ! `observerCodeForZopeTemporaryObject()`, and to ! ``tests/test_NotificationCenter.test_7_codeObjectObservers()``. ! MT status: This library was designed to be MT-safe. $Id$ + """ *************** *** 251,256 **** def addObserver(observer, callback, notificationName, object=None, sameObserverRegistersOnce=1): ! """ ! Adds the supplied observer to the list. Note that if the observer in a class' instance, it will be weakly --- 261,265 ---- def addObserver(observer, callback, notificationName, object=None, sameObserverRegistersOnce=1): ! """Adds the supplied observer to the list. Note that if the observer in a class' instance, it will be weakly *************** *** 260,274 **** first time they are supposed to receive a notification. ! addObserver() raises ValueError when an attempt is made to register an object that was previously registered with a different callback than the one supplied. Please refer to the module's documentation for a complete discussion on this topic. ! Parameters: ! observer, callback -- the observer object to be notified, and the method ! to call on that object when a given notification (see other parameters, ! below) is received. The following combinations of observer/callback are ! possible: - observer is a class instance (either a classic or a new-style --- 269,284 ---- first time they are supposed to receive a notification. ! `addObserver()` raises ``ValueError`` when an attempt is made to register an object that was previously registered with a different callback than the one supplied. Please refer to the module's documentation for a complete discussion on this topic. ! :Parameters: ! - `observer` ! - `callback`: the observer object to be notified, and the ! method to call on that object when a given notification (see other ! parameters, below) is received. The following combinations of ! observer/callback are possible: - observer is a class instance (either a classic or a new-style *************** *** 299,322 **** - observer is None: the callback must be of type 'types.FunctionType' ! notificationName, object -- identifies the notification the observer ! listens to. The 'notificationName' is mandatory and is usually a ! string. The object is optional. If provided, the observer will only be ! notified when a notification is posted with the same name and ! accompanying object. If omitted or 'None',the observer will be notified ! each time a notification with the correspoinding 'notificationName' is ! posted (whatever the accompanying object can be in the posted ! notification). ! sameObserverRegistersOnce -- if omitted or if it evaluates to a true ! value, the same observer will only be added once for the notification ! identified by '(notificationName, object)' (if the observer is None, ! replace ``observer'' with ``callback'' in the previous sentence) ; note ! that a notification with an accompanying object being None and another one ! whose accompanying object is not None are always considered different, ! hence in this case this option has obviously no effect. If this parameter ! evaluates to a false value, then the same observer can be multiply ! registered --in this case, such an observer's callback should be ready to ! answer more than once to a single notification post, and should be removed ! as many times as it was registered. """ --- 309,333 ---- - observer is None: the callback must be of type 'types.FunctionType' ! - `notificationName` ! - `object`: identifies the notification the observer listens to. The ! `notificationName` is mandatory and is usually a string. The object is ! optional. If provided, the observer will only be notified when a ! notification is posted with the same name and accompanying object. If ! omitted or ``None``,the observer will be notified each time a ! notification with the correspoinding `notificationName` is posted ! (whatever the accompanying object can be in the posted notification). ! ! - `sameObserverRegistersOnce`: if omitted or if it evaluates to a true ! value, the same observer will only be added once for the notification ! identified by ``(notificationName, object)`` (if the observer is None, ! replace ``observer`` with ``callback`` in the previous sentence) ; note ! that a notification with an accompanying object being None and another ! one whose accompanying object is not None are always considered ! different, hence in this case this option has obviously no effect. If ! this parameter evaluates to a false value, then the same observer can be ! multiply registered --in this case, such an observer's callback should ! be ready to answer more than once to a single notification post, and ! should be removed as many times as it was registered. """ *************** *** 363,381 **** Unregisters the observer for the given notification. Regarding the fact that an observer can be multiply registered for a single Notification (see: ! addObserver()), this method removes **one and only one** of the registered ! occurences except when both 'notificationName' and 'object' are omitted or None: see below. Silently returns if 'observer' is not registered. ! Parameters: ! observer -- the observer object to unregister ! notificationName, object -- these parameters identify the Notification for ! which the observer should be unregistered. If both are omitted or are ! equal to None, then the observer is completely removed from all the lists ! of observers. This includes all occurrences of 'observer' if it has been ! multiply registered. """ --- 374,393 ---- Unregisters the observer for the given notification. Regarding the fact that an observer can be multiply registered for a single Notification (see: ! `addObserver()`), this method removes **one and only one** of the registered ! occurences except when both `notificationName` and `object` are omitted or None: see below. Silently returns if 'observer' is not registered. ! :Parameters: ! - `observer`: the observer object to unregister ! - `notificationName` ! - `object`: these parameters identify the ! `Notification` for which the observer should be unregistered. If both ! are omitted or are equal to None, then the observer is completely ! removed from all the lists of observers. This includes all occurrences ! of 'observer' if it has been multiply registered. """ Index: __init__.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/__init__.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** __init__.py 14 Feb 2004 19:41:22 -0000 1.5 --- __init__.py 15 Feb 2004 14:03:56 -0000 1.6 *************** *** 27,34 **** they have no idea of who and where the other objects live. ! The complete documentation can found in L{module ! NotificationCenter<NotificationCenter>}. It is distributed under the GNU General Public License. """ __version__="0.6.1" --- 27,97 ---- they have no idea of who and where the other objects live. ! The complete documentation can found in module `NotificationCenter`. It is distributed under the GNU General Public License. + + `Download the last release at sourceforge`_ + + .. _`Download the last release at sourceforge`: https://sourceforge.net/project/showfiles.php?group_id=58935&package_id=54990 + + Example of use: + + .. code-block:: Python + + >>> from NotificationFramework import NotificationCenter as NC + + >>> SUBJECT_CHANGED='Subject changed' # string identifying the notification + + >>> class Subject: + ... value=0 + ... def __init__(self, name): + ... self.name=name + ... def change_and_notify(self, value): + ... self.value=value + ... NC.postNotification(SUBJECT_CHANGED, self, info=value) + ... def __str__(self): + ... return self.name + + >>> class Observer: + ... def __init__(self, name): + ... self.name=name + ... + ... def handle_notification(self, notification): + ... print self.name, 'received notification:', str(notification) + ... print ' with info:', notification.userInfo() + ... + >>> s1=Subject('s1') + >>> s2=Subject('s2') + >>> observ1, observ2 = Observer('observ1'), Observer('observ2') + >>> generic = Observer('generic') + + >>> # observ1 listens to SUBJECT_CHANGED posted by s1 + ... NC.addObserver(observ1, Observer.handle_notification, SUBJECT_CHANGED, s1) + >>> # observ2 listens to SUBJECT_CHANGED posted by s2 + ... NC.addObserver(observ2, Observer.handle_notification, SUBJECT_CHANGED, s2) + >>> # generic listens to all SUBJECT_CHANGED notifications + ... NC.addObserver(generic, Observer.handle_notification, SUBJECT_CHANGED) + + + >>> s1.change_and_notify(value='hop') + observ1 received notification: <Notification name:'Subject changed' object:'s1'> + with info: hop + generic received notification: <Notification name:'Subject changed' object:'s1'> + with info: hop + + + >>> s2.change_and_notify(value=3) + observ2 received notification: <Notification name:'Subject changed' object:'s2'> + with info: 3 + generic received notification: <Notification name:'Subject changed' object:'s2'> + with info: 3 + + .. raw:: html + + Hosted by:<a href="http://sourceforge.net"> + <img src="http://sourceforge.net/sflogo.php?group_id=58935&type=1" + width="88" height="31" border="0" alt="SourceForge.net Logo"> + </a> + """ __version__="0.6.1" Index: log.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/log.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** log.py 14 Feb 2004 19:44:11 -0000 1.5 --- log.py 15 Feb 2004 14:03:56 -0000 1.6 *************** *** 26,32 **** Logging methods. ! All methods log(), warn() and trace() are disabled by default. To enable ! them set the environment variable 'NOTIFICATION_FRAMEWORK_TRACE' (for ! debugging purpose mainly) CVS Information --- 26,32 ---- Logging methods. ! All methods `log()`, `warn()` and `trace()` are disabled by default. To ! enable them set the environment variable ``NOTIFICATION_FRAMEWORK_TRACE`` ! (for debugging purpose mainly) CVS Information Index: mems_lib.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/mems_lib.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** mems_lib.py 14 Feb 2004 19:44:11 -0000 1.4 --- mems_lib.py 15 Feb 2004 14:03:56 -0000 1.5 *************** *** 3,16 **** The code in this module is borrowed from the ZODB Programmer's Guide. ! It redefines the python2.1's builtin functions issubclass() and isinstance() ! so that they work properly with extension classes. Versions 2.2 and up of python do not have the problem so the module's ! functions issubclass() and isinstance() are the default ones, unchanged. - Note: this is not indicated in the ZODB Programming Guide anymore, probably - because it's of no use for python2.2 and up. Last time I checked I was able to - find the page I'm referring to at: - http://cvs.zope.org/StandaloneZODB/Doc/guide/zodb/node18.html?rev=1.2 - but this URL might be unavailable at the time you're reading this. So in case it is not available, here is a copy of the comments A.M. Kuchling --- 3,20 ---- The code in this module is borrowed from the ZODB Programmer's Guide. ! It redefines the python2.1's builtin functions ``issubclass()`` and ! ``isinstance()`` so that they work properly with extension classes. Versions 2.2 and up of python do not have the problem so the module's ! functions ``issubclass()`` and ``isinstance()`` are the default ones, ! unchanged. ! ! **Note**: ! ! This is not indicated in the ZODB Programming Guide anymore, ! probably because it's of no use for python2.2 and up. Last time I checked I ! was able to find the page I'm referring to at: ! http://cvs.zope.org/StandaloneZODB/Doc/guide/zodb/node18.html?rev=1.2 but ! this URL might be unavailable at the time you're reading this. So in case it is not available, here is a copy of the comments A.M. Kuchling |
Update of /cvsroot/modeling/NotificationFramework/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16606/tests Modified Files: compare_perfs.py run.py test_Notification.py test_NotificationCenter.py testmodule.py utils.py Log Message: Updated the files to conform to PEP-0263: source encoding is iso-8859-1 Index: compare_perfs.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/tests/compare_perfs.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** compare_perfs.py 26 May 2003 12:24:52 -0000 1.2 --- compare_perfs.py 14 Feb 2004 19:44:12 -0000 1.3 *************** *** 1,7 **** #! /usr/bin/env python #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sebastien Bigaret # # This file is part of the Notification Framework. --- 1,8 ---- #! /usr/bin/env python + # -*- coding: iso-8859-1 -*- #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sébastien Bigaret # # This file is part of the Notification Framework. *************** *** 28,31 **** --- 29,34 ---- """ + __version__='$Revision$'[11:-2] + import os, sys, time import utils Index: run.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/tests/run.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** run.py 26 May 2003 12:24:52 -0000 1.4 --- run.py 14 Feb 2004 19:44:12 -0000 1.5 *************** *** 1,7 **** #!/usr/bin/env python #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sebastien Bigaret # # This file is part of the Notification Framework. --- 1,8 ---- #!/usr/bin/env python + # -*- coding: iso-8859-1 -*- #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sébastien Bigaret # # This file is part of the Notification Framework. *************** *** 24,27 **** --- 25,31 ---- """Run all tests.""" + + __version__='$Revision$'[11:-2] + import os, sys, getopt import utils Index: test_Notification.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/tests/test_Notification.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_Notification.py 1 Feb 2004 10:25:21 -0000 1.6 --- test_Notification.py 14 Feb 2004 19:44:12 -0000 1.7 *************** *** 1,7 **** #! /usr/bin/env python #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sebastien Bigaret # # This file is part of the Notification Framework. --- 1,8 ---- #! /usr/bin/env python + # -*- coding: iso-8859-1 -*- #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sébastien Bigaret # # This file is part of the Notification Framework. *************** *** 25,28 **** --- 26,31 ---- """Test the Notification class""" + __version__='$Revision$'[11:-2] + import unittest, sys import utils Index: test_NotificationCenter.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/tests/test_NotificationCenter.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_NotificationCenter.py 1 Feb 2004 10:25:21 -0000 1.8 --- test_NotificationCenter.py 14 Feb 2004 19:44:12 -0000 1.9 *************** *** 25,28 **** --- 25,30 ---- """Test the Model""" + __version__='$Revision$'[11:-2] + import unittest, os, sys, weakref import utils Index: testmodule.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/tests/testmodule.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** testmodule.py 26 May 2003 12:24:53 -0000 1.3 --- testmodule.py 14 Feb 2004 19:44:12 -0000 1.4 *************** *** 1,6 **** #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sebastien Bigaret # # This file is part of the Notification Framework. --- 1,7 ---- + # -*- coding: iso-8859-1 -*- #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sébastien Bigaret # # This file is part of the Notification Framework. *************** *** 21,24 **** --- 22,26 ---- # #----------------------------------------------------------------------------- + __version__='$Revision$'[11:-2] from threading import RLock Index: utils.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/tests/utils.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** utils.py 26 May 2003 12:24:53 -0000 1.4 --- utils.py 14 Feb 2004 19:44:12 -0000 1.5 *************** *** 1,6 **** #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sebastien Bigaret # # This file is part of the Notification Framework. --- 1,7 ---- + # -*- coding: iso-8859-1 -*- #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sébastien Bigaret # # This file is part of the Notification Framework. *************** *** 25,28 **** --- 26,31 ---- # inspired by TAL tests.utils + __version__='$Revision$'[11:-2] + import os, sys |
From: <sbi...@us...> - 2004-02-14 19:50:52
|
Update of /cvsroot/modeling/NotificationFramework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16606 Modified Files: CHANGES Notification.py NotificationCenter.py log.py mems_lib.py setup.py Log Message: Updated the files to conform to PEP-0263: source encoding is iso-8859-1 Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/CHANGES,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CHANGES 14 Feb 2004 19:41:22 -0000 1.9 --- CHANGES 14 Feb 2004 19:44:11 -0000 1.10 *************** *** 2,5 **** --- 2,7 ---- - Added attribute __version__ to package NotificationFramework + - Updated the files to conform to PEP-0263: source encoding is iso-8859-1 + 0.6.1 [2004/02/01] Index: Notification.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/Notification.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Notification.py 26 May 2003 12:57:20 -0000 1.5 --- Notification.py 14 Feb 2004 19:44:11 -0000 1.6 *************** *** 1,6 **** #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sebastien Bigaret # # This file is part of the Notification Framework. --- 1,7 ---- + # -*- coding: iso-8859-1 -*- #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sébastien Bigaret # # This file is part of the Notification Framework. Index: NotificationCenter.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/NotificationCenter.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** NotificationCenter.py 27 Sep 2003 23:58:12 -0000 1.9 --- NotificationCenter.py 14 Feb 2004 19:44:11 -0000 1.10 *************** *** 1,6 **** #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sebastien Bigaret # # This file is part of the Notification Framework. --- 1,7 ---- + # -*- coding: iso-8859-1 -*- #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sébastien Bigaret # # This file is part of the Notification Framework. Index: log.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/log.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** log.py 26 May 2003 12:57:20 -0000 1.4 --- log.py 14 Feb 2004 19:44:11 -0000 1.5 *************** *** 1,6 **** #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sebastien Bigaret # # This file is part of the Notification Framework. --- 1,7 ---- + # -*- coding: iso-8859-1 -*- #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sébastien Bigaret # # This file is part of the Notification Framework. Index: mems_lib.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/mems_lib.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** mems_lib.py 2 Feb 2004 21:36:14 -0000 1.3 --- mems_lib.py 14 Feb 2004 19:44:11 -0000 1.4 *************** *** 1,2 **** --- 1,3 ---- + # -*- coding: iso-8859-1 -*- """ The code in this module is borrowed from the ZODB Programmer's Guide. Index: setup.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/setup.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** setup.py 2 Feb 2004 21:40:34 -0000 1.12 --- setup.py 14 Feb 2004 19:44:11 -0000 1.13 *************** *** 1,4 **** #!/usr/bin/env python ! # -*- coding: latin-1 -*- #----------------------------------------------------------------------------- # --- 1,4 ---- #!/usr/bin/env python ! # -*- coding: iso-8859-1 -*- #----------------------------------------------------------------------------- # |
From: <sbi...@us...> - 2004-02-14 19:48:06
|
Update of /cvsroot/modeling/NotificationFramework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16027 Modified Files: vertoo.config CHANGES __init__.py Log Message: Added attribute __version__ to package NotificationFramework Index: vertoo.config =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/vertoo.config,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** vertoo.config 1 Feb 2004 12:38:38 -0000 1.2 --- vertoo.config 14 Feb 2004 19:41:22 -0000 1.3 *************** *** 7,10 **** --- 7,12 ---- nf.addAnchors("setup.py", arguments(pattern="version=%Q", format='@normal')) + nf.addAnchors("__init__.py", + arguments(pattern="__version__=%Q", format='@normal')) setSCMInfo(tool="cvs", Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/CHANGES,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CHANGES 2 Feb 2004 21:36:14 -0000 1.8 --- CHANGES 14 Feb 2004 19:41:22 -0000 1.9 *************** *** 1,2 **** --- 1,5 ---- + + - Added attribute __version__ to package NotificationFramework + 0.6.1 [2004/02/01] Index: __init__.py =================================================================== RCS file: /cvsroot/modeling/NotificationFramework/__init__.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** __init__.py 26 May 2003 12:57:20 -0000 1.4 --- __init__.py 14 Feb 2004 19:41:22 -0000 1.5 *************** *** 1,6 **** #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sebastien Bigaret # # This file is part of the Notification Framework. --- 1,7 ---- + # -*- coding: iso-8859-1 -*- #----------------------------------------------------------------------------- # # Notification Framework: "Observer" Design Pattern for python ! # (c) 2001, 2002, 2003 Sébastien Bigaret # # This file is part of the Notification Framework. *************** *** 31,32 **** --- 32,34 ---- It is distributed under the GNU General Public License. """ + __version__="0.6.1" |
From: <sbi...@us...> - 2004-02-14 19:26:27
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11886 Modified Files: test_EditingContext_Global.py Log Message: Fixed: test_12 was failing for SQLite because MDL_TRANSIENT_DB_CONNECTION is no more the default Index: test_EditingContext_Global.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global.py,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** test_EditingContext_Global.py 14 Feb 2004 18:17:21 -0000 1.47 --- test_EditingContext_Global.py 14 Feb 2004 19:19:48 -0000 1.48 *************** *** 1512,1515 **** --- 1512,1522 ---- author_books_model.entityNamed('Writer').attributeNamed('birthday').setExternalType('DATE') + # SQLite specifics: test_12 requires that the framework closes the db + # connection, so that the new context/channel can connect to the db (sqlite + # does not allow concurrent access to the db). + if database_cfg=='SQLite.cfg': + import os + os.environ['MDL_TRANSIENT_DB_CONNECTION']='yes' + utils.enable_model_cache_and_compute() |
From: <sbi...@us...> - 2004-02-14 19:07:06
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8003 Modified Files: test_EditingContext_Global_Inheritance.py Log Message: Fixed: test_03 was failing for SQLite because MDL_TRANSIENT_DB_CONNECTION is no more the default Index: test_EditingContext_Global_Inheritance.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global_Inheritance.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** test_EditingContext_Global_Inheritance.py 14 Feb 2004 18:17:21 -0000 1.22 --- test_EditingContext_Global_Inheritance.py 14 Feb 2004 19:00:28 -0000 1.23 *************** *** 903,906 **** --- 903,914 ---- return DCOracle2.Timestamp(yyyy,mm,dd,h,m,s) DateFrom=OracleDateFrom + + # SQLite specifics: test_03 requires that the framework closes the db + # connection, so that the new context/channel can connect to the db (sqlite + # does not allow concurrent access to the db). + if database_cfg=='SQLite.cfg': + import os + os.environ['MDL_TRANSIENT_DB_CONNECTION']='yes' + utils.enable_model_cache_and_compute() |
From: <sbi...@us...> - 2004-02-14 18:39:11
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2738 Modified Files: ObserverCenter.py Log Message: Conformance to PEP-0263 + internals changed: no more variables or functions whose names are surrounded by dble-underscores (these are normally reserved for python use) Index: ObserverCenter.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ObserverCenter.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ObserverCenter.py 14 Mar 2003 11:40:09 -0000 1.7 --- ObserverCenter.py 14 Feb 2004 18:32:34 -0000 1.8 *************** *** 1,2 **** --- 1,3 ---- + # -*- coding: iso-8859-1 -*- #----------------------------------------------------------------------------- # *************** *** 44,50 **** import weakref, sys ! __observers_wdict__ = weakref.WeakKeyDictionary() # dict[object]=[observers] ! __omniscientObservers__ = [] # omniscient observers ! __alreadyNotifiedObjects__ = weakref.WeakKeyDictionary() # keys only observerCenter_lock=RLock() lock=observerCenter_lock.acquire --- 45,51 ---- import weakref, sys ! __observers_wdict = weakref.WeakKeyDictionary() # dict[object]=[observers] ! __omniscientObservers = [] # omniscient observers ! __alreadyNotifiedObjects = weakref.WeakKeyDictionary() # keys only observerCenter_lock=RLock() lock=observerCenter_lock.acquire *************** *** 52,75 **** ! def __observersForObject__(anObject): """ Private method - do not access directly. Equivalent to public method 'observersForObject()' """ ! observers=__observers_wdict__.get(anObject, []) for observer in observers: if observer() is None: observers.remove(observer) #observers=filter(lambda o:o(), observers) ! #__observers_wdict__[anObject]=observers return [obs() for obs in observers] ! def __setObjectObservers__(anObject, observers): """ Private method - do not access directly. """ ! __observers_wdict__[anObject]=map(weakref.ref, observers) ! def __ensureSubsequentChangeWillBeNotifiedForObject__(anObject): """ Private method - do not access directly. --- 53,76 ---- ! def __observersForObject(anObject): """ Private method - do not access directly. Equivalent to public method 'observersForObject()' """ ! observers=__observers_wdict.get(anObject, []) for observer in observers: if observer() is None: observers.remove(observer) #observers=filter(lambda o:o(), observers) ! #__observers_wdict[anObject]=observers return [obs() for obs in observers] ! def __setObjectObservers(anObject, observers): """ Private method - do not access directly. """ ! __observers_wdict[anObject]=map(weakref.ref, observers) ! def __ensureSubsequentChangeWillBeNotifiedForObject(anObject): """ Private method - do not access directly. *************** *** 80,84 **** #import sys #print 'Ooops %s %s %s'%sys.exc_info() ! #print __alreadyNotifiedObjects__.keys() pass --- 81,85 ---- #import sys #print 'Ooops %s %s %s'%sys.exc_info() ! #print __alreadyNotifiedObjects.keys() pass *************** *** 86,94 **** def removeObjectFromAlreadyNotifiedObjects(object): "Private method - do not access directly." ! del __alreadyNotifiedObjects__[object] else: def removeObjectFromAlreadyNotifiedObjects(object): "Private method - do not access directly." ! del __alreadyNotifiedObjects__[weakref.ref(object)] ## Public API --- 87,95 ---- def removeObjectFromAlreadyNotifiedObjects(object): "Private method - do not access directly." ! del __alreadyNotifiedObjects[object] else: def removeObjectFromAlreadyNotifiedObjects(object): "Private method - do not access directly." ! del __alreadyNotifiedObjects[weakref.ref(object)] ## Public API *************** *** 97,106 **** lock() try: ! observers = __observersForObject__(anObject) if anObserver not in observers: observers.append(anObserver) # add it and reset the 'wasNotified' flag ! __setObjectObservers__(anObject, observers) ! __ensureSubsequentChangeWillBeNotifiedForObject__(anObject) finally: unlock() --- 98,107 ---- lock() try: ! observers = __observersForObject(anObject) if anObserver not in observers: observers.append(anObserver) # add it and reset the 'wasNotified' flag ! __setObjectObservers(anObject, observers) ! __ensureSubsequentChangeWillBeNotifiedForObject(anObject) finally: unlock() *************** *** 111,116 **** try: obs=weakref.ref(anObserver) ! if obs not in __omniscientObservers__: ! __omniscientObservers__.append(obs) finally: unlock() --- 112,117 ---- try: obs=weakref.ref(anObserver) ! if obs not in __omniscientObservers: ! __omniscientObservers.append(obs) finally: unlock() *************** *** 118,124 **** def ensureSubsequentChangeWillBeNotifiedForObject(anObject): "See interfaces.ObserverCenter for details" try: ! lock() ! __ensureSubsequentChangeWillBeNotifiedForObject__(anObject) finally: unlock() --- 119,125 ---- def ensureSubsequentChangeWillBeNotifiedForObject(anObject): "See interfaces.ObserverCenter for details" + lock() try: ! __ensureSubsequentChangeWillBeNotifiedForObject(anObject) finally: unlock() *************** *** 128,144 **** lock() try: ! for omni in map(lambda o: o(), __omniscientObservers__): #trace('Notifying omniscient observer %s'%str(omni)) if omni is not None: omni.objectWillChange(anObject) ! global __alreadyNotifiedObjects__ if anObject is None: ! __alreadyNotifiedObjects__.clear() return ! if __alreadyNotifiedObjects__.get(anObject, 0): return ! observers=__observersForObject__(anObject) for observer in observers: try: --- 129,145 ---- lock() try: ! for omni in map(lambda o: o(), __omniscientObservers): #trace('Notifying omniscient observer %s'%str(omni)) if omni is not None: omni.objectWillChange(anObject) ! global __alreadyNotifiedObjects if anObject is None: ! __alreadyNotifiedObjects.clear() return ! if __alreadyNotifiedObjects.get(anObject, 0): return ! observers=__observersForObject(anObject) for observer in observers: try: *************** *** 147,151 **** except 'truc': # swallow all possible exceptions raise ! __alreadyNotifiedObjects__[anObject]=1 finally: unlock() --- 148,152 ---- except 'truc': # swallow all possible exceptions raise ! __alreadyNotifiedObjects[anObject]=1 finally: unlock() *************** *** 156,160 **** try: # make a copy and returns it ! return tuple(__observersForObject__(anObject)) finally: unlock() --- 157,161 ---- try: # make a copy and returns it ! return tuple(__observersForObject(anObject)) finally: unlock() *************** *** 164,171 **** lock() try: ! observers = __observersForObject__(anObject) try: observers.remove(anObserver) ! __setObjectObservers__(anObject, observers) except: pass --- 165,172 ---- lock() try: ! observers = __observersForObject(anObject) try: observers.remove(anObserver) ! __setObjectObservers(anObject, observers) except: pass *************** *** 177,181 **** lock() try: ! __omniscientObservers__.remove(weakref.ref(anObserver)) finally: unlock() --- 178,182 ---- lock() try: ! __omniscientObservers.remove(weakref.ref(anObserver)) finally: unlock() |
From: <sbi...@us...> - 2004-02-14 18:37:10
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2408 Modified Files: ClassDescription.py Log Message: Conformance to PEP-0263 Index: ClassDescription.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ClassDescription.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ClassDescription.py 24 Jul 2003 11:11:34 -0000 1.13 --- ClassDescription.py 14 Feb 2004 18:30:33 -0000 1.14 *************** *** 1,2 **** --- 1,3 ---- + # -*- coding: iso-8859-1 -*- #----------------------------------------------------------------------------- # |