Michael Steinfeld wrote:
> so if I was to do something like
>
> import calendar, itertools
>
> month = calendar.monthcalendar(2006, 10)
> days = [i for i in itertools.chain(*month)]
You don't need to build a list here; simply pass the iterator.
> if days ==0:
> print '<td class='in'></td>
> else:
> print '<td class='out'> days </td>
>
> what would be the 'correct' and 'most efficient' way to do that using
> kid? And is there any benefit using a widget?
The Kid template would look like that:
<td py:for="day in days"
class="${day and 'out' or 'in'}" py:content="day or ''"/>
This will display all days of the month in one long table column which
does not seem very plausible to me, but this is what your originally
posted nested loop did. If you want to have the weeks in separate rows,
then pass month directly to the template and do the following:
<table><tr py:for="week in month"><td py:for="day in week"
class="${day and 'out' or 'in'}" py:content="day or ''"/></tr></table>
I think that is actually even simpler than a PHP solution.
A widget makes sense when you are displaying such calendars in various
situations in the template, so you can reuse it.
-- Christoph
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---