def on_request(self):
    session = self.request.session
    query = session.query(Vote).filter_by(type='simple')
    self.simple_vote.choices = [(vote.id, vote.title) for vote in query.order_by(Vote.shortcode)]
    query = session.query(Vote).filter_by(type='complex')
    self.complex_vote.choices = [(vote.id, vote.title) for vote in query.order_by(Vote.shortcode)]
    query = session.query(Election).filter_by(type='majorz')
    self.majorz_election.choices = [(election.id, election.title) for election in query.order_by(Election.shortcode)]
    query = session.query(Election).filter_by(type='proporz')
    self.proporz_election.choices = [(election.id, election.title) for election in query.order_by(Election.shortcode)]
    query = session.query(ElectionCompound)
    query = query.order_by(ElectionCompound.shortcode)
    self.election_compound.choices = [(election_compound.id, election_compound.title) for election_compound in query]
    self.tags_simple_vote.text = '\n'.join(sorted([tag.usage for tag in self.get_widgets('simple_vote').values()]))
    self.tags_complex_vote.text = '\n'.join(sorted([tag.usage for tag in self.get_widgets('complex_vote').values()]))
    self.tags_majorz_election.text = '\n'.join(sorted([tag.usage for tag in self.get_widgets('majorz_election').values()]))
    self.tags_proporz_election.text = '\n'.join(sorted([tag.usage for tag in self.get_widgets('proporz_election').values()]))
    self.tags_election_compound.text = '\n'.join(sorted([tag.usage for tag in self.get_widgets('election_compound').values()]))
def on_request(self):
    session = self.request.session
    query = session.query(Vote).filter_by(type='simple')
    self.simple_vote.choices = [(vote.id, vote.title) for vote in query.order_by(Vote.shortcode)]
    query = session.query(Vote).filter_by(type='complex')
    self.complex_vote.choices = [(vote.id, vote.title) for vote in query.order_by(Vote.shortcode)]
    query = session.query(Election).filter_by(type='majorz')
    self.majorz_election.choices = [(election.id, election.title) for election in query.order_by(Election.shortcode)]
    query = session.query(Election).filter_by(type='proporz')
    self.proporz_election.choices = [(election.id, election.title) for election in query.order_by(Election.shortcode)]
    query = session.query(ElectionCompound)
    query = query.order_by(ElectionCompound.shortcode)
    self.election_compound.choices = [(election_compound.id, election_compound.title) for election_compound in query]
    self.tags_simple_vote.text = '\n'.join(sorted([tag.usage for tag in self.get_widgets('simple_vote').values()]))
    self.tags_complex_vote.text = '\n'.join(sorted([tag.usage for tag in self.get_widgets('complex_vote').values()]))
    self.tags_majorz_election.text = '\n'.join(sorted([tag.usage for tag in self.get_widgets('majorz_election').values()]))
    self.tags_proporz_election.text = '\n'.join(sorted([tag.usage for tag in self.get_widgets('proporz_election').values()]))
    self.tags_election_compound.text = '\n'.join(sorted([tag.usage for tag in self.get_widgets('election_compound').values()]))