On Oct 29, 3:44 pm, "Karl Guertin" <[EMAIL PROTECTED]> wrote:
> On 10/29/06, Lord Galrion <[EMAIL PROTECTED]> wrote:
>
> > @expose()
> > def names(self, first='somebody', 'nobody'):
> > return 'Student: %s %s' % (first, last)The argument syntax here is
> > wrong. The self is fine, the first= is
> fine, but the 'nobody' needs an argument name (last=).
>
> You'll want to define a method:
>
> @expose()
> def names(self, first='default_firstname',last='default_lastname'):
> return 'Student: %s %s' % (first, last)
>
> Which you can pass values to (only) via
> ?first=custom_first&last=custom_last. Alternatively,
> you can define the method:
>
> @expose
> def names(self, *name):
> first = 'default_firstname'
> last = 'default_lastname'
> if len(name) >= 2:
> first = name[0]
> last = name[1]
> elif len(name) == 1:
> first = name[0]
> return 'Student: %s %s' % (first, last)
>
> Which you can pass values to via /names/custom_first/custom_last
>
> > I am feeling very lame here because what I want to do is
>
> > return 'Student: %s %s' % (first, last), dict(projects=projects,
> > projwidget=projwidget)return dict(name='Student: %s %s' %(first,last),
> projects=projects, projwidget=projwidget)
>
> or if you want the individual name parts:
>
> return dict(first=first,last=last,projects=projects,projwidget=projwidget)
yeah, that is what I have, except that I always get "name first is not
defined" when I try and use the widget, if I put it in a kid template
it works fine. Here is the code for the widget.
class ProjWidget(widgets.Widget):
template = '''
<table xmlns:py="http://purl.org/kid/ns#" class="main" border="0">
<td> ${first} ${last} </td>
<tr>
<th>Team</th>
<th>Group</th>
<th>Enemy</th>
</tr>
<tr py:for="data in value">
<td py:for="d in data">
<a href='${d}'>${d}</a></td>
</tr>
</table>'''
projwidget = ProjWidget()
Everything works fine except "<td> ${first} ${last} </td>" returns
undefined.
I call the widget from kid with "${projwidget.display(projects)}"
I hope that makes sense.
thanks alot for your help!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears
-~----------~----~----~----~------~----~------~--~---