Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > f6c029cb6d7f91d967561f80e604bd05 > files > 329

python-nevow-0.9.32-2mdv2010.0.noarch.rpm

from nevow import rend, loaders, tags as t
from nevow.taglibrary import cal

class Calendar(rend.Page):
    addSlash = True
    year = None
    month = None
    def __init__(self, year=None, month=None):
        if year is not None and month is not None:
            self.year = year
            self.month = month

    def locateChild(self, ctx, segments):
        if len(segments) >= 2:
            year, month = segments[:2]
            return Calendar(int(year), int(month)), segments[2:]
        return super(Calendar, self).locateChild(ctx, segments)

    def data_date(self, ctx, data):
        if self.year is None or  self.month is None:
            return None
        return int(self.year), int(self.month)
        
    docFactory = loaders.stan(
        t.html[
            t.head[
                t.title["Calendar Example"],
                cal.calendarCSS
            ],
            t.body[
                t.invisible(data=t.directive('date'), render=cal.cal)
            ]
        ]
    )