Guest User

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
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  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)
Add Comment
Please, Sign In to add comment