Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. class RouteDetails(ndb.Model):
  2. """Get list of routes from Datastore """
  3. RouteName = ndb.StringProperty()
  4.  
  5. @classmethod
  6. def query_routes(cls):
  7. return cls.query().order(-cls.RouteName)
  8.  
  9.  
  10. class RoutesPage(webapp2.RequestHandler):
  11. def get(self):
  12. adminLink = authenticate.get_adminlink()
  13. authMessage = authenticate.get_authmessage()
  14. self.output_routes(authMessage,adminLink)
  15.  
  16. def output_routes(self,authMessage,adminLink):
  17. self.response.headers['Content-Type'] = 'text/html'
  18. html = templates.base
  19. html = html.replace('#title#', templates.routes_title)
  20. html = html.replace('#authmessage#', authMessage)
  21. html = html.replace('#adminlink#', adminLink)
  22. html = html.replace('#content#', '')
  23. self.response.out.write(html + '<ul>')
  24. list_name = self.request.get('list_name')
  25. #version_key = ndb.Key("List of routes", list_name or "*notitle*")
  26. routes = RouteDetails.query_routes().fetch(20)
  27.  
  28. for route in routes:
  29. routeLink = '<a href="route_instance?key={}">{}</a>'.format(
  30. route.Key, route.RouteName)
  31. self.response.out.write('<li>' + routeLink + '</li>')
  32. self.response.out.write('</ul>' + templates.footer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement