문제

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>

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:

I would do this the "normal" way, with keyword arguments passed to invokeFactory, but XML-RPC does not support them.

도움이 되었습니까?

해결책

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())

More info:

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top