Debugging/testing outside a cherrypy app

8 views
Skip to first unread message

Sheco

unread,
Jul 20, 2006, 5:51:44 PM7/20/06
to cherrypy-devel
Hello,

I would like to know how to call some method from of a cherrypy app
code in the interactive python shell, it uses the request/response
variables, currently it is not possible as far as I know, because
cherrypy.request and cherrypy.response variables are empty when the
server is not started and there is (obviously) no request to respond
to. Maybe if they could have an empty default state I could perform the
tests on the interactive shell simulating a new server serving a fake
empty request. Maybe I could get my hands into writting this but I'd
like to know first if it is a bad idea.

Any suggestions to this? Should I be posting this to cherrypy-users
instead?

Christian Wyglendowski

unread,
Jul 20, 2006, 6:09:13 PM7/20/06
to cherryp...@googlegroups.com, cherryp...@googlegroups.com
On 7/20/06, Sheco <sergi...@gmail.com> wrote:
I would like to know how to call some method from of a cherrypy app
code in the interactive python shell, it uses the request/response
variables, currently it is not possible as far as I know, because
cherrypy.request and cherrypy.response variables are empty when the
server is not started and there is (obviously) no request to respond
to. Maybe if they could have an empty default state I could perform the
tests on the interactive shell simulating a new server serving a fake
empty request. Maybe I could get my hands into writting this but I'd
like to know first if it is a bad idea.

Well, if you want to interactively poke around in your CP app, there are a couple good options that I know of.

First, if you would like to do it all via the browser, check out HTTPREPL:
http://projects.amor.org/misc/wiki/HTTPREPL

That will give you basically a Python interpreter in your browser.  It was written by Robert Brewer (lead CP dev) and is very handy.

If you'd rather have it the other way around, you can comlpetely run your CP app in the interactive interpreter.  For details on how to do that, check out the screencast that I made:
http://docs.cherrypy.org/running-cherrypy-from-the-interactive-interpreter

Hope this is helpful.  Let me know if I misunderstood.

Any suggestions to this? Should I be posting this to cherrypy-users
instead?

Yep, probably - I copied this message there so reply there if you want to discuss this further.

Christian

fumanchu

unread,
Aug 4, 2006, 12:40:18 PM8/4/06
to cherrypy-devel
Sheco wrote:
> I would like to know how to call some method from of a cherrypy app
> code in the interactive python shell, it uses the request/response
> variables, currently it is not possible as far as I know, because
> cherrypy.request and cherrypy.response variables are empty when the
> server is not started and there is (obviously) no request to respond
> to. Maybe if they could have an empty default state I could perform the
> tests on the interactive shell simulating a new server serving a fake
> empty request. Maybe I could get my hands into writting this but I'd
> like to know first if it is a bad idea.

Just a note that this has already been worked on for CP 3. There will
be dummy request and response objects, with default values.


Robert Brewer
System Architect
Amor Ministries
fuma...@amor.org

Sheco

unread,
Aug 8, 2006, 12:19:42 PM8/8/06
to cherrypy-devel
Even better, now that's exactly what I wanted, thanks, Robert Brewer.

Reply all
Reply to author
Forward
0 new messages