On Thu, Jun 25, 2009 at 2:23 PM, Thomas G. Willis<[email protected]> wrote:
>
>
>
> On Jun 25, 12:19 pm, Marius Gedminas <[email protected]> wrote:
>> On Thu, Jun 25, 2009 at 05:22:24AM -0700, Thomas G. Willis wrote:
>> > ok, I've been trying to figure this out for a while, and I haven't
>> > quite cracked this nut.
>>
>> > What I'm trying to do is understand the mechanics of mounting a pylons
>> > app as anothers controller. To get this sort of effect...
>>
>> >http://myapp:5000/home/index<------site container
>> > and
>> >http://myapp:5000/registration/register/index<---- another pylons app
>>
>> > in my registration.py controller of my container app I have...
>>
>> > from paste.deploy import loadapp
>> > RegistrationController = loadapp("config:/path/to/config.ini")
>>
>> > in my routing.py of my container app I have...
>>
>> > map.connect("registration/{path_info:.*}",controller="registration")
>>
>> I don't think you can chain routes this way.
>
> Would you mind elaborating? It seems it should work. Doesn't routes
> just pick up the SCRIPT_NAME and PATH_INFO from environ? And isn't the
> purpose of the above map.connect to set those 2 variables
> appropriately? What's the magic I'm missing?
It should be OK. 'path_info' is a magic variable that sets the real
SCRIPT_NAME and PATH_INFO to the subapplication, as well as setting
the routing variable.
I wonder if you have the same controller_scan problem I mentioned in
an earlier message today. If so, instantiate your route map with a
list of controller names you think should be valid, and see if that
clears up the problem.
def my_controllers():
return ["registration"]
map = routes.Mapper(controller_scan=my_controllers)
Also turn on full debug logging. (Set the root logger to debug, or a
logger for routes.middleware.)
I would think that a 404 indicates a routing problem. A missing
controller module would raise ImportError, and a malformed controller
would raise something else. Make sure you're in development mode.
(In production mode, missing controllers are disguised as 404s I
think.)
I hope that nested Pylons applications work because I want to split up
one of my applications this summer.
Be sure to set full_stack=False in the myapp.middleware.make_app()
call. I think you may also want to adjust the 'if full_stack:' in the
function because the default doesn't look quite right to me. I think
you want the outer app to handle sessions and errors but the inner app
to have its own routing, no?
Because of the 'full_stack' argument, it may not be appropriate to
instantiate the inner app via paste.deploy. You may have better luck
calling make_app directly, and creating the desired configuration
variables in the pseudo-controller module. That is, assuming you're
not passing a lot of variables through from the top-level
configuration.
You can also set the WSGI application to __controller__ rather than
RegistrationController. Or you may want a custom __controller__
function that instantiates the application with a particular
configuration and returns it.
--
Mike Orr <[email protected]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---