Config parsing with IronPython

133 views
Skip to first unread message

Dave Wald

unread,
Mar 4, 2011, 9:08:37 AM3/4/11
to cherryp...@googlegroups.com
Hi all - newbie here...
First off, CherryPy is the coolest thing since sliced ice-cream. I'm not
really a web guy, but need to get into it. Done some ASP.Net stuff, for
work, but I hate it. This is what I want to use, but I need to use it
with IronPython. IPy is now up to version 2.7 and it rocks. For the most
part.
I've gotten CP running on it in basic default-config mode, but running
through the tutorial examples, the config parser is having a problem.
Obviously, there is no compiler module in IPy. It's deprecated since 2.6.
So, the config parser is not returning an ast for the socket_server
option, just an eval'd string.
The Builder().build function is barfing on it.
I saw on the tracker that there were some efforts back in '06-'07 to
patch for IronPython 1.0, but... things have changed since then.
I did need to patch the wsgiserver.init.py just a bit for the _rbuf
stuff, but no problem so far.

Question: Any plans of upgrading the config option parsing to use the
newer AST or Parsing modules, or do I just wing it here?
I am NOT a compiler guy. I can muddle through with it some, but, like,
damn. (To paraphrase Will Smith).
I think I could hack around on it and get something going, but just
wanted to check with y'all first and see if there was anything in the
works before I go off half-cocked here.

Thanks for your attention,

Dave

Sylvain Hellegouarch

unread,
Mar 4, 2011, 9:36:34 AM3/4/11
to cherryp...@googlegroups.com
Hi Dave,

Welcome.

The best bet would be to replace the config file by a config dict so that no magic would need to happen:

cherrypy.config.update(conf_file.cfg)

becomes

cherrypy.config.update({'server.socket_port': 8900, 'server.socket_host': '0.0.0.0' ... })

For the application, you can follow the same idea:

cherrypy.tree.mount(app, '/', app_file.cfg) or cherrypy.quickstart(app, '/', app_file.cfg)

becomes

cherrypy.tree.mount(app, '/', {'/': {'tools.gzip.on': True ... }}) or cherrypy.quickstart(app, '/',  {'/': {'tools.gzip.on': True ... }})
 
I don't believe there are any plan to upgrade the config loader for now.

--
- Sylvain
http://www.defuze.org
http://twitter.com/lawouach

Dave Wald

unread,
Mar 4, 2011, 9:44:17 AM3/4/11
to cherryp...@googlegroups.com
Sylvain,

Excellent suggestion. Thank you! I will try that tonight.

Dave
--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherryp...@googlegroups.com.
To unsubscribe from this group, send email to cherrypy-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en.

Naveen

unread,
Aug 24, 2011, 3:35:38 PM8/24/11
to Dave Wald, cherryp...@googlegroups.com
Or you can use the fepy version of socket.py.
From an interactive python session, do:


import fepy
fepy.install_option('fileobject')

import cherrypy
class Empty(object):
@cherrypy.expose
def hello(self):
return "hello"

config = {'/' :
{
'engine.autoreload_on':False,
'log.screen':False,
'server.socket_host' : "0.0.0.0",
'server.socket_port' : 8080,
'server.thread_pool' : 10,
'engine.autoreload_on' : False,
'log.screen' : False
}
}

import threading
class ThreadClass(threading.Thread):
def run(self):
cherrypy.tree.mount(Empty(), "/", config = config)
cherrypy.quickstart(Empty(), "/", config = config)

t = ThreadClass()
t.start()

# http://127.0.0.1:8080/hello


Reply all
Reply to author
Forward
0 new messages