Does anyone have a clue why this code

        def make_option(row):
            return OPTION(row[1], _value=row[0])


        q = '''
            SELECT id, name
            FROM products
            WHERE
                is_active = 'T' AND
                tenant_link = {} AND
                is_container
            ORDER BY name
        '''.format(self.tenant_link)
        rows = self.db.executesql(q)


        myselect = SELECT(
            OPTION('Choose'),
            map(make_option, rows),
            _id='container_selector',
            _name='container_selector',
            )
        print XML(myselect)

Would produce this result.  Line breaks added for clarity. Comes out the 
same if not pushed through XML().

<select id="container_selector" name="container_selector">
<option value="Choose">Choose</option>

<option value="[&lt;gluon.html.OPTION object at 0x7fa4bcfc1a50&gt;, 
&lt;gluon.html.OPTION object at 0x7fa4bcfc1a90&gt;, &lt;gluon.html.OPTION 
object at 0x7fa4bcfc1ad0&gt;, &lt;gluon.html.OPTION object at 
0x7fa4bcfc1b10&gt;, &lt;gluon.html.OPTION object at 0x7fa4bcfc1b50&gt;]">

<option value="338">OH Blue Drum</option>
<option value="334">RoCon Square Fiber Drum</option>
<option value="335">Round Fiber Drum</option>
<option value="308">TH Blue Drum</option>
<option value="305">Tote</option></option>
</select>

If I do this, it works as it should
        select = SELECT(
            OPTION('Choose'),
            _id='container_selector',
            _name='container_selector',
            )


        for r in rows:
            select.append(OPTION(r[1], _value=r[0]))

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to