Remi Cool wrote:
Is it possible to run a nevow site and and serve XMLRPC (or SOAP)
requests on a single port?
I've tried to make it work some time ago, but to no avail.

I've attached an example extracted (with names changed to protect the
guilty) from my app's tac file, which gives one possible approach ...
in my case I've only set up xmlrpc and a static web site, but I
think adding a Nevow service would not be much different in
principle.

Gracefully handling a web client wandering into the xmlrpc area
or vice versa is left as an exercise to the reader, but I don't
expect it would be all that difficult.

There may be a more elegant way to do this -- commentary from the
twisted gurus is welcome (as always :).

Steve

application = Application('My_App')
myapp_hub = MyApp()
myapp_hub.setServiceParent(application)
myappchkr = myapp_hub.credchkr

###  HTTP Multiplexer resource  ###
# provides the root for My_App's HTTP resources.
# Base URLs:
#     * Static Web:  '/'
#     * XML-RPC:     '/RPC2'
# TODO:  handle requests sent to the wrong URL gracefully.
mux = web.resource.Resource()

###  My_App XML-RPC interface  ###
xr = myappcred.XmlrpcRealm('My_App XML-RPC',
                          engine=myapp_hub)
xp = portal.Portal(xr)
xp.registerChecker(myappchkr)
mux.putChild('RPC2', myappcred.BasicAuthResource(xp))

###  My_App Static web server  ###
sr = myappcred.StaticHttpRealm('My_App Web', 'web')
sp = portal.Portal(sr)
sp.registerChecker(myappchkr)
res = myappcred.BasicAuthResource(sp)
res.processors = {'.rpy': script.ResourceScript}
mux.putChild('', res)

webport = 8080 # or whatever
site = web.server.Site(mux)
webserv = internet.TCPServer(webport, site)
webserv.setServiceParent(myapp_hub)


_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

Reply via email to