In my Pyramid application, I set up a composite application with my main app on /
and my admin portal on /admin
.
[composite:main]
use = egg:paste#urlmap
/ = mainapp
/admin = adminapp
[app:mainapp]
use = egg:myApp#main
[app:adminapp]
use = egg:myApp#admin
I also added two separate initialization methods in my __init__.py
method so that I could have two separate add_request_method
s and authentication policies – one for general users and the other for admins.
To test this, I added two routes, one as:
config.add_route('admin_login_handler', '/admin/login/')
for the admin portal login, and the other as:
config.add_route('login_handler', '/login/')
for the general site login. Supposedly, I would see two different templates, one for each view, and I would have a separate request object for admins and general users – self.request.admin
for admins and self.request.user
for users.
However, when I go to /admin/login/
, the /login/
template is shown. Basically, my main app's routes are now located under both /
and /admin
, and my admin routes are ignored. This is not what I wanted. But, I do get my desired self.request.admin
object when viewing /admin
routes, and my self.request.user
object on my /
routes, regardless of the template/view being shown.
How can I fix this so that routes with /admin/...
are not "remapped" with my /
routes, and I have two separate applications under two different routes prefixes?