Need more than one value to unpack?

64 views
Skip to first unread message

Chris Curvey

unread,
Nov 16, 2007, 10:04:33 AM11/16/07
to ToscaWidgets-discuss
I'm moving along, but still not quite there. Now I'm getting a stack
trace ending in:

File "/usr/lib/python2.5/site-packages/Genshi-0.4.4-py2.5.egg/genshi/
template/base.py", line 432, in _eval
for event in substream:
File "/usr/lib/python2.5/site-packages/Genshi-0.4.4-py2.5.egg/genshi/
template/base.py", line 398, in _eval
for kind, data, pos in stream:
ValueError: need more than 2 values to unpack

Here's the controller code:

@expose(template="genshi:turbotown.templates.toscaPosts")
def toscaGrid(self, *args, **kwargs):
# set up the grid widget
from toscawidgets.widgets import forms

postFields = [('English','english'),
('Spanish', 'spanish')]

toscaGrid = forms.DataGrid(id="PostList", fields=postFields)

# set up the data to be displayed
class Post:
def __init__(self, english, spanish):
self.english = english
self.spanish = spanish

posts = [ Post("one", "uno"),
Post("two", "dos"),
Post("three", "tres")]

#pass it all back
return dict(posts=posts, toscaGrid=toscaGrid)

And here is the template that's exposed:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:py="http://genshi.edgewall.org/">

<xi:include href="toscasitetemplate.html" />

<head>
<title>ToscaWidgets Test Page</title>
</head>

<body>
<div id="main">
<div>
${toscaGrid.display(posts)}
</div>
</div>
</body>

</html>

This has got to be something simple, but I just can't see it.

Alberto Valverde

unread,
Nov 16, 2007, 10:17:03 AM11/16/07
to toscawidge...@googlegroups.com
Chris Curvey wrote:
> I'm moving along, but still not quite there. Now I'm getting a stack
> trace ending in:
>
> File "/usr/lib/python2.5/site-packages/Genshi-0.4.4-py2.5.egg/genshi/
> template/base.py", line 432, in _eval
> for event in substream:
> File "/usr/lib/python2.5/site-packages/Genshi-0.4.4-py2.5.egg/genshi/
> template/base.py", line 398, in _eval
> for kind, data, pos in stream:
> ValueError: need more than 2 values to unpack
>
> Here's the controller code:
>
> @expose(template="genshi:turbotown.templates.toscaPosts")
> def toscaGrid(self, *args, **kwargs):
(...)

I assume you have tg.defaultview set to "kid" since you're explicitly
telling TG your template uses Genshi, right?

If this is the case, TW believes it is displaying the grid on Kid so it
breaks when displaying it on Genshi. There are a two solutions, use the
one you see fits best in your scenario (depends on the templating
language you use most in your app to render pages)

1) set tg.defaultview = "genshi" in your config.

2) When displaying the grid, pass it the displays_on parameter:
${grid(data, displays_on="genshi")}

Alberto

Chris Curvey

unread,
Nov 17, 2007, 3:00:28 PM11/17/07
to ToscaWidgets-discuss
Thanks, Alberto. I got it working by using your suggestion. I could
not get the "displays_on" method to work. If tg.defaultview is not
explicitly set (which is the default configuration for quickstarted
projects, AFAICT), OR if it is set to "kid", I get a stack trace. Not
a problem though, as the point of the exercise at this point is to get
things working with Genshi and TW.

Many thanks, once again.

-Chris

Alberto Valverde

unread,
Nov 17, 2007, 4:12:20 PM11/17/07
to toscawidge...@googlegroups.com

Really? That *should* work (it is heavily unit-tested). Are you passing
it when initializing the grid instance or when displaying it? It only
works when displaying it.

If tg.defaultview is not
> explicitly set (which is the default configuration for quickstarted
> projects, AFAICT), OR if it is set to "kid", I get a stack trace. Not
> a problem though, as the point of the exercise at this point is to get
> things working with Genshi and TW.
>
> Many thanks, once again.

No problem :)

Alberto

Chris Curvey

unread,
Nov 17, 2007, 10:23:54 PM11/17/07
to ToscaWidgets-discuss
Yep, I just confirmed it. I can send or post a stack trace if you
like.

Alberto Valverde

unread,
Nov 18, 2007, 6:00:09 PM11/18/07
to toscawidge...@googlegroups.com

Yes please. Can you open a new ticket at trac.turbogears.org/newticket?

Thanks!

Alberto


Reply all
Reply to author
Forward
0 new messages