class ClockController(BaseController): def __init__(self): BaseController.__init__(self) self.ups = UserPropertySDB() @authorize(RemoteUser()) def now(self): item = self.ups.get_item(request.environ['REMOTE_USER']) if item: name = item.nickname time_diff = item.time_diff else: name = request.environ['REMOTE_USER'] time_diff = 0 time = datetime.datetime.now() time = str(time + datetime.timedelta(0, 0, 0, 0, 0, time_diff)) c.content = "Welcome, %s. Current time is %s (diff is %s)" % (name, time, str(time_diff)) return render('/derived/clock/now.html') @authorize(RemoteUser()) def customize(self): return render('/derived/clock/customize.html') @restrict('POST') @validate(schema = TimeDiffForm(), form = 'time_diff') @authorize(RemoteUser()) def save(self): up = UserProperty(request.environ['REMOTE_USER'], self.form_result['nickname'], int(self.form_result['time_diff'])) self.ups.put_item(up) redirect_to('now') def signout(self): redirect_to('now')
def __init__(self): BaseController.__init__(self) self.ups = UserPropertySDB()