[Twisted-Python] Newbie:XMLRPC Server as plugin?
Daniel Fernández
dnfesp at hotmail.com
Thu Sep 18 21:23:47 EDT 2003
Sorry, I'm newbie too..
I got confused also the first time, then I realized that what I wanted was
just a server not a protocol (in my case a SOAP one). But then I found the
way things are explained is running your server as a regular python script,
but that prevents you from taking advantage from the facilities given by
running your service like e.g. twistd -f myserver.tap. So I realized that
what I really need is an Application so I can have a tap file. Everything
seems easy but then while following the examples (the last one in Creating
XML-RPC Servers and Clients - modified to get a tap file) I get an
unexpected error. I'm using Twisted 1.0.7 with SOAPpy 0.10.2 and python 2.3
on windows 2000
the code is a bit modified, I removed the quoters logic and changed the last
line from:
application.run(save=0) ---------> application.save("start")
in order to get a tap file
<code>
from twisted.web import soap, xmlrpc, resource, server
class XMLRPCQuoter(xmlrpc.XMLRPC):
def xmlrpc_quote(self):
return 'Hola'
class SOAPQuoter(soap.SOAPPublisher):
def soap_quote(self):
return 'Hola'
def main():
from twisted.internet.app import Application
app = Application("xmlrpc")
root = resource.Resource()
root.putChild('RPC2', XMLRPCQuoter())
root.putChild('SOAP', SOAPQuoter())
app.listenTCP(7080, server.Site(root))
return app
application = main()
if __name__ == '__main__':
application.save("start")
</code>
I can't find what is going wrong here, this is the log I'm getting when I
try to run xmlrpc-start.tap
D:\Python23\Lib\site-packages>twistd -f xmlrpc-start.tap
2003/09/18 20:08 Hora de verano de MÚxico [-] Log opened.
2003/09/18 20:08 Hora de verano de MÚxico [-] twistd 1.0.7
(D:\PYTHON23\python.e
xe 2.3.0) starting up
2003/09/18 20:08 Hora de verano de MÚxico [-] reactor class:
twisted.internet.de
fault.SelectReactor
2003/09/18 20:08 Hora de verano de MÚxico [-] Loading xmlrpc-start.tap...
2003/09/18 20:08 Hora de verano de MÚxico [-] Warning! Loading from
__main__: X
MLRPCQuoter
2003/09/18 20:08 Hora de verano de MÚxico [-] Traceback (most recent call
last):
2003/09/18 20:08 Hora de verano de MÚxico [-] File
"D:\PYTHON23\Lib\site-packa
ges\twisted\scripts\twistd.py", line 317, in runApp
2003/09/18 20:08 Hora de verano de MÚxico [-] application =
loadApplication(
config, passphrase)
2003/09/18 20:08 Hora de verano de MÚxico [-] File
"D:\PYTHON23\Lib\site-packa
ges\twisted\scripts\twistd.py", line 210, in loadApplication
2003/09/18 20:08 Hora de verano de MÚxico [-] return decode(filename,
data)
2003/09/18 20:08 Hora de verano de MÚxico [-] File
"D:\PYTHON23\Lib\site-packa
ges\twisted\scripts\twistd.py", line 188, in decode
2003/09/18 20:08 Hora de verano de MÚxico [-] application =
pickle.loads(dat
a)
2003/09/18 20:08 Hora de verano de MÚxico [-] AttributeError: ('Ephemeral
instan
ce has no __call__ method', <twisted.persisted.styles.Ephemeral instance at
0x00
FEB580>, ())
2003/09/18 20:08 Hora de verano de MÚxico [-] Failed to load application:
('Ephe
meral instance has no __call__ method', <twisted.persisted.styles.Ephemeral
inst
ance at 0x00FEB580>, ())
2003/09/18 20:08 Hora de verano de MÚxico [-] Traceback (most recent call
last):
File "D:\PYTHON23\scripts\twistd.py", line 32, in ?
run()
File "D:\PYTHON23\Lib\site-packages\twisted\scripts\twistd.py",
line 4
48, in run
runApp(config)
--- <exception caught here> ---
File "D:\PYTHON23\Lib\site-packages\twisted\scripts\twistd.py",
line 3
17, in runApp
application = loadApplication(config, passphrase)
File "D:\PYTHON23\Lib\site-packages\twisted\scripts\twistd.py",
line 2
10, in loadApplication
return decode(filename, data)
File "D:\PYTHON23\Lib\site-packages\twisted\scripts\twistd.py",
line 1
88, in decode
application = pickle.loads(data)
exceptions.AttributeError: ('Ephemeral instance has no __call__
method',
<twisted.persisted.styles.Ephemeral instance at 0x00FEB580>, ())
Failed to load application: ('Ephemeral instance has no __call__ method',
<twist
ed.persisted.styles.Ephemeral instance at 0x00FEB580>, ())
2003/09/18 20:08 Hora de verano de MÚxico [-]
after that it just return to the prompt.
any help would be really appreciated.
thanks
_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
More information about the Twisted-Python
mailing list