tree.mount doesn't do what I expect

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

tree.mount doesn't do what I expect

Tim Roberts

I'm developing a CherryPy 2.2.1 application.  I happened to have an
occasion where it would be convenient to mount separate handlers for
parts of the URL tree.  If I do this:

  cherrypy.tree.mount( MyApplication(), baseurl="/", conf=config )
  cherrypy.tree.mount( Query(), baseurl="/query/", conf=config )
  cherrypy.tree.mount( Profile(), baseurl="/register/", conf=config )

then I get a 404 when I try to reference /query/ or /register.  But if I
do this (which is deprecated):

  cherrypy.tree.mount( MyApplication(), baseurl="/", conf=config )
  cherrypy.root.query = Query()
  cherrypy.root.register = Profile()

then it works exactly as I expect.  I tried a little debugging, and I
could see that it got into mapPathToObject, but the objects on the tree
weren't instances of my classes, they were instances of cherrypy.tree,
which doesn't have an "exposed" attribute, so it failed.

Am I misunderstanding something here?

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: tree.mount doesn't do what I expect

Sylvain Hellegouarch

Tim Roberts wrote:

> I'm developing a CherryPy 2.2.1 application.  I happened to have an
> occasion where it would be convenient to mount separate handlers for
> parts of the URL tree.  If I do this:
>
>   cherrypy.tree.mount( MyApplication(), baseurl="/", conf=config )
>   cherrypy.tree.mount( Query(), baseurl="/query/", conf=config )
>   cherrypy.tree.mount( Profile(), baseurl="/register/", conf=config )
>
> then I get a 404 when I try to reference /query/ or /register.  But if I
> do this (which is deprecated):
>
>   cherrypy.tree.mount( MyApplication(), baseurl="/", conf=config )
>   cherrypy.root.query = Query()
>   cherrypy.root.register = Profile()
>
> then it works exactly as I expect.  I tried a little debugging, and I
> could see that it got into mapPathToObject, but the objects on the tree
> weren't instances of my classes, they were instances of cherrypy.tree,
> which doesn't have an "exposed" attribute, so it failed.
>
> Am I misunderstanding something here?
>

I can't really try now but would you mind trying without the trailing
'/' on the /query and /profile paths?

- Sylvain

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: tree.mount doesn't do what I expect

Tim Roberts
Sylvain Hellegouarch wrote:
Tim Roberts wrote:
  
I'm developing a CherryPy 2.2.1 application.  I happened to have an
occasion where it would be convenient to mount separate handlers for
parts of the URL tree.  If I do this:

  cherrypy.tree.mount( MyApplication(), baseurl="/", conf=config )
  cherrypy.tree.mount( Query(), baseurl="/query/", conf=config )
  cherrypy.tree.mount( Profile(), baseurl="/register/", conf=config )

then I get a 404 when I try to reference /query/ or /register.  But if I
do this (which is deprecated):

  cherrypy.tree.mount( MyApplication(), baseurl="/", conf=config )
  cherrypy.root.query = Query()
  cherrypy.root.register = Profile()

then it works exactly as I expect.  I tried a little debugging, and I
could see that it got into mapPathToObject, but the objects on the tree
weren't instances of my classes, they were instances of cherrypy.tree,
which doesn't have an "exposed" attribute, so it failed.

Am I misunderstanding something here?

    

I can't really try now but would you mind trying without the trailing
'/' on the /query and /profile paths?
  

Hmm, I was sure I had tried that, but I did it one more time just to be sure, and it works.  Very interesting.  I had convinced myself that the leading and trailing slashes were stripped off everywhere that matters.

Thanks for the suggestion.
-- 
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: tree.mount doesn't do what I expect

Sylvain Hellegouarch


>
> Hmm, I was sure I had tried that, but I did it one more time just to be
> sure, and it works.  Very interesting.  I had convinced myself that the
> leading and trailing slashes were stripped off everywhere that matters.
>

The leading one is but not the trailing one. Maybe something we should
do automatically though.

Glad it worked.

- Sylvain

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---