I'm trying to create a validator that will check to determine if the value
entered for a particular field is duplicated in another object. I created a
validator which check for duplicates. This validator fires when the user
attempts to move off the field and properly determines if the entered value
is a duplicate.
However, when the user presses the Save button, the validator fires three
more times and the final two times appear to be after the object has been
saved, so the validator finds the newly inserted object as a duplicate (even
though it has already been saved correctly).
Is there any way to have the validator not check for those subsequent calls.
I cannot find any difference in the inforamtion available to the validator
to just return and ignore the validation.
Any ideas would be greatly appreciated.
Thanks.
John
--
View this message in context: http://plone.293351.n2.nabble.com/Validator-challenge-tp5919348p5919348.html
Sent from the Archetypes mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Archetypes-users mailing list
Archetyp...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/archetypes-users
IIRC the multiple validations are due to
(i) using portal factory, meaning the object gets copied
to its final place only after hitting 'save' for the first time.
The adding involved here triggers another round of validation.
(ii) 'validate integrity' meaning that not only are the
individual fields validated as they are entered but also
later during the process when all data has been entered.
Now, (i) you can detect by checking for the '_creationflag'
(or similar) but I'm not aware that you can detect whether
you are in (ii)
I'd recommend that you handle this by introducing a custom
flag e.g., by assigning some attribute to the instance on
first validation and check for it thereafter.
The instance in question can be obtained from the keyword
arguments passed to the validator.
HTH
Raphael
>
> Any ideas would be greatly appreciated.
>
> Thanks.
>
> John
------------------------------------------------------------------------------
Your explanation and suggestions were exactly what I needed. I never
thought about portal factory. I was able to use the presence (or lack
thereof) of the REQUEST to bypass additional checks. Thanks.
John
--
View this message in context: http://plone.293351.n2.nabble.com/Validator-challenge-tp5919348p5922024.html