Anonymous avatar Anonymous committed 2d2a81f

Proof of concept idea to handle multiple apps: adding a cherrypy.url() function and a is_app_root class attribute for apps

Comments (0)

Files changed (2)


 __version__ = '2.2.0-beta'
 import datetime
+import os.path
 import sys
 import types
     logfunc(msg, context, severity)
+def url(u):
+    return request.app_path + u


         objectTrail = _cputil.get_object_trail(objectpath)
         names = [name for name, candidate in objectTrail]
+        # Try to get app_path:
+        current_objectpath = objectpath
+        for i in xrange(len(objectTrail) - 1, -1, -1):
+            name, candidate = objectTrail[i]
+            if getattr(candidate, 'is_app_root', False):
+                cherrypy.request.app_path = current_objectpath
+                break
+            current_objectpath = os.path.dirname(current_objectpath)
         # Try successive objects (reverse order)
         mounted_app_roots = cherrypy.tree.mount_points.values()
         for i in xrange(len(objectTrail) - 1, -1, -1):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.