In the doc: =
http://modeling.sourceforge.net/UserGuide/validate-for-save.html
appears the following text:
<quote>
You can also define your own global validation method, like:=20
from Modeling import Validation
def validateForSave(self):
"Validate "
error=3DValidation.Exception()
try:
CustomObject.validateForSave(self)
except Validation.Exception, error:
error.aggregateException(error)
# Your custom bizness logic goes here
if self.getFirstName()=3D=3D'John': # No John, except the One
if self.getLastName()!=3D'Cleese':
error.aggregateError(Validation.CUSTOM_OBJECT_VALIDATION,
Validation.OBJECT_WIDE_KEY)
error.finalize() # raises, if appropriate
...
<quote>
1. doing the import and trying a Validation.Exception() fails. I think =
it should be, Validation.ValidationException(), shouldn't it?
2. On the other hand the instruction sequence:
error=3DValidation.Exception()
try:
CustomObject.validateForSave(self)
except Validation.Exception, error:
error.aggregateException(error)
gets me confused. Shouldn't it be as follow?:
error=3DValidation.Exception()
try:
CustomObject.validateForSave(self)
except Validation.Exception, exc:
error.aggregateException(exc)
Note that I catch the exception argument with exc and add it =
afterwards to error with 'aggregateException'.
regards, Erny
|