[IronPython] CherryPy 3 on top of IronPython 1.0... kind of working

M. David Peterson xmlhacker at gmail.com
Wed Sep 6 04:59:31 CEST 2006


FYI -- I've added Sylvains code base from this post to the
PyPod.NETClick-Once IP console app.  While there's more to this app
than just this,
if you access > http://pypod.net/console/index.html < from a Windows box,
Click install, a few moments later (and as long as your Python Lib directory
is located @ C:\Python24\Lib, if not, you will need to >>>
sys.path.appendthe proper location) you will be presented with the IP
1.0 Final console.

>>> import cptest

Will initialize an instance of CP and make it available via
http://localhost:8080

While there is still quite a bit more work to both integrate as well as
finish out, you can view the source for this app via the Trac interface @
http://dev.pypod.net, and as per the URI Sylvain pointed to earlier, you can
check out the SVN repository via http://src.pypod.net/trunk

More details on the overall features and extended plans for this project as
the week progresses, but for now this should provide a simple way of playing
with the CherryPy code base Sylvain posted earlier.

Enjoy!

On 9/5/06, Sylvain Hellegouarch <sh at defuze.org> wrote:
>
> All,
>
> First congratulations for the fantastic work you have done with
> IronPython.
>
> Tested against:
> IP 1.0 (binaries)
> CP 3 (recent svn trunk)
> Python 2.4.3
> .NET 2 on Windows XP (yeah my Linux system broke down...)
>
> Tonight I was trying to run CherryPy 3 [1](which will reach its first
> beta really soon but which is already extremely stable) with IronPython
> 1.0 and it kind of worked. I say kind of because of the following reasons:
>
> 1. It won't work from without hacking CherryPy's code. Considering the
> fact CP does some internal stuff using not (yet?) supported CPython
> functionnalities it is not a surprise.
>     a. First string.encode('hex') is not implemented so:
>
> >>> import sys
> >>> sys.path.append('c:\python24\lib')
> >>> import os
> >>> os.urandom(20).encode('hex')
> Traceback (most recent call last):
>   File , line 0, in <stdin>##46
>   File , line 0, in Encode##48
> LookupError: unknown encoding: hex
>
> The session module of CherryPy uses by default that method to generate
> fairly decent random IDs. There is a fallback by using:
>
> sha.new('%s' % random.random()).hexdigest()
>
> instead. It works fine when you fetch Seo Sanghyeon's sha.py module from
> [2].
>
>
>
>    b. Next CherryPy uses in some areas the inspect module as follow:
> >>> import inspect
> >>> def f(): pass
> ...
> >>> inspect.getargspec(f)[0]
> Traceback (most recent call last):
>   File , line 0, in <stdin>##84
>   File c:\python24\lib\inspect.py, line 678, in getargspec
>   File c:\python24\lib\inspect.py, line 616, in getargs
>   File , line 0, in get_Code##86
> NotImplementedError:
>
> That exception was not catched by CP, after added it to _cptools.py it
> worked better :)
>
>
>    c. CherryPy uses the signal module which is not part of IP. I simply
> modified the import as follow in _cpengine.py
> try:
>     import signal
> except:
>     signal = None
>
>
>   d. CP uses the logging module from the CPython stdlib which does not
> seem to work properly in IP because it uses the _getframe function.
> I simply commented out two lines in _cplogging.py to not access the
> logging module. To keep a trace of the request I just print them to
> stdout. :)
>
>   e. Finally because the default IP socket implementation does not
> support makefile, I had to use Seo's socket.py module in lieu. To avoid
> collision and because I did not want to recompile IP, I modified the
> import from _cpwsgiserver.py as follow:
>
> import ipsocket as socket
>
> ipsocket is just the name of the file under which I saved Seo's module.
> Could be Alf.py if you wanted to :)
>
>
>
> 2. After all those modification, I was able to start up the server like
> this:
> import sys
> sys.path.append('c:\python24\lib')
> # contains CherryPy
> sys.path.append('c:\python24\lib\site-packages')
> # misc is just a directory containing Seo's module sha.py, ipsocket.py
> and ssl.py
> sys.path.append('c:\python24\lib\site-packages\misc')
> import cherrypy
> class Root:
>     def index(self):
>         return "Hello"
>     # this could be set as a decorator @cherrypy.expose but this won't
> work I think from IP
>     index.exposed = True
>
> cherrypy.quickstart(Root())
> [05/Sep/2006:23:00:11] HTTP Serving HTTP on http://localhost:8080/
>
>
>
> 3. Now the fun part.
> The server does show it received and treats requests from Firefox 1.5,
> InternetExplorer 6 and httplib2 [3] a Python module for HTTP  requests
> handling  from CPython. However only in IE and httplib2 I was able to
> view/read the response content. Fx was hanging with no real reason,
> whether I used network.http.pipelining or not.
>
> So here we are, it kind of worked but it's far from being smooth yet.
> It's better than a few months ago however and there is less issues.
> Maybe this email will help fixing some issues and improve the situation
> even more. I would be very interested in making this work as I intend to
> run my little Atom Publishing Protocol implementation in Python using CP
> through IP.
>
> You can download the files from:
> http://src.pypod.net/branches/
>
> Simply add the directory you will unzip to sys.path
>
> Thanks,
> - Sylvain
> http://www.defuze.org
>
> [1]: http://svn.cherrypy.org/trunk/
> [2]: http://sparcs.kaist.ac.kr/~tinuviel/fepy/lib/
> [3]: http://bitworking.org/projects/httplib2/
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>



-- 
/M:D

M. David Peterson
http://mdavid.name | http://www.oreillynet.com/pub/au/2354
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060905/b4c93f55/attachment.html>


More information about the Ironpython-users mailing list