Commits

Anonymous committed c3e2533

Allow apps to be mounted with the same script_name passed in as they are already instantiated with. Fumanchu asked for this earlier, or at least wondered about it. I realized it would allow apps to be compatible with both CP 3.1 and CP Trunk so I added it.

  • Participants
  • Parent commits bdebb72

Comments (0)

Files changed (2)

cherrypy/_cptree.py

         
         if isinstance(root, Application):
             app = root
-            if script_name != "":
-                raise ValueError, "Cannot specify a script name and pass an Application instance to cherrypy.mount"
+            if script_name != "" and script_name != app.script_name:
+                raise ValueError, "Cannot specify a different script name and pass an Application instance to cherrypy.mount"
             script_name = app.script_name
         else:
             app = Application(root, script_name)

cherrypy/test/test_objectmapping.py

         a = Application(object(), '/somewhere')
         self.assertRaises(ValueError, cherrypy.tree.mount, a, '/somewhereelse')
 
+        # When mounting an application instance, 
+        # we can't specify a script name in the call to mount.
+        a = Application(object(), '/somewhere')
+        try:
+            cherrypy.tree.mount(a, '/somewhere')
+        except ValueError:
+            self.fail("tree.mount must allow script_names which are the same")
+
         try:
             cherrypy.tree.mount(a)
         except ValueError: