order in All compound validator
Arnaud Fontaine <[email protected]>
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Organization | Andesi |
| Message-ID | <[email protected]> |
Hello,
I'm trying to use the All compound. I would like that the All validator
firstly convert the email address to an object and then give the object
to _CheckPendingResend(), therefore I wrote the following code:
class CheckEmailAddress(validators.FancyValidator):
def _to_python(self, email, state):
try:
return model.User.byEmail(email)
except SQLObjectNotFound:
raise formencode.Invalid(E_EMAIL_INVALID, email, state)
class _CheckPendingResend(validators.FancyValidator):
def validate_python(self, user, state):
if not user.activeKey:
raise formencode.Invalid(E_EMAIL_PENDING_INVALID, user, state)
class CheckPendingResend(SchemaAllowExtraFields):
email = formencode.All(CheckEmailAddress(), _CheckPendingResend())
However, the _CheckPendingResend validator is called first. It comes
from the All validator:
# attempt_convert method of All validator
if validate is to_python:
validators = list(self.validators)
validators.reverse()
else:
validators = self.validators
I don't understand why there is a call to reverse(). I tried ForEach
validator which works as i expected, but I don't understand why it
doesn't with the All validator.
Regards,
Arnaud Fontaine
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV