SHARE
TWEET

How to create a controller method in Turbogears that can be called from within the controller, or rendered with a template

a guest Feb 26th, 2012 22 Never
  1. @expose("json")
  2. def artists(self, action="view",artist_id=None):
  3.     artists=session.query(model.Artist).all()
  4.     return dict(artists=artists)
  5.        
  6. artists = self.artists()
  7.        
  8. # The _artists method can be used from any other method
  9. def _artists(self, action, artist_id):
  10.     artists = session.query(model.Artist).all()
  11.     return dict(artists=artists)
  12.  
  13. @expose("json")
  14. #@identity.require(identity.non_anonymous())
  15. # error handlers, etc.
  16. def artists(self, action="view", artist_id=None):
  17.     return self._artists(action=action, artist_id=artist_id)
RAW Paste Data
Top