Help debugging 404 from cherrypy.tree.mount()

John Stile <[email protected]>
Newsgroups gmane.comp.python.cherrypy
Message-ID <[email protected]>
I am using CherryPy-5.3.0, mod_wsgi-4.4, and apache 2.4

My .wsgi file has a get_app() function to instantiate application

This always does the right thing, and I get a response.
def get_app(config=None):
    return cherrypy.Application(Root(), script_name=None, config=conf)
application = get_app(config=conf)

I am trying to migrate from cherrypy.Application to cherrypy.tree, so that 
I can have several mount statements.

This always shows a 404, but I see no python errors, and Apache shows the 
proper request.
def get_app(config=None):
    cherrypy.config.update(config)
    cherrypy.tree.mount(Root(),script_name='' ,config=config)
    return cherrypy.tree
application = get_app(config=conf)

I have tried to minimize the extra information above, to keep this short.  
Below I will show my full wsgi file and apache config.

--------------------------
myproject.wsgi BEGIN
--------------------------
import os
import sys

# Apache base for the app
here = os.path.dirname(__file__)

# Activate virtualenv
activate_this = os.path.join( here, 'venv', 'bin','activate_this.py')
execfile(activate_this, dict(__file__=activate_this))

# Add to python path 
sys.path.insert(0,here)

# Not sure about this one
sys.stdout = sys.stderr

# Time for pie
import cherrypy

cherrypy.config.update({'environment': 'embedded'})

@cherrypy.popargs('name')
class Root(object):
    @cherrypy.expose
    def index(self, name):
        return 'Hello {}'.format(name)

conf = {
    '/': {
        'log.access_file' : os.path.abspath(os.path.join( 
os.path.dirname(__file__),'logs','access.log')),
        'log.error_file' : os.path.abspath(os.path.join( 
os.path.dirname(__file__),'logs','error.log')),
        'tools.staticdir.root' : os.path.abspath(os.path.dirname(__file__)),
        'tools.response_headers.on': True,
        'tools.response_headers.headers': [('Content-Type', 'text/plain')],
    }
}
def get_app(config=None):
    # This Works
    #return cherrypy.Application(Root(), script_name=None, config=conf)
    # This Fails
    cherrypy.config.update(config)
    cherrypy.tree.mount(Root(),script_name='' ,config=config)
    return cherrypy.tree

application = get_app(config=conf) 
--------------------------
myproject.wsgi END
--------------------------
--------------------------
Apache config BEGIN
--------------------------
        WSGIScriptAlias  /cherrypy 
/var/www/localhost/wsgi/project_cherrypy/myproject.wsgi
        <Directory "/var/www/localhost/wsgi/project_cherrypy">
            AllowOverride None
        Options None
        Require all granted
        </Directory>
--------------------------
Apache config END
--------------------------

Calling it:
    http://localhost/cherrypy/joe/

Response when I use cherrypy.Application()
Hello joe

Logs when I use cherrypy.Application()
==> /var/log/apache2/error_log <==
[Mon May 02 21:11:34.569663 2016] [wsgi:info] [pid 19923] [client 
::1:51401] mod_wsgi (pid=19923, process='', 
application='localhost|/cherrypy'): Loading WSGI script 
'/var/www/localhost/wsgi/project_cherrypy/myproject.wsgi'.

==> /var/log/apache2/access_log <==
::1 - - [02/May/2016:21:11:34 -0700] "GET /cherrypy/joe/ HTTP/1.1" 200 9

==> logs/access.log <==
::1 - - [02/May/2016:21:11:34] "GET /cherrypy/joe/ HTTP/1.1" 200 9 "" 
"Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0"

Response when cherrypy.tree.mount()
404 Not Found 

The path '/cherrypy/joe/' was not found.


Logs when I use cherrypy.tree.mount()

==> /var/log/apache2/error_log <==
[Mon May 02 21:15:06.429073 2016] [wsgi:info] [pid 18153] [client 
::1:51425] mod_wsgi (pid=18153, process='', 
application='localhost|/cherrypy'): Reloading WSGI script 
'/var/www/localhost/wsgi/project_cherrypy/myproject.wsgi'.

==> /var/log/apache2/access_log <==
::1 - - [02/May/2016:21:15:06 -0700] "GET /cherrypy/joe/ HTTP/1.1" 404 745

==> logs/access.log <==
::1 - - [02/May/2016:21:15:06] "GET /cherrypy/joe/ HTTP/1.1" 404 745 "" 
"Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0"

-- 
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.