This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

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

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 0.54 KB  |  views: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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)
clone this paste RAW Paste Data