<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi, I resolved the problem following your comments. Thak you. <br>
<br>
I am writting the solution for possible future similar problems and
close the topic.<br>
<br>
I defined my root resources (HTML, XML-RPP, SOAP, etc.):<br>
<br>
class RootResource(resource.Resource):<br>
"""Define the resources"""<br>
<br>
def __init__(self):<br>
resource.Resource.__init__(self)<br>
self.putChild('', Renders.Login())<br>
self.putChild('test', Renders.TestPage)<br>
self.putChild('loginHandler', HandleLogin())<br>
self.putChild('uploadHandler', HandleUpload())<br>
self.putChild('upload', Renders.Upload())<br>
self.putChild("SOAP", Converter())<br>
<br>
I set my resources as the site root and run the reactor.<br>
<br>
siteRoot = RootResource() <br>
reactor.listenTCP(8000, server.Site(siteRoot))<br>
<br>
<br>
<br>
Jean-Paul Calderone escribió:
<blockquote
cite="mid20070709141407.4947.1888526620.divmod.quotient.9437@ohm"
type="cite">Wasn't going to reply to this, for reasons which will be
obvious momentarily,
<br>
but I haven't seen a correct reply yet, so...
<br>
<br>
On Fri, 06 Jul 2007 09:46:38 +0200, Daniel de la Cuesta
<a class="moz-txt-link-rfc2396E" href="mailto:daniel.cuesta@iavante.es"><daniel.cuesta@iavante.es></a> wrote:
<br>
<blockquote type="cite"><!DOCTYPE html PUBLIC "-//W3C//DTD HTML
4.01 Transitional//EN">
<br>
<html>
<br>
<head>
<br>
<meta content="text/html;charset=ISO-8859-1"
http-equiv="Content-Type">
<br>
</head>
<br>
<body bgcolor="#ffffff" text="#000000">
<br>
Hi,<br>
<br>
<br>
<br>
I have a twisted web server running using "twisted.web.http".<br>
<br>
<br>
<br>
</blockquote>
<br>
You probably want to direct future questions on this topic to the
<br>
twisted-web mailing list, where you'll get more attention from
<br>
people more actively doing web things.
<br>
<br>
<blockquote type="cite">The objective of the server is to convert
files to another format.
<br>
Currently I upload the files and the conversion params using an HTTP
<br>
POST from a form.<br>
<br>
<br>
<br>
Now I want to add XML-RPC support to the conversion process. It means
<br>
the user could process the conversion using the http form or calling
<br>
directly the XML-RPC class.<br>
<br>
</blockquote>
<br>
HTTP POST is probably a better way to upload files, in general.
MIME-ish
<br>
encoding is a bit easier and has less overhead than base64 encoding.
<br>
<br>
<blockquote type="cite"><br>
<br>
This is my pages dispatch:<br>
<br>
<br>
<br>
class MyRequestHandler(http.Request):<br>
<br>
<br>
<br>
&nbsp;&nbsp; <br>
<br>
&nbsp;&nbsp;&nbsp; pages = { '/' : loginPage, <br>
<br>
&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'/uploadHandler' : handleUpload,<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'/uploadform' : uploadForm,<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'/xmlrpc_converter': MyConverterXMLRPCClass() }<br>
<br>
</blockquote>
<br>
Rarely is it correct to subclass Request. You can probably just
discard
<br>
all of the above code. Aside from that, I don't know what the `pages'
<br>
attribute is. I don't think anything pays any attention to it.
<br>
<br>
<blockquote type="cite"><br>
<br>
What I want to do is offer the user two possibilities to upload the
<br>
file, one of them using HTTP POST (calling to "uploadform") and the
<br>
other using XML-RPC (caling to xmlrpc_converter).<br>
<br>
<br>
<br>
I have tried to implement MyConverterXMLRPCClass() as
follows:<br>
<br>
<br>
<br>
MyConverterXMLRPCClass(xmlrpc.XMLRPC):<br>
<br>
&nbsp;&nbsp; <br>
<br>
&nbsp;&nbsp;&nbsp; def __init(self):<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
""""""<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
pass<br>
<br>
<br>
<br>
&nbsp;&nbsp;&nbsp; def xmlrpc_mymethod1(self,
param)<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
"""My process""<br>
<br>
<br>
<br>
</blockquote>
<br>
This part looks okay.
<br>
<br>
<blockquote type="cite">But It down't work, when I try <a
class="moz-txt-link-freetext"
href=<a class="moz-txt-link-rfc2396E" href="http://localhost:8000/xmlrpc_converter">"http://localhost:8000/xmlrpc_converter"</a>><a class="moz-txt-link-freetext" href="http://localhost:8000/xmlrpc_converter">http://localhost:8000/xmlrpc_converter</a></a>
I
<br>
get the following error:<br>
<br>
<br>
<br>
"MyConverterXMLRPCClass instance has no __call__ method"<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>
<br>
How can I call MyConverterXMLRPCClass from an url in my http
server?<br>
<br>
</blockquote>
<br>
I don't know how a MyConverterXMLRPCClass got called. I suppose you
have
<br>
some more code that you didn't include in this message which looks at
the
<br>
pages dictionary on the request object and does something with them.
<br>
Whatever it is, I guess it isn't correct. ;)
<br>
<br>
Instead, what you should do is define a root resource which has
<br>
MyConverterXMLRPCClass as a child at the "xmlrpc_converter" segment.
You
<br>
can do this pretty easily using the basic Resource class in
twisted.web:
<br>
<br>
from twisted.web.resource import Resource
<br>
from twisted.web.server import Site
<br>
from twisted.internet import reactor
<br>
<br>
root = Resource()
<br>
root.putChild('xmlrpc_converter', MyConverterXMLRPCClass())
<br>
site = Site(root)
<br>
reactor.listenTCP(8080, site)
<br>
<br>
The Resource class is implemented to keep track of child resources
added
<br>
to it with putChild so that when a request comes in for one of them, it
<br>
gives back the appropriate one and URL traversal or page rendering can
<br>
continue.
<br>
<br>
Hope this helps,
<br>
<br>
Jean-Paul
<br>
<br>
_______________________________________________
<br>
Twisted-Python mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a>
<br>
<a class="moz-txt-link-freetext" href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a>
<br>
<br>
</blockquote>
<br>
<br>
<div class="moz-signature">-- <br>
<title></title>
<p align="left"><span lang="es"><b><font color="#808080"
face="RotisSemiSans">Daniel de la Cuesta Navarrete</font></b></span> <br>
<span lang="es"><b><font color="#808080" face="RotisSemiSans">Técnico
de Desarrollo de Software</font></b></span></p>
<p align="left"><span lang="es"></span><span lang="es"><font
color="#339966" face="IAVANTE" size="4">FUNDACIÓN IAVANTE</font></span>
<br>
<span lang="es"><font color="#339966" face="RotisSemiSans"><a class="moz-txt-link-abbreviated" href="mailto:daniel.cuesta@iavantefundacion.com">daniel.cuesta@iavantefundacion.com</a></font></span>
<br>
<span lang="es"><font color="#339966" face="RotisSemiSans">Tel. 951 015
300</font></span> </p>
<br>
<p align="center"><span lang="es"><font color="#999999" face="Verdana"
size="1">Este correo electrónico y, en su caso, cualquier fichero
anexo, contiene información confidencial exclusivamente dirigida a
su(s) destinatario(s). Toda copia o divulgación deberá ser autorizada
por IAVANTE.</font></span></p>
<p align="center"><span lang="en-gb"><font color="#999999"
face="Verdana" size="1">This e-mail and any attachments are
confidential and exclusively directed to its adressee(s). Any copy or
distribution will have to be authorized by IAVANTE.</font></span></p>
<br>
</div>
</body>
</html>