[Zope-dev] Bug? Handling of attribute names and default values in forms in 2.61 ??

Tres Seaver tseaver at zope.com
Thu Nov 13 14:34:18 EST 2003


On Thu, 2003-11-13 at 12:01, Max M wrote:
> I have a piece of code that looks like below. It has worked for a few 
> years now. After upgrading to 2.61 it doesn't any more.
> 
> <input type="hidden" name="teachers:list:default" value="">
> 
> <dtml-call "REQUEST.set('teacherList', getAllTeachers())">
> <dtml-in teacherList sort=title>
>          <input type="checkbox" name="teachers:list"
>             value="<dtml-var path>"<dtml-if selected> checked</dtml-if>>
> 
>          <a href="<dtml-var path>/manage_main">&dtml-title;</a><br>
> </dtml-in>
> 
> 
> I have tracked the problem to the default value always being added to 
> the "teachers" list.
> 
> meaning that my action method:
> 
> def addTeacher(self, teachers):
> 	print teachers
> 
>  >> ['some/path', '']
> 
> Where I would expect:
> 
>  >> ['some/path']
> 
> Isn't that a new behaviour? And isn't it a bug?

Can you double check that it is actually the default value, and not a
trailing empty line (I'm guessing that you are posting to 'addTeacher'
from a form with a control like:  '<textarea
name="teachers:lines">...').

E.g, change the 'teachers:list:default' value to some other string, and
see if that value propagates.

Either way, as a robustness measure I would recommend adding some input
checking to 'addTeacher', e.g.:

    def addTeacher( self, teachers ):

        """ Add one or more teachers.
        """
        teachers = filter( None, teachers ) # strip empty lines
        # your processing here

Tres.
-- 
===============================================================
Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com





More information about the Zope-Dev mailing list