1. Matthew Turk
  2. yt_ajax

Commits

Matthew Turk  committed 552e985

Adding a test of dynamic tree manipulation in CherryPy

  • Participants
  • Parent commits 2ffa549
  • Branches default

Comments (0)

Files changed (1)

File cp/test_dynamic.py

View file
+import cherrypy
+
+class Something(object):
+    def __init__(self, val):
+        self.val = val
+
+    def index(self):
+        return self.val
+    index.exposed = True
+
+class HelloWorld(object):
+    def index(self):
+        return "Hello world!"
+    index.exposed = True
+
+    def add_function(self, func_name, return_value):
+        cherrypy.tree.mount(Something(return_value),
+                '/functions/%s' % func_name)
+    add_function.exposed = True
+
+cherrypy.tree.mount(HelloWorld(), '/')
+cherrypy.quickstart()