def test_route_repr(self): self.assertEqual( webapp2.SimpleRoute(r"/<foo>", None).__repr__(), "<SimpleRoute('/<foo>', None)>", ) self.assertEqual( str(webapp2.SimpleRoute(r"/<foo>", None)), "<SimpleRoute('/<foo>', None)>" )
self.response.out.write("Memcache key %s = %s.<br>\n" % (key, values)) if type(values) is dict: for k, value in values.iteritems(): self.response.out.write( "<p><b>%s</b>%s</p>" % (k, dict( (key, getattr(value, key)) for key in dir(value)))) if self.request_bool("clear", False): memcache.delete(key, namespace=namespace) application = webapp2.WSGIApplication( [ DomainRoute( 'smarthistory.khanacademy.org', [webapp2.SimpleRoute('/.*', smarthistory.SmartHistoryProxy)]), ('/', homepage.ViewHomePage), ('/about', util_about.ViewAbout), ('/about/blog', blog.ViewBlog), RedirectRoute('/about/blog/schools', redirect_to='http://ka-implementations.tumblr.com/', defaults={'_permanent': False}), ('/about/blog/.*', blog.ViewBlogPost), ('/about/the-team', util_about.ViewAboutTheTeam), RedirectRoute( '/about/getting-started', redirect_to= 'http://khanacademy.desk.com/customer/portal/articles/329323-where-do-i-begin-how-should-i-get-started-' ), ('/about/discovery-lab', util_about.ViewDiscoveryLab), ('/about/tos', ViewTOS),
def test_build(self): route = webapp2.SimpleRoute('/', None) self.assertRaises(NotImplementedError, route.build, None, None, None)
def wrapper(func): # Do we want to extend this to full Routes someday? # Won't work with batched_mapperworker's slurp-all-but-pass-no-args approach, so need bwcompat self.router.add(webapp2.SimpleRoute(handler=func, *args, **kwargs)) return func