Noel Villamor | 1 Sep 2011 02:31
Picon
Gravatar

Re: Bug in TR when rendering an array


Just when I thought I have helped find a bug, I am faced with the
revelation that I need to hone my python some more. He he he.

Thanks Anthony.

On Sep 1, 12:18 pm, Anthony <abasta...@...> wrote:
> The problem is you are passing a list of TD's to TR instead of individual
> TD's. Instead, try this:
>
> {{=TABLE(TR(TD('first'),*[TD(x) for x in arr]))}}
>
> Notice the "*" before the list comprehension -- that converts the list to a
> set of positional arguments.
>
> Anthony
>
>
>
>
>
>
>
> On Wednesday, August 31, 2011 8:03:48 PM UTC-4, Noel Villamor wrote:
>
> > To reproduce, create a view with the ff contents:
>
> > <style type="text/css">
> > td {
> > border-width: 5px;
(Continue reading)

Noel Villamor | 1 Sep 2011 02:50
Picon
Gravatar

Re: Bug in TR when rendering an array


By the way, the reason why I stumbled on this is because I wanted to
add a fourth TD to my test case.

{{=TABLE(TR(TD('first'),*[TD(x) for x in arr],TD('fourth')))}}
or more simply
{{=TABLE(TR(TD('first'),*arr,TD('fourth')))}}

But, this results to
SyntaxError: only named arguments may follow *expression

The syntax appears reasonable to me. Perhaps in the future, developers
would consider allowing this.

On Sep 1, 12:31 pm, Noel Villamor <noe...@...> wrote:
> Just when I thought I have helped find a bug, I am faced with the
> revelation that I need to hone my python some more. He he he.
>
> Thanks Anthony.
>
> On Sep 1, 12:18 pm, Anthony <abasta...@...> wrote:
>
>
>
>
>
>
>
> > The problem is you are passing a list of TD's to TR instead of individual
> > TD's. Instead, try this:
(Continue reading)

Jonathan Lundell | 1 Sep 2011 02:55
Picon
Favicon
Gravatar

Re: Re: Bug in TR when rendering an array

On Aug 31, 2011, at 5:50 PM, Noel Villamor wrote:

> 
> By the way, the reason why I stumbled on this is because I wanted to
> add a fourth TD to my test case.
> 
> {{=TABLE(TR(TD('first'),*[TD(x) for x in arr],TD('fourth')))}}
> or more simply
> {{=TABLE(TR(TD('first'),*arr,TD('fourth')))}}
> 
> But, this results to
> SyntaxError: only named arguments may follow *expression
> 
> The syntax appears reasonable to me. Perhaps in the future, developers
> would consider allowing this.

You can, I think, supply a list of TDs to TR. The problem in your example is that you had a bare TD followed by a
list of TDs.

Instead of 

{{=TABLE(TR(TD('first'),[TD(x) for x in arr]))}}

you could probably have said this:

{{=TABLE(TR([TD('first')] + [TD(x) for x in arr]))}}

> 
> On Sep 1, 12:31 pm, Noel Villamor <noe...@...> wrote:
>> Just when I thought I have helped find a bug, I am faced with the
(Continue reading)

Noel Villamor | 1 Sep 2011 03:04
Picon
Gravatar

Re: Bug in TR when rendering an array


Anthony, you surely have another way to killl the cat:

{{=TABLE(TR([TD('first')]+[TD(x) for x in arr]+[TD('fourth')]))}}

Thanks for that.

Noel

On Sep 1, 12:55 pm, Jonathan Lundell <jlund...@...> wrote:
> On Aug 31, 2011, at 5:50 PM, Noel Villamor wrote:
>
>
>
> > By the way, the reason why I stumbled on this is because I wanted to
> > add a fourth TD to my test case.
>
> > {{=TABLE(TR(TD('first'),*[TD(x) for x in arr],TD('fourth')))}}
> > or more simply
> > {{=TABLE(TR(TD('first'),*arr,TD('fourth')))}}
>
> > But, this results to
> > SyntaxError: only named arguments may follow *expression
>
> > The syntax appears reasonable to me. Perhaps in the future, developers
> > would consider allowing this.
>
> You can, I think, supply a list of TDs to TR. The problem in your example is that you had a bare TD followed by a
list of TDs.
>
(Continue reading)

Noel Villamor | 1 Sep 2011 03:43
Picon
Gravatar

Re: Bug in TR when rendering an array


Jonathan, you surely have another way to killl the cat:

{{=TABLE(TR([TD('first')]+[TD(x) for x in arr]+[TD('fourth')]))}}

Thanks for that. Anthony, thanks to you as well.

Noel

On Sep 1, 12:55 pm, Jonathan Lundell <jlund...@...> wrote:
> On Aug 31, 2011, at 5:50 PM, Noel Villamor wrote:
>
>
>
> > By the way, the reason why I stumbled on this is because I wanted to
> > add a fourth TD to my test case.
>
> > {{=TABLE(TR(TD('first'),*[TD(x) for x in arr],TD('fourth')))}}
> > or more simply
> > {{=TABLE(TR(TD('first'),*arr,TD('fourth')))}}
>
> > But, this results to
> > SyntaxError: only named arguments may follow *expression
>
> > The syntax appears reasonable to me. Perhaps in the future, developers
> > would consider allowing this.
>
> You can, I think, supply a list of TDs to TR. The problem in your example is that you had a bare TD followed by a
list of TDs.
>
(Continue reading)

Anthony | 1 Sep 2011 02:53
Picon

Re: Bug in TR when rendering an array

By the way, the reason you got the output you did is because TR expects its positional arguments to be TD's, and if they are not, it wraps them in a TD. In your case, your second positional argument was a list, so TR wrapped it in a TD for you (it turned out that your list itself contained two TD's, so they ended up inside another TD).


