Re: .isset() behaviour change on StringHTMLProperty
Nagy Gabor <[email protected]>
| Newsgroups | gmane.comp.bug-tracking.roundup.user |
|---|---|
| Message-ID | <20210801110657.43caf6f4@Dell> |
Hi,
There is no default_value in my schema.py at all, and
hyperdb.issue.get() returns None for unset string properties in
question.
Yes, I saw the test "return self._value is not None", so I think the
None string property is changed somewhere to "". And so my original
report was loose: I should have said that isset() always reports True
for String poperties, no matter what I do.
Yes, commenting out the lines
if self._value is None:
self._value = prop.get_default_value()
fixes the issue, so somehow prop.get_default_value() sets the wrong
value.
And yes, I think the problem is in String(_Type) of hyperdb.py:
def __init__(self, indexme='no', required=False, default_value="",
quiet=False):
...
Probably there is a reason for this default value, but this breaks
isset()...
Regards,
Gábor
> Hi Nagy:
>
> In message <20210801020640.73ac1729@Dell>,
> Nagy Gabor writes:
> >In Roundup 2.1.0, the isset method of StringHTMLProperty of
> >cgi/templating.py reports True for empty strings. IIRC, Roundup 2.0.0
> >reported False in this case. (Anyway, if I replace templating.py to
> >the 2.0.0 version, it reports False.)
> >
> >Is this an intended change?
>
> Nope. That code hasn't changed since 2004-05-10 0.7.1. But the test
> is:
>
> return self._value is not None
>
> I wonder if something in 2.1.0 changed the representation of an unset
> string from None to ""?
>
> One change in 2.1.0 added support for property default_values. At the
> end of the HTMLProperty::__init__ I added:
>
> # if self._value is None see if we have a default value
> if self._value is None:
> self._value = prop.get_default_value()
>
> Can you restore the 2.1.0 copy of templating.py and comment out these
> lines. See if that restores the 2.0.0 behavior.
>
> The default value for default_value is None. Do you define the
> property using default_value='' in your schema?
>
> Have a great day.
>
> --
> -- rouilj
> John Rouillard
> ===========================================================================
> My employers don't acknowledge my existence much less my opinions.
_______________________________________________
Roundup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/roundup-users