Re: template variable reference fails.

"John P. Rouillard" <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.user
Message-ID <[email protected]>
Hi Tom:

Just a couple of thoughts.

In message
<DM6PR08MB4778DEBD4EA9FEFF0B3B2743CA670@DM6PR08MB4778.namprd08.prod.
outlook.com>, Tom Ekberg writes:

>I'm using almost the tip of the roundup code and am having trouble running
>a classic template that works fine in the old (1.5) roundup. I'm running
>python 3.5, Ubuntu 16.04.

This is wierd. I don't recognize your issue.

Can you try running using python2 rather than 3. Maybe try 1.6
(obviuosly with python 2) from the hg repo for testing as well. If it
works in either of these scenarios, I suspect a python 3 support patch
may be missing a conversion somewhere.

>The error I'm getting is this:
>
><class 'NameError'>: name 'compstaff_ulist' is not defined
>
>If I look further down the error page on the left side I see the
>variable compstaff_ulist defined!

Hmm, that would seem to rule out the one idea I had. Does the value of
the definition seem right?

>If it matters, the structure of
>that part of the classic template (issue.item.html) looks links this:
>
><table class="form" border="0"
>       tal:define="compstaff_ulist python:sorted...
>
>The reference to the variable is within this table as a <td> element:
>
>    <td
>       tal:define="users python:sorted([user for user in db['user'].list()
>    if user.username in compstaff_ulist],
>    key=lambda x:x.realname.plain().lower());...
>

Try invalidating this (change the :define to :def) and use:

    <td tal:content="compstaff_ulist"> </td>

So you get the value without changing to python mode.

What does it display? Does it throw an error?

>Have you encountered this problem, where a variable is tal:defined
>but is not recognized in a python expression?

I have but there were all scope issues. Since the traceback shows a
definition for the variable, it seems to not be a scope issue like:

  <div tal:define="foo ...">
  </div>
  <div tal:content="string:foo">
       no foo defined here. need global foo in the define for this to work
  </div>

>I have other variables
>tal:defined in the <body> element in page.html that work fine. It
>looks like I may have to instrument PythonExpr.py. If you have a
>better place to start looking I'd like to know.

Except for scoping I got nothing. I have to admit the TAL code is a
bit opaque to me.

Good luck and let us know what the result is.

--
				-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.