[Modeling-cvs] ProjectModeling/Modeling CHANGES,1.80,1.81 ModelValidation.py,1.5,1.6
Status: Abandoned
Brought to you by:
sbigaret
From: <sbi...@us...> - 2003-03-14 14:33:46
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv26515 Modified Files: CHANGES ModelValidation.py Log Message: Fixed ModelValidation.validateEntity_internals(): now iterates on all primary keys, and correctly report an error when a PK is set to be a class property but does not have a default value set to integer zero (this is now enforced since when the default value is None, we get an erroneous error message at EC.saveChanges(): the validation mechanism fails on validating the PK --thanks to Yannick Gingras for reporting the problem) Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** CHANGES 14 Mar 2003 14:27:25 -0000 1.80 --- CHANGES 14 Mar 2003 14:33:39 -0000 1.81 *************** *** 8,11 **** --- 8,18 ---- -------------------------------------------------------- + * Fixed ModelValidation.validateEntity_internals(): now iterates on all + primary keys, and correctly report an error when a PK is set to be a class + property but does not have a default value set to integer zero (this is + now enforced since when the default value is None, we get an erroneous + error message at EC.saveChanges(): the validation mechanism fails on + validating the PK --thanks to Yannick Gingras for reporting the problem) + * Fixed Attribute.initWithXMLDOMNode(): it was possible that the defaultValue was set prior to the attribute's type, hence it didn't get Index: ModelValidation.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelValidation.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ModelValidation.py 2 Mar 2003 12:44:10 -0000 1.5 --- ModelValidation.py 14 Mar 2003 14:33:40 -0000 1.6 *************** *** 257,260 **** --- 257,264 ---- if not entity.externalName(): msgs.append('externalName is not defined') if not entity.primaryKeyAttributes(): msgs.append('no primary key defined') + else: + for pk in entity.primaryKeyAttributes(): + if pk.isClassProperty() and pk.defaultValue()!=0: + msgs.append("PK '%s' is a class property: its default value must be 0 (int zero)"%pk.name()) if msgs: errors.aggregateError('Entity %s'%entity.name(), ERROR, msgs) *************** *** 265,276 **** msgs=[] if entity.primaryKeyAttributes(): ! pk=entity.primaryKeyAttributes()[0] ! if pk.isClassProperty(): ! msgs.append("Primary key '%s' is also marked as ``class property'' "\ ! "--this is strongly discouraged"\ ! %entity.primaryKeyAttributes()[0].name()) ! if not pk.isRequired(): ! errors.aggregateError('Entity %s'%entity.name(), WARNING, ! "Primary key '%s' should be mandatory"%pk.name()) if msgs: errors.aggregateError('Entity %s'%entity.name(), WARNING, msgs) --- 269,280 ---- msgs=[] if entity.primaryKeyAttributes(): ! for pk in entity.primaryKeyAttributes(): ! if pk.isClassProperty(): ! msgs.append("Primary key '%s' is also marked as ``class property'' "\ ! "--this is strongly discouraged"\ ! %pk.name()) ! if not pk.isRequired(): ! errors.aggregateError('Entity %s'%entity.name(), WARNING, ! "Primary key '%s' should be mandatory"%pk.name()) if msgs: errors.aggregateError('Entity %s'%entity.name(), WARNING, msgs) |