On Mon, Jan 26, 2009 at 12:14:44PM -0800, Daniel Fetchinson wrote:
> {'x': {}}
> {'x': None}
Found it. It is in FormEncode, api.py, class FancyValidator; note
if self.is_empty(value):
...
return self.empty_value(value)
def from_python(self, value, state=None):
try:
if self.strip and isinstance(value, (str, unicode)):
value = value.strip()
if not self.accept_python:
if self.is_empty(value):
if self.not_empty:
raise Invalid(self.message('empty', state),
value, state)
else:
return self.empty_value(value)
vp = self.validate_python
if vp and vp is not self._validate_noop:
vp(value, state)
fp = self._from_python
if fp:
value = fp(value, state)
vo = self.validate_other
if vo and vo is not self._validate_noop:
vo(value, state)
return value
else:
if self.is_empty(value):
return self.empty_value(value)
fp = self._from_python
if fp:
value = self._from_python(value, state)
return value
except Invalid:
if self.if_invalid_python is NoDefault:
raise
else:
return self.if_invalid_python
def is_empty(self, value):
# None and '' are "empty"
return value is None or value == '' or (
isinstance(value, (list, tuple, dict)) and not value)
def empty_value(self, value):
return None
In newer version of FormEncode compound.All validator got correct
is_empty method:
def is_empty(self, value):
# sub-validators should handle emptiness.
return False
So it's time to require more recent FormEncode to be used with SQLObject.
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ [email protected]
Programmers don't die, they just GOSUB without RETURN.
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss