Probably, this variant is the full:

class Form:
    r"""print(Form(Textbox("x"),(Textbox("y0"),Textbox("y1"))).render())
<table>
    <tr><th><label for="x">x</label></th><td><input type="text" name="x"
id="x" /></td></tr>
    <tr><th><label for="y0">y0</label></th><td><input type="text" name="y0"
id="y0" /></td><th><label for="y1">y1</label></th><td><input type="$
</table>"""
    def __init__(self, *inputs, **kw):
        def untree(a):
            from pprint import isrecursive
            if isrecursive(a): raise
            if type(a) not in [tuple, list]: return [a]
            else: return reduce(lambda x,y: x+untree(y),a,[])
        self.tree_inputs = inputs
        self.inputs = tuple(untree(inputs))
        self.valid = True
        self.note = None
        self.validators = kw.pop('validators', [])

    def render(self):
        def recursiverender(i):
            if type(i) in [list, tuple]:
                return "    <tr>%s</tr>\n"%''.join([recursiverender(ii) for
ii in i])
            else:
                #if not i.description: lbl=""
                #else: lbl='<th><label for="%s">%s</label></th>'%(i.id,
net.websafe(i.description))
                lbl='<th><label for="%s">%s</label></th>'%(i.id,
net.websafe(i.description))
                return '%s<td>%s</td>' % (lbl, i.pre+i.render()+i.post)
        return '%s<table>\n%s</table>' % (self.rendernote(self.note), \
            ''.join([ type(i)==tuple and recursiverender(i) or
recursiverender((i,)) for i in self.tree_inputs]))
............

I will be glad to know your opinion

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to