wsgi-app + reload

9 views
Skip to first unread message

Diez B. Roggisch

unread,
May 13, 2008, 6:11:55 AM5/13/08
to cherrypy-users
Hi all,

I'm running a WSGI-app using this:

server = wsgiserver.CherryPyWSGIServer(('localhost', PORT), wsgi_apps,
server_name='localhost')
server.start()

However, what I'd like to have is that instead the "normal" cherrypy
engine is used so that I can configure & use the autoreload-feature.

I tried a few ways but failed miserably - any suggestions on how to
proceed on that?

Diez


Sylvain Hellegouarch

unread,
May 13, 2008, 8:44:16 AM5/13/08
to cherryp...@googlegroups.com
Off the top of my head:

import cherrypy

class Dummy: pass

wsgi_app = ...

cherrypy.tree.graft(wsgi_app, '/some/path')
cherrypy.quickstart(Dummy(), '/')


Your WSGI application is just grafted and served by the WSGI server but
the whole CherryPy engine is started as well hence you can use autoreload
and other goodies :)

Hope that helps,
- Sylvain


--
Sylvain Hellegouarch
http://www.defuze.org

Diez B. Roggisch

unread,
May 13, 2008, 10:05:34 AM5/13/08
to cherryp...@googlegroups.com
On Tuesday 13 May 2008 14:44:16 Sylvain Hellegouarch wrote:
> Off the top of my head:
>
> import cherrypy
>
> class Dummy: pass
>
> wsgi_app = ...
>
> cherrypy.tree.graft(wsgi_app, '/some/path')
> cherrypy.quickstart(Dummy(), '/')
>
>
> Your WSGI application is just grafted and served by the WSGI server but
> the whole CherryPy engine is started as well hence you can use autoreload
> and other goodies :)

I will try that, one question though: it is necessary that my wsgi-app is
served from root. will that work as well? I don't mind serving dummy from
some arbitrary url. But the app itself must be root.

Diez

Sylvain Hellegouarch

unread,
May 13, 2008, 10:13:30 AM5/13/08
to cherryp...@googlegroups.com

Sure:

import cherrypy

def application(environ, start_response):
start_response("200 OK", [])
return ["Hello world"]

cherrypy.tree.graft(application, '')
cherrypy.quickstart()

- Sylvain

Diez B. Roggisch

unread,
May 13, 2008, 10:23:07 AM5/13/08
to cherryp...@googlegroups.com
>
> Sure:
>
> import cherrypy
>
> def application(environ, start_response):
> start_response("200 OK", [])
> return ["Hello world"]
>
> cherrypy.tree.graft(application, '')
> cherrypy.quickstart()

That did not work, however passing a Dummy and mapping it to some arbitrary
path works. Now I only have to figure out how to make the reloading-error I'm
getting go disappear, but that is most probably related to some packaging
problems we do suffer from here. Thanks for your help!

Diez

Sylvain Hellegouarch

unread,
May 13, 2008, 10:26:20 AM5/13/08
to cherryp...@googlegroups.com

>
>>
>> Sure:
>>
>> import cherrypy
>>
>> def application(environ, start_response):
>> start_response("200 OK", [])
>> return ["Hello world"]
>>
>> cherrypy.tree.graft(application, '')
>> cherrypy.quickstart()
>
> That did not work,

Now that is strange since that code was pasted straight from IDLE and
running just fine.Maybe a CP version difference.

- Sylvain


Reply all
Reply to author
Forward
0 new messages