modeling-cvs Mailing List for Object-Relational Bridge for python (Page 17)
Status: Abandoned
Brought to you by:
sbigaret
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
(54) |
Apr
(29) |
May
(94) |
Jun
(47) |
Jul
(156) |
Aug
(132) |
Sep
(40) |
Oct
(6) |
Nov
(18) |
Dec
(24) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(18) |
Feb
(59) |
Mar
(7) |
Apr
|
May
(8) |
Jun
(2) |
Jul
(12) |
Aug
(15) |
Sep
(12) |
Oct
(6) |
Nov
(25) |
Dec
(1) |
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
(27) |
Mar
|
Apr
(16) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <sbi...@us...> - 2003-08-03 13:58:15
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks In directory sc8-pr-cvs1:/tmp/cvs-serv21021/ModelMasons/Python_bricks Modified Files: module_compact.tmpl Log Message: Added header "Generated by ..." Index: module_compact.tmpl =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelMasons/Python_bricks/module_compact.tmpl,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** module_compact.tmpl 20 Apr 2003 16:10:40 -0000 1.1 --- module_compact.tmpl 3 Aug 2003 13:58:10 -0000 1.2 *************** *** 1,4 **** ## This template will build the module ! # Modeling #set $custom = 1 #for entity in $entities: --- 1,5 ---- ## This template will build the module ! #import time ! # Generated by mdl_generate_python_code.py / $(time.strftime("%Y/%m/%d %H:%M")) #set $custom = 1 #for entity in $entities: |
From: <sbi...@us...> - 2003-08-03 12:57:26
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests/testPackages/AuthorBooks In directory sc8-pr-cvs1:/tmp/cvs-serv9795/tests/testPackages/AuthorBooks Modified Files: pymodel_AuthorBooks.py Log Message: Changed to be in sync w/ .xml: Book.FK_Writer_Id has been made a class prop Index: pymodel_AuthorBooks.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/testPackages/AuthorBooks/pymodel_AuthorBooks.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pymodel_AuthorBooks.py 3 Aug 2003 12:21:41 -0000 1.5 --- pymodel_AuthorBooks.py 3 Aug 2003 12:57:23 -0000 1.6 *************** *** 36,40 **** columnName='id'), AString('title', isRequired=1, columnName='title'), ! AFloat('price'), ], ), Entity('Writer', --- 36,42 ---- columnName='id'), AString('title', isRequired=1, columnName='title'), ! AFloat('price'), ! AForeignKey('FK_Writer_Id', isClassProperty=1), ! ], ), Entity('Writer', |
From: <sbi...@us...> - 2003-08-03 12:56:13
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv9652 Modified Files: Model.py Log Message: loadModel() builds a pymodel only if it has been previously built Index: Model.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Model.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Model.py 31 Jul 2003 17:11:12 -0000 1.11 --- Model.py 3 Aug 2003 12:56:10 -0000 1.12 *************** *** 130,133 **** --- 130,134 ---- 2. 'pymodel' (id.): if found, we assume this is an instance of Modeling.PyModel.Model and we return its 'component' attribute + If the PyModel has not been built yet, it is build() here. 3. 'model_src' (id.): if found, we assume this is a string and return *************** *** 166,170 **** import PyModel if isinstance(model, PyModel.Model): ! model.build() model=model.component updateModelWithCFG(model) --- 167,172 ---- import PyModel if isinstance(model, PyModel.Model): ! if not model.is_built: ! model.build() model=model.component updateModelWithCFG(model) |
From: <sbi...@us...> - 2003-08-03 12:54:51
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv9470 Modified Files: PyModel.py Log Message: PyModel can be built once, at most Index: PyModel.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/PyModel.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyModel.py 24 Jul 2003 12:14:04 -0000 1.3 --- PyModel.py 3 Aug 2003 12:54:48 -0000 1.4 *************** *** 120,123 **** --- 120,124 ---- def __init__(self, name, **kw): + self.is_built=0 self.name=self.requiredField(name) self.entities=list(kw.get('entities', [])) *************** *** 177,180 **** --- 178,186 ---- if getattr(self, 'version', None)!=BaseDescription.VERSION: raise ValueError, 'Incompatible versions' + + # + if self.is_built: + raise RuntimeError, 'PyModel has already been built' + self.is_built=1 # Build ordered list of entities |
From: <sbi...@us...> - 2003-08-03 12:54:12
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests In directory sc8-pr-cvs1:/tmp/cvs-serv9389 Modified Files: test_PyModel.py Log Message: Added test: PyModel can be built once, at most Index: test_PyModel.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_PyModel.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_PyModel.py 3 Aug 2003 12:50:52 -0000 1.4 --- test_PyModel.py 3 Aug 2003 12:54:09 -0000 1.5 *************** *** 455,458 **** --- 455,471 ---- RToOne.defaults['delete']=toMany_def_delete + def test_09_cannot_rebuild(self): + "[PyModel] build() should be called once, no more" + model = self.model + model.entities = [ + Entity('Employee', + properties=[ AString('lastName'), + AString('firstName'), + ] ), + ] + model.build() + self.failUnless(model.is_built) + self.assertRaises(RuntimeError, model.build) + def test_suite(): suite = unittest.TestSuite() |
From: <sbi...@us...> - 2003-08-03 12:50:54
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests In directory sc8-pr-cvs1:/tmp/cvs-serv8890 Modified Files: test_PyModel.py Log Message: Updated tests for pk Index: test_PyModel.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_PyModel.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_PyModel.py 23 Jul 2003 11:23:58 -0000 1.3 --- test_PyModel.py 3 Aug 2003 12:50:52 -0000 1.4 *************** *** 151,162 **** "[PyModel] entity w/ pk" model = self.model model.entities = [ Entity('Employee', ! properties=[ APrimaryKey('ID', isClassProperty=1, isRequired=1, doc='SalesClerk PK') ] ), ] model.build() emp=model.component.entityNamed('Employee') self.checkEntitiesProperties((emp,)) ! self.assertEqual(emp.primaryKeyAttributeNames(), ['ID']) self.failUnless(emp.primaryKeyAttributes()[0].isClassProperty()) self.assertEqual(emp.primaryKeyAttributes()[0].defaultValue(), 0) --- 151,164 ---- "[PyModel] entity w/ pk" model = self.model + # we also use the same name 'id' model.entities = [ Entity('Employee', ! properties=[ APrimaryKey('id', isClassProperty=1, isRequired=1, doc='SalesClerk PK') ] ), ] model.build() emp=model.component.entityNamed('Employee') self.checkEntitiesProperties((emp,)) ! self.assertEqual(emp.primaryKeyAttributeNames(), ['id']) ! self.assertEqual(emp.primaryKeyAttributes()[0].comment(), 'SalesClerk PK') self.failUnless(emp.primaryKeyAttributes()[0].isClassProperty()) self.assertEqual(emp.primaryKeyAttributes()[0].defaultValue(), 0) |
From: <sbi...@us...> - 2003-08-03 12:50:01
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests In directory sc8-pr-cvs1:/tmp/cvs-serv8701 Modified Files: test_generate_python_code.sh Log Message: misc. Index: test_generate_python_code.sh =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_generate_python_code.sh,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_generate_python_code.sh 9 Jul 2003 11:42:41 -0000 1.3 --- test_generate_python_code.sh 3 Aug 2003 12:49:58 -0000 1.4 *************** *** 4,8 **** GENERATE=../scripts/mdl_generate_python_code.py RMDIR='/bin/rm -rf' ! PYTHON=/usr/local/bin/python tests_dir=`pwd` --- 4,8 ---- GENERATE=../scripts/mdl_generate_python_code.py RMDIR='/bin/rm -rf' ! PYTHON=python2.2 tests_dir=`pwd` |
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests/xmlmodels In directory sc8-pr-cvs1:/tmp/cvs-serv8307/xmlmodels Modified Files: model_StoreEmployees.xml model_StoreEmployees2.xml model_StoreEmployees3.xml pymodel_StoreEmployees2.py pymodel_StoreEmployees3.py Log Message: Updated: 0.9pre11 has added entity Holidays to the model, plus a tomany rel. Employee-->Holidays having no inverse, but these models were not updated. Index: model_StoreEmployees.xml =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/xmlmodels/model_StoreEmployees.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** model_StoreEmployees.xml 26 May 2003 15:44:50 -0000 1.2 --- model_StoreEmployees.xml 3 Aug 2003 12:48:19 -0000 1.3 *************** *** 23,26 **** --- 23,29 ---- <join sourceAttribute='fkStoreId' destinationAttribute='id'/> </relation> + <relation deleteRule='0' isClassProperty='1' multiplicityUpperBound='-1' multiplicityLowerBound='0' destinationEntity='Holidays' name='holidays' displayLabel='' joinSemantic='0'> + <join sourceAttribute='id' destinationAttribute='fkEmployeeId'/> + </relation> </entity> <entity isReadOnly='0' isAbstract='0' name='Address' parentEntity='' moduleName='Address' className='Address' typeName='' externalName='ADDRESS'> *************** *** 50,53 **** --- 53,59 ---- <join sourceAttribute='fkStoreId' destinationAttribute='id'/> </relation> + <relation deleteRule='0' isClassProperty='1' multiplicityUpperBound='-1' multiplicityLowerBound='0' destinationEntity='Holidays' name='holidays' displayLabel='' joinSemantic='0'> + <join sourceAttribute='id' destinationAttribute='fkEmployeeId'/> + </relation> </entity> <entity isReadOnly='0' isAbstract='0' name='Executive' parentEntity='Employee' moduleName='Executive' className='Executive' typeName='' externalName='EXECUTIVE'> *************** *** 69,72 **** --- 75,81 ---- <join sourceAttribute='id' destinationAttribute='FK_Executive_id'/> </relation> + <relation deleteRule='0' isClassProperty='1' multiplicityUpperBound='-1' multiplicityLowerBound='0' destinationEntity='Holidays' name='holidays' displayLabel='' joinSemantic='0'> + <join sourceAttribute='id' destinationAttribute='fkEmployeeId'/> + </relation> </entity> <entity isReadOnly='0' isAbstract='0' name='Mark' parentEntity='' moduleName='Mark' className='Mark' typeName='' externalName='MARK'> *************** *** 79,82 **** --- 88,98 ---- <join sourceAttribute='FK_Executive_id' destinationAttribute='id'/> </relation> + </entity> + <entity isReadOnly='0' isAbstract='0' name='Holidays' parentEntity='' moduleName='Holidays' className='Holidays' typeName='' externalName='HOLIDAYS'> + <primaryKey attributeName='id'/> + <attribute isClassProperty='0' width='0' columnName='ID' isRequired='1' precision='0' defaultValue='None' externalType='INTEGER' name='id' scale='0' type='int' displayLabel=''/> + <attribute isClassProperty='1' width='0' columnName='START_DATE' isRequired='1' precision='0' defaultValue='None' externalType='TIMESTAMP' name='startDate' scale='0' type='DateTime' displayLabel=''/> + <attribute isClassProperty='1' width='0' columnName='END_DATE' isRequired='1' precision='0' defaultValue='None' externalType='TIMESTAMP' name='endDate' scale='0' type='DateTime' displayLabel=''/> + <attribute isClassProperty='0' width='0' columnName='FK_EMPLOYEE_ID' isRequired='0' precision='0' defaultValue='None' externalType='INTEGER' name='fkEmployeeId' scale='0' type='int' displayLabel=''/> </entity> </model> Index: model_StoreEmployees2.xml =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/xmlmodels/model_StoreEmployees2.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** model_StoreEmployees2.xml 8 Jul 2003 16:03:58 -0000 1.1 --- model_StoreEmployees2.xml 3 Aug 2003 12:48:19 -0000 1.2 *************** *** 23,26 **** --- 23,29 ---- <join sourceAttribute='fkStoreId' destinationAttribute='id'/> </relation> + <relation deleteRule='0' isClassProperty='1' multiplicityUpperBound='-1' multiplicityLowerBound='0' destinationEntity='Holidays' name='holidays' displayLabel='' joinSemantic='0'> + <join sourceAttribute='id' destinationAttribute='fkEmployeeId'/> + </relation> </entity> <entity isReadOnly='0' isAbstract='0' name='Address' parentEntity='' moduleName='Address' className='Address' typeName='' externalName='ADDRESS'> *************** *** 50,53 **** --- 53,59 ---- <join sourceAttribute='fkStoreId' destinationAttribute='id'/> </relation> + <relation deleteRule='0' isClassProperty='1' multiplicityUpperBound='-1' multiplicityLowerBound='0' destinationEntity='Holidays' name='holidays' displayLabel='' joinSemantic='0'> + <join sourceAttribute='id' destinationAttribute='fkEmployeeId'/> + </relation> </entity> <entity isReadOnly='0' isAbstract='0' name='Executive' parentEntity='Employee' moduleName='Employees' className='Executive' typeName='' externalName='EXECUTIVE'> *************** *** 69,72 **** --- 75,81 ---- <join sourceAttribute='id' destinationAttribute='FK_Executive_id'/> </relation> + <relation deleteRule='0' isClassProperty='1' multiplicityUpperBound='-1' multiplicityLowerBound='0' destinationEntity='Holidays' name='holidays' displayLabel='' joinSemantic='0'> + <join sourceAttribute='id' destinationAttribute='fkEmployeeId'/> + </relation> </entity> <entity isReadOnly='0' isAbstract='0' name='Mark' parentEntity='' moduleName='Mark' className='Mark' typeName='' externalName='MARK'> *************** *** 79,82 **** --- 88,98 ---- <join sourceAttribute='FK_Executive_id' destinationAttribute='id'/> </relation> + </entity> + <entity isReadOnly='0' isAbstract='0' name='Holidays' parentEntity='' moduleName='Holidays' className='Holidays' typeName='' externalName='HOLIDAYS'> + <primaryKey attributeName='id'/> + <attribute isClassProperty='0' width='0' columnName='ID' isRequired='1' precision='0' defaultValue='None' externalType='INTEGER' name='id' scale='0' type='int' displayLabel=''/> + <attribute isClassProperty='1' width='0' columnName='START_DATE' isRequired='1' precision='0' defaultValue='None' externalType='TIMESTAMP' name='startDate' scale='0' type='DateTime' displayLabel=''/> + <attribute isClassProperty='1' width='0' columnName='END_DATE' isRequired='1' precision='0' defaultValue='None' externalType='TIMESTAMP' name='endDate' scale='0' type='DateTime' displayLabel=''/> + <attribute isClassProperty='0' width='0' columnName='FK_EMPLOYEE_ID' isRequired='0' precision='0' defaultValue='None' externalType='INTEGER' name='fkEmployeeId' scale='0' type='int' displayLabel=''/> </entity> </model> Index: model_StoreEmployees3.xml =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/xmlmodels/model_StoreEmployees3.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** model_StoreEmployees3.xml 8 Jul 2003 16:03:58 -0000 1.1 --- model_StoreEmployees3.xml 3 Aug 2003 12:48:19 -0000 1.2 *************** *** 23,26 **** --- 23,29 ---- <join sourceAttribute='fkStoreId' destinationAttribute='id'/> </relation> + <relation deleteRule='0' isClassProperty='1' multiplicityUpperBound='-1' multiplicityLowerBound='0' destinationEntity='Holidays' name='holidays' displayLabel='' joinSemantic='0'> + <join sourceAttribute='id' destinationAttribute='fkEmployeeId'/> + </relation> </entity> <entity isReadOnly='0' isAbstract='0' name='Address' parentEntity='' moduleName='Address' className='Address' typeName='' externalName='ADDRESS'> *************** *** 50,53 **** --- 53,59 ---- <join sourceAttribute='fkStoreId' destinationAttribute='id'/> </relation> + <relation deleteRule='0' isClassProperty='1' multiplicityUpperBound='-1' multiplicityLowerBound='0' destinationEntity='Holidays' name='holidays' displayLabel='' joinSemantic='0'> + <join sourceAttribute='id' destinationAttribute='fkEmployeeId'/> + </relation> </entity> <entity isReadOnly='0' isAbstract='0' name='Executive' parentEntity='Employee' moduleName='Employees' className='Executive' typeName='' externalName='EXECUTIVE'> *************** *** 69,72 **** --- 75,81 ---- <join sourceAttribute='id' destinationAttribute='FK_Executive_id'/> </relation> + <relation deleteRule='0' isClassProperty='1' multiplicityUpperBound='-1' multiplicityLowerBound='0' destinationEntity='Holidays' name='holidays' displayLabel='' joinSemantic='0'> + <join sourceAttribute='id' destinationAttribute='fkEmployeeId'/> + </relation> </entity> <entity isReadOnly='0' isAbstract='0' name='Mark' parentEntity='' moduleName='Mark' className='Mark' typeName='' externalName='MARK'> *************** *** 79,82 **** --- 88,98 ---- <join sourceAttribute='FK_Executive_id' destinationAttribute='id'/> </relation> + </entity> + <entity isReadOnly='0' isAbstract='0' name='Holidays' parentEntity='' moduleName='Holidays' className='Holidays' typeName='' externalName='HOLIDAYS'> + <primaryKey attributeName='id'/> + <attribute isClassProperty='0' width='0' columnName='ID' isRequired='1' precision='0' defaultValue='None' externalType='INTEGER' name='id' scale='0' type='int' displayLabel=''/> + <attribute isClassProperty='1' width='0' columnName='START_DATE' isRequired='1' precision='0' defaultValue='None' externalType='TIMESTAMP' name='startDate' scale='0' type='DateTime' displayLabel=''/> + <attribute isClassProperty='1' width='0' columnName='END_DATE' isRequired='1' precision='0' defaultValue='None' externalType='TIMESTAMP' name='endDate' scale='0' type='DateTime' displayLabel=''/> + <attribute isClassProperty='0' width='0' columnName='FK_EMPLOYEE_ID' isRequired='0' precision='0' defaultValue='None' externalType='INTEGER' name='fkEmployeeId' scale='0' type='int' displayLabel=''/> </entity> </model> Index: pymodel_StoreEmployees2.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/xmlmodels/pymodel_StoreEmployees2.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pymodel_StoreEmployees2.py 7 Jul 2003 14:57:15 -0000 1.2 --- pymodel_StoreEmployees2.py 3 Aug 2003 12:48:19 -0000 1.3 *************** *** 59,63 **** AInteger('mark', isRequired=1), ] ! ) ] model.associations=[ --- 59,68 ---- AInteger('mark', isRequired=1), ] ! ), ! Entity('Holidays', ! properties=[ ADateTime('startDate', isRequired=1), ! ADateTime('endDate', isRequired=1), ! ] ! ), ] model.associations=[ *************** *** 75,78 **** --- 80,87 ---- delete=['nullify', 'deny'], keys=['fkStoreId', 'id']), + Association('Holidays', 'Employee', + relations=[None, 'holidays'], + delete=[None, 'cascade'], + keys=['fkEmployeeId', 'id']), ] Index: pymodel_StoreEmployees3.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/xmlmodels/pymodel_StoreEmployees3.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pymodel_StoreEmployees3.py 7 Jul 2003 14:57:15 -0000 1.2 --- pymodel_StoreEmployees3.py 3 Aug 2003 12:48:19 -0000 1.3 *************** *** 60,64 **** AInteger('mark', isRequired=1), ] ! ) ] model.associations=[ --- 60,69 ---- AInteger('mark', isRequired=1), ] ! ), ! Entity('Holidays', ! properties=[ ADateTime('startDate', isRequired=1), ! ADateTime('endDate', isRequired=1), ! ] ! ), ] model.associations=[ *************** *** 76,79 **** --- 81,88 ---- delete=['nullify', 'deny'], keys=['fkStoreId', 'id']), + Association('Holidays', 'Employee', + relations=[None, 'holidays'], + delete=[None, 'cascade'], + keys=['fkEmployeeId', 'id']), ] |
From: <sbi...@us...> - 2003-08-03 12:21:45
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests/testPackages/AuthorBooks In directory sc8-pr-cvs1:/tmp/cvs-serv4154/testPackages/AuthorBooks Modified Files: pymodel_AuthorBooks.py Log Message: Fixed fk name in Writer (out of sync w/ .xml) Index: pymodel_AuthorBooks.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/testPackages/AuthorBooks/pymodel_AuthorBooks.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pymodel_AuthorBooks.py 24 Jul 2003 16:45:50 -0000 1.4 --- pymodel_AuthorBooks.py 3 Aug 2003 12:21:41 -0000 1.5 *************** *** 8,12 **** from Modeling.PyModel import * - raise 'do not use' ## --- 8,11 ---- *************** *** 59,63 **** relations=['pygmalion', None], delete=['nullify', None], ! keys=['FK_Writer_Id', 'id']), ] --- 58,62 ---- relations=['pygmalion', None], delete=['nullify', None], ! keys=['FK_Writer_id', 'id']), ] |
From: <sbi...@us...> - 2003-08-03 11:15:55
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests In directory sc8-pr-cvs1:/tmp/cvs-serv26719/tests Modified Files: test_EditingContext_Global_Inheritance.py Log Message: Updated tests for snapshot_raw Index: test_EditingContext_Global_Inheritance.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global_Inheritance.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** test_EditingContext_Global_Inheritance.py 28 Jul 2003 06:53:33 -0000 1.18 --- test_EditingContext_Global_Inheritance.py 3 Aug 2003 11:15:39 -0000 1.19 *************** *** 693,698 **** --- 693,702 ---- # Not computed before saveChanges() + self.failUnless(holidays.snapshot_raw().has_key('fkEmployeeId')) self.assertEqual(holidays.snapshot_raw()['fkEmployeeId'], None) ec.saveChanges() + #print holidays.snapshot_raw() + # We check here that snapshot_raw() is able to find the value + # for the FK by examining the database's cache. self.assertEqual(holidays.snapshot_raw()['fkEmployeeId'], emp.globalID().keyValues()['id']) *************** *** 702,708 **** --- 706,714 ---- self._test_10_class_employee=Employee.Employee self._test_13_toMany_with_no_inverse__snapshot_row() + self._test_10_class_employee=SalesClerk self._test_13_toMany_with_no_inverse__snapshot_row() + def tearDown(self): """ |
From: <sbi...@us...> - 2003-08-03 11:13:52
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests In directory sc8-pr-cvs1:/tmp/cvs-serv26524/tests Modified Files: MySQL.cfg Postgresql.cfg Log Message: Added 'database' entry for model AuthorBooks and StoreEmployees, or the tests failed when MDL_DB_CONNECTIONS_CFG points to SQLite.cfg Index: MySQL.cfg =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/MySQL.cfg,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MySQL.cfg 7 May 2003 11:27:10 -0000 1.1 --- MySQL.cfg 3 Aug 2003 11:13:49 -0000 1.2 *************** *** 10,14 **** --- 10,16 ---- [AuthorBooks] + database: ADDRESS_BOOK [StoreEmployees] + database: STORE_EMPLOYEES Index: Postgresql.cfg =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/Postgresql.cfg,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Postgresql.cfg 7 May 2003 11:27:10 -0000 1.1 --- Postgresql.cfg 3 Aug 2003 11:13:49 -0000 1.2 *************** *** 10,14 **** --- 10,16 ---- [AuthorBooks] + database: AUTHOR_BOOKS [StoreEmployees] + database: STORE_EMPLOYEES |
From: <sbi...@us...> - 2003-08-03 11:10:52
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/PostgresqlAdaptorLayer In directory sc8-pr-cvs1:/tmp/cvs-serv26209/DatabaseAdaptors/PostgresqlAdaptorLayer Modified Files: __init__.py Log Message: Updated docstring Index: __init__.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/PostgresqlAdaptorLayer/__init__.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** __init__.py 27 Jan 2003 16:21:17 -0000 1.2 --- __init__.py 3 Aug 2003 11:10:50 -0000 1.3 *************** *** 27,36 **** This package is for use by the core to interact with PostgreSQL databases. ! Two different low-level DB-adaptors, conforming to the python DB-API 2.0, ! can be used: - 'psycopg', if available, will be used, ! - otherwise, 'pgdb' is used. """ --- 27,52 ---- This package is for use by the core to interact with PostgreSQL databases. ! Three different low-level DB-adaptors, conforming to the python DB-API 2.0, ! can be used, and by default theyu are searched in the following order: - 'psycopg', if available, will be used, ! - then 'pygresql' (pgdb), if available, is used, ! ! - otherwise, 'PyPgSQL' is searched and used. ! ! If more than one of these adaptors are installed, you can set the ! environment variable 'MDL_PREFERRED_PYTHON_POSTGRESQL_ADAPTOR' to either ! 'psycopg', 'pgdb' or 'pypgsql' to indicate your preference. ! ! Model & Connection Dictionaries: ! ! 'adaptorName' -- should be 'Postgresql' ! ! 'database' -- the name of the database ! ! 'host' -- where the pg server is hosted ! ! 'user', 'password' -- user credentials """ |
From: <sbi...@us...> - 2003-08-03 11:10:52
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer In directory sc8-pr-cvs1:/tmp/cvs-serv26209/DatabaseAdaptors/MySQLAdaptorLayer Modified Files: __init__.py Log Message: Updated docstring Index: __init__.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer/__init__.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** __init__.py 27 Jan 2003 16:21:16 -0000 1.2 --- __init__.py 3 Aug 2003 11:10:49 -0000 1.3 *************** *** 31,34 **** --- 31,44 ---- - 'MySQL-python', v0.9.2' + Model & Connection Dictionaries: + + 'adaptorName' -- should be 'MySQL' + + 'database' -- the name of the database + + 'host' -- where the mysql server is hosted + + 'user', 'password' -- user credentials + """ |
From: <sbi...@us...> - 2003-08-03 10:59:45
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide In directory sc8-pr-cvs1:/tmp/cvs-serv24676/doc/UserGuide Modified Files: ManipulatingGraphOfObjects.tex Log Message: Misc. fix Index: ManipulatingGraphOfObjects.tex =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/ManipulatingGraphOfObjects.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ManipulatingGraphOfObjects.tex 24 Jul 2003 12:07:25 -0000 1.16 --- ManipulatingGraphOfObjects.tex 3 Aug 2003 10:59:42 -0000 1.17 *************** *** 480,484 **** \begin{verbatim} ! >>> gargantua=ec.fetch('Book', 'title == "Gargantua"')[0] >>> pprint.pprint([b.getTitle() for b in ec.fetch('Book')]) ['Bouge ton pied que je voie la mer', --- 480,484 ---- \begin{verbatim} ! >>> ec.delete(gargantua) >>> pprint.pprint([b.getTitle() for b in ec.fetch('Book')]) ['Bouge ton pied que je voie la mer', |
From: <sbi...@us...> - 2003-08-03 10:53:29
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/HomePage In directory sc8-pr-cvs1:/tmp/cvs-serv23951/doc/HomePage Modified Files: main.tex Log Message: mysql v4.x is also supported Index: main.tex =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/HomePage/main.tex,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** main.tex 28 Jul 2003 18:27:36 -0000 1.21 --- main.tex 3 Aug 2003 10:53:26 -0000 1.22 *************** *** 115,119 **** \end{rawhtml} ! \item[\begin{rawhtml}<a href="http://www.mysql.com/">MySQL</a>\end{rawhtml}] tested with v3.23.52 Supported python adaptor: --- 115,120 ---- \end{rawhtml} ! \item[\begin{rawhtml}<a href="http://www.mysql.com/">MySQL</a>\end{rawhtml}] ! tested with v3.23.52 and v4.0.13 Supported python adaptor: |
From: <sbi...@us...> - 2003-08-03 10:34:18
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests In directory sc8-pr-cvs1:/tmp/cvs-serv21866/tests Modified Files: test_SQLExpression.py Log Message: Fixed bug #780495: when ec.fetch() is joining two tables or more, the returned set of objects could have duplicates. Index: test_SQLExpression.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_SQLExpression.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_SQLExpression.py 14 Mar 2003 11:40:13 -0000 1.6 --- test_SQLExpression.py 3 Aug 2003 10:34:15 -0000 1.7 *************** *** 167,171 **** lock=0, fetchSpec=fs) self.assertEqual(sqlExpr.statement(), ! "SELECT t0.id, t0.title, t0.FK_WRITER_ID, t0.PRICE FROM BOOK t0 INNER JOIN ( WRITER t1 INNER JOIN WRITER t2 ON t1.FK_WRITER_ID=t2.ID ) ON t0.FK_WRITER_ID=t1.ID WHERE t2.LAST_NAME = 'Rabelais'") # None/NULL value --- 167,171 ---- lock=0, fetchSpec=fs) self.assertEqual(sqlExpr.statement(), ! "SELECT DISTINCT t0.id, t0.title, t0.FK_WRITER_ID, t0.PRICE FROM BOOK t0 INNER JOIN ( WRITER t1 INNER JOIN WRITER t2 ON t1.FK_WRITER_ID=t2.ID ) ON t0.FK_WRITER_ID=t1.ID WHERE t2.LAST_NAME = 'Rabelais'") # None/NULL value *************** *** 176,180 **** lock=0, fetchSpec=fs) self.assertEqual(sqlExpr.statement(), ! "SELECT t0.id, t0.title, t0.FK_WRITER_ID, t0.PRICE, t0.id, t0.title, t0.FK_WRITER_ID, t0.PRICE FROM BOOK t0 INNER JOIN ( WRITER t1 INNER JOIN ( WRITER t2 INNER JOIN BOOK t3 ON t2.ID=t3.FK_WRITER_ID ) ON t1.FK_WRITER_ID=t2.ID ) ON t0.FK_WRITER_ID=t1.ID WHERE t3.PRICE IS NULL") def test_07_prepareSelectExpressionWithAttributes_02(self): --- 176,180 ---- lock=0, fetchSpec=fs) self.assertEqual(sqlExpr.statement(), ! "SELECT DISTINCT t0.id, t0.title, t0.FK_WRITER_ID, t0.PRICE, t0.id, t0.title, t0.FK_WRITER_ID, t0.PRICE FROM BOOK t0 INNER JOIN ( WRITER t1 INNER JOIN ( WRITER t2 INNER JOIN BOOK t3 ON t2.ID=t3.FK_WRITER_ID ) ON t1.FK_WRITER_ID=t2.ID ) ON t0.FK_WRITER_ID=t1.ID WHERE t3.PRICE IS NULL") def test_07_prepareSelectExpressionWithAttributes_02(self): *************** *** 189,193 **** fetchSpec=fetchSpec) self.assertEqual(sqlExpr.statement(), ! "SELECT t0.id, t0.title, t0.FK_WRITER_ID, t0.PRICE FROM BOOK t0 INNER JOIN ( WRITER t1 INNER JOIN WRITER t2 ON t1.FK_WRITER_ID=t2.ID ) ON t0.FK_WRITER_ID=t1.ID WHERE t2.LAST_NAME = t1.LAST_NAME") def test_suite(): --- 189,193 ---- fetchSpec=fetchSpec) self.assertEqual(sqlExpr.statement(), ! "SELECT DISTINCT t0.id, t0.title, t0.FK_WRITER_ID, t0.PRICE FROM BOOK t0 INNER JOIN ( WRITER t1 INNER JOIN WRITER t2 ON t1.FK_WRITER_ID=t2.ID ) ON t0.FK_WRITER_ID=t1.ID WHERE t2.LAST_NAME = t1.LAST_NAME") def test_suite(): |
From: <sbi...@us...> - 2003-08-03 10:34:17
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/PostgresqlAdaptorLayer In directory sc8-pr-cvs1:/tmp/cvs-serv21866/DatabaseAdaptors/PostgresqlAdaptorLayer Modified Files: PostgresqlSQLExpression.py Log Message: Fixed bug #780495: when ec.fetch() is joining two tables or more, the returned set of objects could have duplicates. Index: PostgresqlSQLExpression.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/PostgresqlAdaptorLayer/PostgresqlSQLExpression.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PostgresqlSQLExpression.py 24 Jul 2003 12:07:25 -0000 1.5 --- PostgresqlSQLExpression.py 3 Aug 2003 10:34:14 -0000 1.6 *************** *** 92,95 **** --- 92,114 ---- return attribute.externalType() + def _prepareSelectExpressionWithAttributes(self, attributes, lock, + fetchSpec, count=0): + """ + Overrides the default behaviour and add the necessary + 'AS DISTINCT_ROWS' required by postgresql when dealing with sub-queries. + + This happens when parameter count is true (e.g. when + EditingContext.fetchCount() is called) and that the query corresponding + to fetchSpec implies that two tables or more are joined. + + """ + SQLExpression._prepareSelectExpressionWithAttributes(self, + attributes, lock, + fetchSpec, count) + if count: + select_distinct='SELECT COUNT(*) FROM ( SELECT DISTINCT ' + if self._statement[:len(select_distinct)]==select_distinct: + self._statement=self._statement+' AS DISTINCT_ROWS' + def sqlPatternFromShellPatternWithEscapeCharacter(self, pattern, escapeChar): """ |
From: <sbi...@us...> - 2003-08-03 10:34:17
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv21866 Modified Files: CHANGES SQLExpression.py Log Message: Fixed bug #780495: when ec.fetch() is joining two tables or more, the returned set of objects could have duplicates. Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v retrieving revision 1.142 retrieving revision 1.143 diff -C2 -d -r1.142 -r1.143 *** CHANGES 2 Aug 2003 11:14:57 -0000 1.142 --- CHANGES 3 Aug 2003 10:34:14 -0000 1.143 *************** *** 8,11 **** --- 8,14 ---- -------------------------------------------------------- + * Fixed bug #780495: when ec.fetch() is joining two tables or more, the + returned set of objects could have duplicates. + * Fixed bug #774989: improper result returned by CustomObject.snapshot() wrt tomany relationships --see CustomObject.snapshot() documentation for Index: SQLExpression.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/SQLExpression.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** SQLExpression.py 2 Aug 2003 09:40:49 -0000 1.20 --- SQLExpression.py 3 Aug 2003 10:34:14 -0000 1.21 *************** *** 765,769 **** lockClause='' if lock: ! raise 'Unimplemented', 'lock is not implemented yet' for attribute in attributes: --- 765,769 ---- lockClause='' if lock: ! raise NotImplementedError, 'lock is not implemented yet' for attribute in attributes: *************** *** 775,779 **** self._entity.restrictingQualifier() is not None: # TBD ! raise 'Unimplemented', \ "fetchSpec and/or entity's restrictingQualifier is not None" --- 775,779 ---- self._entity.restrictingQualifier() is not None: # TBD ! raise NotImplementedError, \ "fetchSpec and/or entity's restrictingQualifier is not None" *************** *** 798,802 **** --- 798,806 ---- joinClause='' + # Do we join some tables? + multiple_tables_joined=len(self.entityExternalNamesByAliases())>1 selectString='' + if multiple_tables_joined: + selectString='SELECT DISTINCT ' fetchOrder=None whereClause=self.whereClauseString() *************** *** 804,808 **** orderByClause='' ! if count: columnList=' COUNT(*) ' else: --- 808,812 ---- orderByClause='' ! if count and not multiple_tables_joined: columnList=' COUNT(*) ' else: *************** *** 820,824 **** orderByClause=orderByClause, lockClause=lockClause) ! def prepareSelectCountExpressionWithAttributes(self, --- 824,829 ---- orderByClause=orderByClause, lockClause=lockClause) ! if count and multiple_tables_joined: ! self._statement='SELECT COUNT(*) FROM ( '+self._statement+' )' def prepareSelectCountExpressionWithAttributes(self, *************** *** 1015,1019 **** """ if not self.useAliases(): ! raise 'Unimplemented', '__TBD' if type(path)==types.StringType: --- 1020,1024 ---- """ if not self.useAliases(): ! raise NotImplementedError, '__TBD' if type(path)==types.StringType: *************** *** 1592,1594 **** def __unimplemented__(msg='Unimplemented yet'): ! raise 'Unimplemented', msg --- 1597,1599 ---- def __unimplemented__(msg='Unimplemented yet'): ! raise NotImplementedError, msg |
From: <sbi...@us...> - 2003-08-03 10:34:17
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer In directory sc8-pr-cvs1:/tmp/cvs-serv21866/DatabaseAdaptors/MySQLAdaptorLayer Modified Files: MySQLSQLExpression.py Log Message: Fixed bug #780495: when ec.fetch() is joining two tables or more, the returned set of objects could have duplicates. Index: MySQLSQLExpression.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer/MySQLSQLExpression.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MySQLSQLExpression.py 31 May 2003 15:12:24 -0000 1.5 --- MySQLSQLExpression.py 3 Aug 2003 10:34:14 -0000 1.6 *************** *** 173,174 **** --- 173,272 ---- return (str, aliases) + + def prepareSelectCountExpressionWithAttributes(self, + attributes,lock,fetchSpec): + """ + Overrides the default method and prepares a SQL expression suitable for + MySQL, counting the rows qualified by 'fetchSpec'. + + The SQL statement depends on whether 'fetchSpec' implies joining two or + more tables: + + - if at least a join is needed, the statement is like:: + + SELECT COUNT(DISTINCT t0.pk1, t0.pk2, ...) FROM ... + INNER JOIN ... + [WHERE <fetchSpec's condition>] + + where pk1, pk2 are the primary keys in the fetchSpec's entity, + + - otherwise, it is like: + + SELECT COUNT(*) FROM <table> [WHERE <fetchSpec's condition>] + + Parameters: + + attributes -- the attributes to fetch (they do not appear in the sql) + + lock -- Unimplemented, should be false + + fetchSpec -- the FetchSpecification qualifying the rows to be counted + + """ + self.setUseAliases('Yep') + lockClause='' + if lock: + raise NotImplementedError, 'lock is not implemented yet' + + for attribute in attributes: + self.addSelectListAttribute(attribute) + + # fetchSpec + if fetchSpec is not None and \ + self._entity.restrictingQualifier() is not None: # TBD + raise 'Unimplemented', \ + "fetchSpec and/or entity's restrictingQualifier is not None" + + # qualifier: to be mixed w/ entity's restrictingQualifier if necessary + fullQualifier=None + + fsQualifier=fetchSpec and fetchSpec.qualifier() or None + entityQual=self._entity.restrictingQualifier() + if fsQualifier: + if entityQual: + fullQualifier=AndQualifier([fsQualifier, entityQual]) + else: + fullQualifier=fsQualifier + elif entityQual: + fullQualifier=entityQual + + # clause: WHERE + self._whereClauseString=self.sqlStringForQualifier(fullQualifier) + + joinClause='' + + # Do we join some tables? + multiple_tables_joined=len(self.entityExternalNamesByAliases())>1 + selectString='' + + columnList=' COUNT(*) ' + if multiple_tables_joined: + columnList='COUNT(DISTINCT ' + # TBD: cf. test_14: if we use this: + #self._internals.aliasForEntityExternalName(self._entity.externalName()) + # then we select from the wrong table (t3 instead of t0) + entity_alias='t0' + for pk in self._entity.primaryKeyAttributes(): + columnList+=entity_alias+'.'+pk.columnName()+', ' + columnList=columnList[:-2]+') ' + else: + columnList=' COUNT(*) ' + + fetchOrder=None + whereClause=self.whereClauseString() + # orderBy: see fetchSpec... + orderByClause='' + + # + tableList=self.tableListWithRootEntity(self.entity()) + self.assembleSelectStatementWithAttributes(attributes=attributes, + lock=lock, + qualifier=fullQualifier, + fetchOrder=fetchOrder, + selectString=selectString, + columnList=columnList, + tableList=tableList, + whereClause=whereClause, + joinClause=joinClause, + orderByClause=orderByClause, + lockClause=lockClause) |
From: <sbi...@us...> - 2003-08-03 10:12:28
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests In directory sc8-pr-cvs1:/tmp/cvs-serv19324 Modified Files: test_EditingContext_Global.py Log Message: misc. Index: test_EditingContext_Global.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** test_EditingContext_Global.py 2 Aug 2003 15:24:06 -0000 1.38 --- test_EditingContext_Global.py 3 Aug 2003 10:12:26 -0000 1.39 *************** *** 798,802 **** ec=EditingContext() nb_objs=ec.objectsCountWithFetchSpecification(fs) ! self.failIf(nb_objs!=3) # only 3: author 'Dard' is the only # one with a pygmalion --- 798,802 ---- ec=EditingContext() nb_objs=ec.objectsCountWithFetchSpecification(fs) ! self.assertEqual(nb_objs, 3) # only 3: author 'Dard' is the only # one with a pygmalion |
From: <sbi...@us...> - 2003-08-02 15:24:09
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests In directory sc8-pr-cvs1:/tmp/cvs-serv637 Modified Files: test_EditingContext_Global.py Log Message: Added tests for bug #780495 Index: test_EditingContext_Global.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** test_EditingContext_Global.py 2 Aug 2003 15:13:43 -0000 1.37 --- test_EditingContext_Global.py 2 Aug 2003 15:24:06 -0000 1.38 *************** *** 1207,1211 **** ec=EditingContext() ws=ec.fetchCount('Writer', 'books.title like "*"') ! self.assertEqual(len(ws), 2) def test_999_customSQLQuery(self): --- 1207,1211 ---- ec=EditingContext() ws=ec.fetchCount('Writer', 'books.title like "*"') ! self.assertEqual(ws, 2) def test_999_customSQLQuery(self): |
From: <sbi...@us...> - 2003-08-02 15:13:46
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests In directory sc8-pr-cvs1:/tmp/cvs-serv31716 Modified Files: test_EditingContext_Global.py Log Message: Added tests for bug #780495 Index: test_EditingContext_Global.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** test_EditingContext_Global.py 2 Aug 2003 11:14:57 -0000 1.36 --- test_EditingContext_Global.py 2 Aug 2003 15:13:43 -0000 1.37 *************** *** 1191,1194 **** --- 1191,1212 ---- self.failIf(res[0].getTitle()!='abc*d') + def test_24_fetch_does_not_return_duplicates(self): + "[EditingContext] fetch does not return duplicates" + # bug #780495 + ec=EditingContext() + ws=ec.fetch('Writer', 'books.title like "*"') + # explicitely look for duplicates + for w in ws: + _ws=list(ws) #[:-1]) + _ws.remove(w) + self.failIf(w in _ws, 'Duplicate found: %s'%w) + + def test_25_fetchCount_is_not_affected_by_duplicates(self): + "[EditingContext] fetchCount is not affected by duplicates" + # bug #780495 + ec=EditingContext() + ws=ec.fetchCount('Writer', 'books.title like "*"') + self.assertEqual(len(ws), 2) + def test_999_customSQLQuery(self): "[EditingContext] custom SQL Query" |
From: <sbi...@us...> - 2003-08-02 11:16:42
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv32715 Modified Files: DatabaseContext.py Log Message: Fixed bug #774989: improper result returned by CustomObject.snapshot() wrt tomany relationships --see CustomObject.snapshot() documentation for details. Index: DatabaseContext.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseContext.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** DatabaseContext.py 28 Jul 2003 06:15:15 -0000 1.18 --- DatabaseContext.py 2 Aug 2003 11:16:40 -0000 1.19 *************** *** 1292,1298 **** for key in toManyKeys: _sn=objectSnapshot[key] ! if _sn is not None: ! # 'faulted toMany' are None when returned from ! # CustomObject.snapshot() toManySnap[key]=objectSnapshot[key] # replace any TemporaryGlobalID with its corresponding new value --- 1292,1299 ---- for key in toManyKeys: _sn=objectSnapshot[key] ! from CustomObject import Snapshot_ToManyFault ! if not isinstance(_sn, Snapshot_ToManyFault): ! # 'faulted toMany' are instances of Snapshot_ToManyFault when returned ! # by CustomObject.snapshot() toManySnap[key]=objectSnapshot[key] # replace any TemporaryGlobalID with its corresponding new value |
From: <sbi...@us...> - 2003-08-02 11:15:00
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests In directory sc8-pr-cvs1:/tmp/cvs-serv32454/tests Modified Files: test_EditingContext_Global.py Log Message: Fixed bug #774989: improper result returned by CustomObject.snapshot() wrt tomany relationships --see CustomObject.snapshot() documentation for details. Index: test_EditingContext_Global.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** test_EditingContext_Global.py 2 Aug 2003 09:40:49 -0000 1.35 --- test_EditingContext_Global.py 2 Aug 2003 11:14:57 -0000 1.36 *************** *** 22,25 **** --- 22,26 ---- # #----------------------------------------------------------------------------- + from __future__ import nested_scopes """ *************** *** 920,924 **** ec.saveChanges() gid=ec.globalIDForObject(w) ! self.assertEqual(b.getFK_Writer_Id(), gid.keyValues()['id']) def test_18_percent_in_qualifiers_should_be_correctly_escaped(self): --- 921,928 ---- ec.saveChanges() gid=ec.globalIDForObject(w) ! # a FK defined as a class property is NOT updated by the framework ! # see the User's Guide, section B.1 ! # so we get None instead of gid.keyValues()['id'] ! self.assertEqual(b.getFK_Writer_Id(), None) def test_18_percent_in_qualifiers_should_be_correctly_escaped(self): *************** *** 962,970 **** def test_20_snapshot(self): ! "[EditingContext] snapshot: TBD" ! pass ! def test_21_snapshot_raw(self): ! "[EditingContext] snapshot_raw" ec=EditingContext() --- 966,1045 ---- def test_20_snapshot(self): ! "[EditingContext] CustomObject.snapshot()" ! ec=EditingContext() ! ! ## single object, no object related ! w=Writer() ! w.setLastName('Test'); w.setFirstName('20') ! ec.insertObject(w) ! ! ws=w.snapshot() ! def check_single_object(): ! self.assertEqual(ws['lastName'], 'Test') ! self.assertEqual(ws['firstName'], '20') ! self.assertEqual(ws['birthday'], None) ! self.assertEqual(ws['pygmalion'], None) ! self.assertEqual(ws['books'], []) ! check_single_object() ! ec.saveChanges() ! check_single_object() ! ! ## all objects saved, no faults here ! b1=Book(); b1.setTitle('b1') ! b2=Book(); b2.setTitle('b2') ! ec.insert(b1) ! ec.insert(b2) ! w.addToBooks(b1) ; b1.setAuthor(w) ! w.addToBooks(b2) ; b2.setAuthor(w) ! p=Writer(); p.setLastName('test_20 pygmalion') ! ec.insert(p) ! w.setPygmalion(p) ! ws=w.snapshot() ! self.assertEqual(ws['lastName'], 'Test') ! self.assertEqual(ws['firstName'], '20') ! self.assertEqual(ws['pygmalion'], p.globalID()) ! self.assertEqual(len(ws['books']), 2) ! self.failUnless(b1.globalID() in ws['books']) ! self.failUnless(b2.globalID() in ws['books']) ! ec.saveChanges() ! p_globalID=p.globalID() ! del ec ! ! ## Now both relationships 'pygmalion' and 'books' are faults ! ec=EditingContext() ! w=ec.fetch('Writer', 'lastName=="Test" and firstName=="20"')[0] ! ws=w.snapshot() ! self.assertEqual(ws['lastName'], 'Test') ! self.assertEqual(ws['firstName'], '20') ! ! # for a faulted to-one rel, we get the corresponding globalID ! self.assertEqual(ws['pygmalion'], p_globalID) ! self.failUnless(w.getPygmalion().isFault()) ! ! # for a faulted to-many rel, we get a CustomObject.Snapshot_ToManyFault ! self.failUnless(w.getBooks().isFault()) ! from Modeling.FaultHandler import AccessArrayFaultHandler ! from Modeling.CustomObject import Snapshot_ToManyFault ! self.assertEqual(ws['books'].__class__, Snapshot_ToManyFault) ! ! # last, we check that the to-many fault is accessible, if we want to: ! self.assertEqual(ws['books'].sourceGlobalID, w.globalID()) ! self.assertEqual(ws['books'].key, 'books') ! tomany_fault=ws['books'].getToManyFault(ec) ! from Modeling.FaultHandler import AccessArrayFaultHandler ! self.failUnless(isinstance(tomany_fault, AccessArrayFaultHandler)) ! self.failUnless(tomany_fault.isFault()) ! ! # check that we got the same set of objects ! adaptorChannel=concreteAdaptorChannelForEntity('Writer', ec) ! fetchCount=adaptorChannel._count_for_execute ! self.assertEqual(len(tomany_fault), 2) ! self.assertEqual(adaptorChannel._count_for_execute, ! fetchCount+1) # fault was cleared ! for book in w.getBooks(): ! self.failIf(book not in tomany_fault) ! def test_21_snapshot_raw(self): ! "[EditingContext] CustomObject.snapshot_raw()" ec=EditingContext() *************** *** 972,977 **** --- 1047,1055 ---- raw_fdard=ec.fetch('Writer', 'age == 82', rawRows=1)[0] fdard=ec.fetch('Writer', 'age == 82')[0] + rabelais=ec.fetch('Writer', 'lastName == "Rabelais"')[0] fdard_snapshot_raw=fdard.snapshot_raw() self.assertEqual(raw_fdard, fdard_snapshot_raw) + self.assertEqual(fdard_snapshot_raw['FK_Writer_id'], + rabelais.globalID().keyValues()['id']) # new object, related to saved objects *************** *** 982,986 **** self.assertEqual(w_sr.keys(), fdard_snapshot_raw.keys()) self.assertEqual(w_sr['FK_Writer_id'], fdard.globalID().keyValues()['id']) ! self.assertEqual(w_sr['id'], w.globalID()) w.setPygmalion(None) ec.delete(w) --- 1060,1065 ---- self.assertEqual(w_sr.keys(), fdard_snapshot_raw.keys()) self.assertEqual(w_sr['FK_Writer_id'], fdard.globalID().keyValues()['id']) ! self.assertEqual(w_sr['id'], w.globalID()) # we get a TemporaryGlobalID ! self.failUnless(w_sr['id'].isTemporary()) w.setPygmalion(None) ec.delete(w) |
From: <sbi...@us...> - 2003-08-02 11:15:00
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv32454 Modified Files: CHANGES CustomObject.py Log Message: Fixed bug #774989: improper result returned by CustomObject.snapshot() wrt tomany relationships --see CustomObject.snapshot() documentation for details. Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v retrieving revision 1.141 retrieving revision 1.142 diff -C2 -d -r1.141 -r1.142 *** CHANGES 2 Aug 2003 09:40:49 -0000 1.141 --- CHANGES 2 Aug 2003 11:14:57 -0000 1.142 *************** *** 8,11 **** --- 8,15 ---- -------------------------------------------------------- + * Fixed bug #774989: improper result returned by CustomObject.snapshot() + wrt tomany relationships --see CustomObject.snapshot() documentation for + details. + * Fixed bug #779775, on behalf of Yannick Gingras who reported the bug and gave the patch fixing it. Index: CustomObject.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CustomObject.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** CustomObject.py 29 Jul 2003 18:42:13 -0000 1.17 --- CustomObject.py 2 Aug 2003 11:14:57 -0000 1.18 *************** *** 40,44 **** import Validation from RelationshipManipulation import RelationshipManipulation ! from FaultHandler import FaultHandler import ObserverCenter from EditingContext import ObjectNotRegisteredError --- 40,44 ---- import Validation from RelationshipManipulation import RelationshipManipulation ! from FaultHandler import FaultHandler, AccessArrayFaultHandler import ObserverCenter from EditingContext import ObjectNotRegisteredError *************** *** 49,52 **** --- 49,94 ---- + class Snapshot_ToManyFault: + """ + Snapshot_ToManyFault is used in CustomObject.snapshot(), when returning + the value for a to-many relationship which is still a fault. + + It should not be mistaken for FaultHandler.AccessArrayFaultHandler, which + holds the real to-many fault. An instance of this class is just a mean for + CustomObject.snapshot() to tell that it found a fault. If you need the real + to-many fault, use getToManyFault(). + + See also: CustomObject.snapshot() for additional details. + """ + def __init__(self, sourceGlobalID, key): + """Initializer + + Parameter: + + sourceGlobalID -- a non temporary GlobalID (this is a non sense to have + a to many fault for an object that has just been inserted + + key -- the corresponding to-many relationship's name + + Raises ValueError is sourceGlobalID.isTemporary() is true. + + """ + if sourceGlobalID.isTemporary(): + raise ValueError, 'sourceGlobalID cannot be a temporary global id' + self.sourceGlobalID=sourceGlobalID + self.key=key + + def getToManyFault(self, ec): + """ + Returns the real to-many fault that this object represents. + + Parameter: + + ec -- an EditingContext + + """ + return ec.arrayFaultWithSourceGlobalID(self.sourceGlobalID, self.key, + ec) + class CustomObject(RelationshipManipulation, DatabaseObject): """ *************** *** 236,245 **** are allPropertyKeys(), and whose values are : ! - for attribute, the corresponding value ! - for toOne relationships, the GlobalID of the related object (or None) ! - for toMany relationships: GlobalIDs of related objects, or None if the ! corresponding value is a toMany fault. Raises ObjectNotRegisteredError if the object itself is not registered in --- 278,310 ---- are allPropertyKeys(), and whose values are : ! - for attribute, the corresponding value, ! - for toOne relationships, the GlobalID of the related object (or None). ! If you want to get the real object corresponding to that global id, ! simply call EditingContext.faultForGlobalID() on ! self.editingContext(). ! - For toMany relationships, the returned value depends on whether the ! set of related objects is still a fault or not: ! ! - if it is still a to-many fault, you'll get an instance of ! Snapshot_ToManyFault. To get the real to-many fault (instance of ! FaultHandler.AccessArrayFaultHandler), simply call ! getToManyFault() on this instance, ! ! - otherwise, you get the list of the GlobalIDs of the related ! objects ! ! Why are to-many faults handled this way? We do not want snapshot() to ! trigger any round-trip to the database. One could say, okay, but then ! you could return the to-many fault as well. True, but this won't be ! consistent with the other values returned by snapshot: values for ! to-one relationship are globalIDs with which you must explicitely call ! ec.faultForGlobalID() to get the real object. Same for to-many faults: ! you also need to explicitely call Snapshot_ToManyFault's ! getToManyFault() to get the whole (faulted) array. Last, this also ! prevents a to-many fault to be cleared by mistake (because simply ! looking at one of the fault properties, such as itys length, triggers ! a round-trip to the database). Raises ObjectNotRegisteredError if the object itself is not registered in *************** *** 284,288 **** else: ! res[key]=None else: --- 349,353 ---- else: ! res[key]=Snapshot_ToManyFault(self.globalID(), key) else: *************** *** 334,338 **** ec=self.editingContext() if ec is None: ! raise ObjectNotRegisteredError, 'Unable to compute snapshot_raw: no editingContext()' if self.isFault(): self.willRead() --- 399,403 ---- ec=self.editingContext() if ec is None: ! raise ObjectNotRegisteredError, 'Unable to compute snapshot_raw: the object is not registered in an EditingContext' if self.isFault(): self.willRead() *************** *** 447,455 **** elif key in toManyKeys: ! if value is not None: ! value=map(lambda gID, ec=ec: ec.faultForGlobalID(gID, ec), value) else: ! gID=ec.globalIDForObject(self) ! value=ec.arrayFaultWithSourceGlobalID(gID, key, ec) self.takeStoredValueForKey(value, key) --- 512,524 ---- elif key in toManyKeys: ! if isinstance(value, Snapshot_ToManyFault): ! #gID=ec.globalIDForObject(self) ! #value=ec.arrayFaultWithSourceGlobalID(gID, key, ec) ! value=value.getToManyFault(ec) else: ! try: ! value=map(lambda gID, ec=ec: ec.faultForGlobalID(gID, ec), value) ! except: ! import pdb ; pdb.set_trace() self.takeStoredValueForKey(value, key) |