Anthony

On Wednesday, August 31, 2011 8:31:09 PM UTC-4, Noel Villamor wrote:

Just when I thought I have helped find a bug, I am faced with the
revelation that I need to hone my python some more. He he he.

Thanks Anthony.


On Sep 1, 12:18 pm, Anthony <abas...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> The problem is you are passing a list of TD's to TR instead of individual
> TD's. Instead, try this:
>
> {{=TABLE(TR(TD('first'),*[TD(x) for x in arr]))}}
>
> Notice the "*" before the list comprehension -- that converts the list to a
> set of positional arguments.
>
> Anthony
>
>
>
>
>
>
>
> On Wednesday, August 31, 2011 8:03:48 PM UTC-4, Noel Villamor wrote:
>
> > To reproduce, create a view with the ff contents:
>
> > <style type="text/css">
> > td {
> > border-width: 5px;
> > border-color: #000080;
> > border-style: solid;
> > }
> > </style>
>
> > {{arr=['second','third']}}
> > {{=TABLE(TR(TD('first'),[TD(x) for x in arr]))}}
>
> > HTML result:
>
> > <table>
> > <tbody>
> > <tr>
> > <td>first</td>
> > <td></td>       <-- This extra td should not be here
> > <td>second</td>
> > <td>third</td>
> > </tr>
> > </tbody>
> > </table>
>
> > Remarks:
>
> > The bug does not show if there is no TD before the TD array. Thus, the
> > following is OK.
> > {{=TABLE(TR([TD(x) for x in arr]))}}
Noel Villamor | 1 Sep 2011 02:59
Picon
Gravatar

Re: Bug in TR when rendering an array

Following what you said, I would have expected the html result to be:

<tr>
<td>first</td>
<td>
<td>second</td>
<td>third</td>
</td>
</tr>

In any case, the following syntax would have been a work-around for
the "SyntaxError: only named arguments may follow *expression" but
only if the extra <td> wasn't there.
{{=TABLE(TR(TD('first'),[TD(x) for x in arr],TD('fourth')))}}

On Sep 1, 12:53 pm, Anthony <abasta...@...> wrote:
> By the way, the reason you got the output you did is because TR expects its
> positional arguments to be TD's, and if they are not, it wraps them in a TD.
> In your case, your second positional argument was a list, so TR wrapped it
> in a TD for you (it turned out that your list itself contained two TD's, so
> they ended up inside another TD).
>
> Anthony
>
>
>
>
>
>
>
> On Wednesday, August 31, 2011 8:31:09 PM UTC-4, Noel Villamor wrote:
>
> > Just when I thought I have helped find a bug, I am faced with the
> > revelation that I need to hone my python some more. He he he.
>
> > Thanks Anthony.
>
> > On Sep 1, 12:18 pm, Anthony <abas...@...> wrote:
> > > The problem is you are passing a list of TD's to TR instead of individual
>
> > > TD's. Instead, try this:
>
> > > {{=TABLE(TR(TD('first'),*[TD(x) for x in arr]))}}
>
> > > Notice the "*" before the list comprehension -- that converts the list to
> > a
> > > set of positional arguments.
>
> > > Anthony
>
> > > On Wednesday, August 31, 2011 8:03:48 PM UTC-4, Noel Villamor wrote:
>
> > > > To reproduce, create a view with the ff contents:
>
> > > > <style type="text/css">
> > > > td {
> > > > border-width: 5px;
> > > > border-color: #000080;
> > > > border-style: solid;
> > > > }
> > > > </style>
>
> > > > {{arr=['second','third']}}
> > > > {{=TABLE(TR(TD('first'),[TD(x) for x in arr]))}}
>
> > > > HTML result:
>
> > > > <table>
> > > > <tbody>
> > > > <tr>
> > > > <td>first</td>
> > > > <td></td>       <-- This extra td should not be here
> > > > <td>second</td>
> > > > <td>third</td>
> > > > </tr>
> > > > </tbody>
> > > > </table>
>
> > > > Remarks:
>
> > > > The bug does not show if there is no TD before the TD array. Thus, the
> > > > following is OK.
> > > > {{=TABLE(TR([TD(x) for x in arr]))}}


Gmane