[Twisted-web] Use Nevow in conjunction with XMLRPC
Remi Cool
mailinglists at smartology.nl
Tue Nov 15 03:24:19 MST 2005
Remi Cool wrote:
>G'day,
>
>My goal is to create a Twisted server that implements XMLRPC, Nevow and
>PHP (for transition of the old webapp).
>
>XMLRPC works again (thanks to Daniel and Matt) ... but I can't get Nevow
>working as a child of the httpResource. Or is there a better (Twisted)
>way of doing this (without using tap)?
>
>
I've got it running somewhat using:
class httpResource(resource.Resource):
implements(resource.IResource)
def __init__(self, service):
resource.Resource.__init__(self)
self.service = service
self.putChild('RPC2', Example(self.service))
self.putChild('formtest', WebForm(Implementation()))
def render(self, request):
self._clientIP = request.getClientIP()
return resource.Resource.render(self, request)
def render_GET(self, request):
"""Process HTTP GET Requests."""
print 'GET: request ->', request
return '<html><body><h3>Not Implemented</h3></body></html>'
def getChild(self, path, request):
"""This method handles http calls"""
print 'getChild path:', path
print 'getChild request:', request
if path=="":
return httpResource(self.service)
else:
return httpResource(self.service)
components.registerAdapter(httpResource, IowwService, resource.IResource)
def main():
""""""
application = service.Application('OWW', uid=1000, gid=1000)
s = owwService()
serviceCollection = service.IServiceCollection(application)
internet.TCPServer(7080,
appserver.NevowSite(resource.IResource(s))).setServiceParent(serviceCollection)
serviceCollection.startService()
reactor.run()
Now I need the form to render, all I got was the h1.
>The code:
>
>from formless.annotate import TypedInterface, Integer, String
>from nevow import rend, tags, loaders
>from formless import webform
>
>class ISimpleMethod(TypedInterface):
> def simple(self,
> name=String(description="Your name."),
> age=Integer(description="Your age.")):
> """Simple
>
> Please enter your name and age.
> """
>
>class Implementation(object):
>
> implements(ISimpleMethod)
>
> def simple(self, name, age):
> print "Hello, %s, who is %s" % (name, age)
>
>
>class WebForm(rend.Page):
> document = loaders.stan(tags.html[
> tags.body[ tags.h1["Here is the form:"],
> webform.renderForms('original')]])
>
>
>
>class httpResource(resource.Resource):
>
> implements(resource.IResource)
>
> def __init__(self, service):
> resource.Resource.__init__(self)
> self.service = service
> self.putChild('RPC2', Example(self.service))
> self.putChild('formtest',
>resource.Resource(WebForm(Implementation())))
>
> def render(self, request):
> self._clientIP = request.getClientIP()
> return resource.Resource.render(self, request)
>
> def render_GET(self, request):
> """Process HTTP GET Requests."""
> print 'GET: request ->', request
> return '<html><body><h3>Not Implemented</h3></body></html>'
>
> def getChild(self, path, request):
> """This method handles http calls"""
> print 'getChild path:', path
> print 'getChild request:', request
> if path=="":
> return httpResource(self.service)
> else:
> return httpResource(self.service)
>
>components.registerAdapter(httpResource, IowwService, resource.IResource)
>
>
>
>_______________________________________________
>Twisted-web mailing list
>Twisted-web at twistedmatrix.com
>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>
>
>
More information about the Twisted-web
mailing list