Zope2 XML-RPC与AT Image mutator之间的互动不良? [英] Bad interaction between Zope2 XML-RPC and AT Image mutator?
问题描述
我正在为mr.migrator创建演示,并且遇到了一个令人烦恼的问题,在此处展示:
I am creating a demo for mr.migrator and have run in to an annoying problem, showcased here:
# create image
proxy = xmlrpclib.ServerProxy(url) # reset
data = open('screenshot.png').read()
try:
proxy.invokeFactory('Image', 'screenshot.png')
except xmlrpclib.ProtocolError:
print sys.exc_info()[1]
except xmlrpclib.Fault:
print "The id is invalid - it is already in use." # most likely
proxy = xmlrpclib.ServerProxy(url + '/screenshot.png')
proxy.setTitle('This is an image')
try:
proxy.setImage(data) # XXX this fails
except:
print sys.exc_info()[1]
此代码应使用来自图像的数据填充图像字段,但失败的原因是:
This code should populate the image field with data from the image, but instead it fails consistently with:
<ProtocolError for admin:admin@localhost:8080/Plone/screenshot.png: 500 Internal Server Error>
更糟糕的是,这就是Zope2所说的.在前台运行Plone时,我没有看到任何回溯或其他任何指示问题的信息.
Worse, this is all Zope2 says. I don't see any tracebacks or anything else that indicates a problem when running Plone in the foreground.
下一步是什么?您可以在此处签出并重现此内容:
What's my next step? You can check out and reproduce this here:
我将以常规"方式执行此操作,并将关键字参数传递给invokeFactory,但 XML-RPC不支持它们.
I would do this the "normal" way, with keyword arguments passed to invokeFactory, but XML-RPC does not support them.
推荐答案
这很可能是特殊字符错误. xml-rpc协议可以使用允许您使用的任何字符XML.您应该尝试将图像数据包装在Binary包装器中:
This is most likely a special character error. The xml-rpc protocol can use any character XML allows you to use. You should try to wrap the image data in a Binary wrapper:
wrappedData = xmlrpclib.Binary(open('screenshot.png').read())
更多信息:
- http://effbot.org/zone/xmlrpc-ascii.htm
- http://docs.python.org/library/xmlrpclib.html
这篇关于Zope2 XML-RPC与AT Image mutator之间的互动不良?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!