tw rating on turbogears2.1

1 view
Skip to first unread message

vivek

unread,
Jul 11, 2010, 11:12:42 AM7/11/10
to TurboGears
Hii!
I just started working on turbogears.. actually am learnig by
following the documentation. Am stuck up on this tutorial where it has
been explained on how to use tw.rating to enable star rating widget on
the template.I did the following:-
installed tw.rating
1.easy_install tw.rating


2.from tw.rating import Rating
3.my_rating = Rating(id='my_rating', action='rating', label_text='')
(in the controller)
4.
@expose('genshi:myproject.templates.ratings')
def testing(self, **kw):
tmpl_context.widget = my_rating
return dict()

5. created a template named ratings.html and inserted the following
code
${tmpl_context.widget(value)}
(( all the above steps are as explained in the tutorial on this link :-
http://turbogears.org/2.1/docs/main/ToscaWidgets/Using.html))

However when i go to localhost:8080/testing .. i get "UndefinedError:
"value" not defined" .. .. I have posted the controller and template
codes here http://pastebin.com/2hqFj6t3

The traceback of the error is here...http://pastebin.com/tvXDpFft

I know am doing something really silly, but can someone please,please
look into it and help me. Have done enough googling but no help. And
yes the default templating is genshi.

Regards
Vivek

Diez B. Roggisch

unread,
Jul 11, 2010, 11:30:07 AM7/11/10
to turbo...@googlegroups.com

You pass a name "value" to the widget in your template. But you don't
return value as part of the testing-controller.

I have no idea what tw.rating does, nor what the value the widget
might or might not get is supposed to look.

Diez

b vivek

unread,
Jul 11, 2010, 11:43:48 AM7/11/10
to turbo...@googlegroups.com
That is true Diez.. but am just following the tutorial here ..http://turbogears.org/2.1/docs/main/ToscaWidgets/Using.html

Thanks for replying!
Vivek



--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbo...@googlegroups.com.
To unsubscribe from this group, send email to turbogears+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en.


b vivek

unread,
Jul 11, 2010, 12:36:17 PM7/11/10
to turbo...@googlegroups.com
Did it .. well yes Diez that was really silly of me in the template you just need to call ${tmpl_context.widget()} instead of ${tmpl_context.widget(value)}

Diez B. Roggisch

unread,
Jul 11, 2010, 12:40:44 PM7/11/10
to turbo...@googlegroups.com

Am 11.07.2010 um 17:43 schrieb b vivek:

> That is true Diez.. but am just following the tutorial here ..http://turbogears.org/2.1/docs/main/ToscaWidgets/Using.html
>
> Thanks for replying!
> Vivek

The tutorial is wrong then. It's obvious that passing something to a
widget can only be done if the "something" is defined first. Again, I
have no idea what tw.rating is supposed to do. I can only suggest to
not pass anything at all, so just remove the "value" from the display-
call.

Diez

Reply all
Reply to author
Forward
0 new messages