def __init__(self, mapping, fvars): # Parent constructor web.application.__init__(self, mapping, fvars) #@UndefinedVariable # The views are bound once for all to the configuration config.views = web.template.render("app/views/", globals={ "all_seasons": lambda: Season.all(), "all_polls": lambda: Poll.all(), "webparts": webparts, "formatting": formatting, "dates": dates, "zip": zip, "getattr": getattr, "hasattr": hasattr, "class_name": lambda x: x.__class__.__name__, "namedtuple": collections.namedtuple, "config": config, "result_statuses": Result.STATUSES, "Events": Events }) # The ORM is bound once since it dynamically loads the engine from the configuration config.orm = meta.init_orm(lambda : config.engine) # Binds the hooking mechanism & the SQL Alchemy processor self.add_processor(web.loadhook(http.init_hooks)) self.add_processor(web.unloadhook(http.execute_hooks)) self.add_processor(http.sqlalchemy_processor) # Binds the webparts initialization mechanism self.add_processor(web.loadhook(webparts.init_webparts))
def __init__(self): # Grid initialization super(EditSeasonsGrid, self).__init__(Season, Season.all(order_by_clause=Season.start_year)) #@UndefinedVariable # Grid configuration inc = [ID_READONLY(self.id), START_YEAR(self.start_year), END_YEAR(self.end_year)] self.configure(include=inc)
def test_all(self): all_seasons = Season.all() self.assertEqual(len(all_seasons), 2) # Checks the order by clause self.assertEqual(all_seasons[0].id, 2) self.assertEqual(all_seasons[1].id, 1)
def __init__(self): # FieldSet initialization super(NewTournamentFieldSet, self).__init__(Tournament) # Creation of a customized date field to edit the tournament's date self.append(create_date_field("formatted_tournament_dt", "tournament_dt", DT_FORMAT)) # FieldSet configuration season_options = [("Saison %s (%s - %s)" %(season.id, season.start_year, season.end_year), season.id) for season in Season.all()] inc = [SEASON(self.season, season_options), FORMATTED_DT(self.formatted_tournament_dt), BUYIN(self.buyin)] self.configure(include=inc)