"Oleg Broytmann" <phd@...> wrote in message
news:20051021074518.GB6944@...
> Hi!
>
> On Fri, Oct 21, 2005 at 10:40:02AM +0800, gary ng wrote:
> > more validators can be guessed from database info.
>
> Column types?
>
> > However, I notice one thing that is not very convenient. The validators
> > created are by default with "NOT NULL" equivalent
>
> I do not understand this. My be you mean not validators but columns?
> SOCol and Col classes?
No I mean validators. The current fromDatabase code will create columns and
attach a validator to it, sort of mimicking as if I hand code it. The change
I sent yesterday for postgresql basically now create all the right
validators for most column types.
However, the validators defined in col.py while do subclass from FormEncode,
they do it in a very crude way and take over the validator features in
formencode ones.
>
> > as the validators created
> > don't have if_empty=None keyword.
>
> What is if_empty? I've never used it.
This is one of the feature of validator in formencode where I can define
if_empty=my_value. What it does is that if the value is being validated is
empty, the whole validation process would be short circuited and return
my_value(None in this case) instead.
This has everything to do with the table. As if I don't give a "NOT NULL"
for a column, it means I can insert rows with no value for this column which
I assume is None in SQLObject speak. Consider a scenario where I create a
HTML form and get the post back value. I can validate them against the
validators in SQLObject which is a first line data type checking(and
validity, say wrong format of date).
With its current form, anything that is not filled(especially none string
fields) would be considered as error by the validator because of this lack
of if_empty but my database definition clearly allows it unless I said NOT
NULL.
I briefly trace a bit and it seems that this validator thing is defined but
not used at all in the operation ?
>
> Oleg.
> --
> Oleg Broytmann http://phd.pp.ru/ phd@...
> Programmers don't die, they just GOSUB without RETURN.
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads, discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl

Hi!
On Fri, Oct 21, 2005 at 10:40:02AM +0800, gary ng wrote:
> more validators can be guessed from database info.
Column types?
> However, I notice one thing that is not very convenient. The validators
> created are by default with "NOT NULL" equivalent
I do not understand this. My be you mean not validators but columns?
SOCol and Col classes?
> as the validators created
> don't have if_empty=None keyword.
What is if_empty? I've never used it.
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ phd@...
Programmers don't die, they just GOSUB without RETURN.

Another thing I notice is that the validators in col.py inherit from
Validator, not FancyValidator and defines :
to_python rather than _to_python.
The result seems to be that it takes over everything in formencode tree and
thus the if_empty thing just don't work at all even if I specify it. Is this
intended ?
"gary ng" <linux@...> wrote in message
news:dj9khe$a0q$1@...
> Hi,
>
> I rely heavily on fromDatabase and find it missing something. I have
already
> submitted some patches so more validators can be guessed from database
info.
> However, I notice one thing that is not very convenient. The validators
> created are by default with "NOT NULL" equivalent as the validators
created
> don't have if_empty=None keyword. So if I use these validators to validate
> some input which is empty, all will fail even though my table definition
may
> not specify NOT NULL which means empty/None is valid content.
>
> This I believe is in general not the case of table definition. In order to
> do this properly some changes are needed to the whole col.py file so all
> column type can take one more argument for the column validator
> creation(if_empty). Another is of course change formencode so all
validators
> assume if_empty=None.
>
> Just want to know what people think about this issue.
>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads, discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl

Hi,
I rely heavily on fromDatabase and find it missing something. I have already
submitted some patches so more validators can be guessed from database info.
However, I notice one thing that is not very convenient. The validators
created are by default with "NOT NULL" equivalent as the validators created
don't have if_empty=None keyword. So if I use these validators to validate
some input which is empty, all will fail even though my table definition may
not specify NOT NULL which means empty/None is valid content.
This I believe is in general not the case of table definition. In order to
do this properly some changes are needed to the whole col.py file so all
column type can take one more argument for the column validator
creation(if_empty). Another is of course change formencode so all validators
assume if_empty=None.
Just want to know what people think about this issue.