2

Based on the answer to Bad interaction between Zope2 XML-RPC and AT Image mutator? I'd expect to be able to do the following with Plone 2.5:

proxy = xmlrpclib.ServerProxy('http://admin:admin@localhost:8080/Plone/screenshot.png', verbose=True)
wrappedData = xmlrpclib.Binary(open(filename).read())
proxy.setImage(wrappedData)

Instead, I get a traceback (from Archetypes):

Value is not File or String (  - xmlrpclib.Binary)\n</string></value>\n</member>\n</struct></value>\n</fault>\n</methodResponse>\n

I suspect I've done something to make AT unhappy, but I'm not sure what. The traceback comes from line 897 of Archetypes's field.py, which you can see here:

Anyone know what's going on here? Also full code example is here:

Community
  • 1
  • 1
aclark
  • 4,345
  • 1
  • 19
  • 31

1 Answers1

2

With this patch it works like a charm:

--- Field.py    2011-10-24 20:33:49.000000000 +0200
+++ Field.py    2011-10-25 00:24:49.360826000 +0200
@@ -2,6 +2,7 @@

 import sys

+import xmlrpclib
 from copy import deepcopy
 from cgi import escape
 from cStringIO import StringIO
@@ -869,6 +870,8 @@
             filename = getattr(value, 'filename', value.getId())
             mimetype = getattr(value, 'content_type', mimetype)
             value = value.data
+        elif isinstance(value, xmlrpclib.Binary):
+            value = value.data
         elif isinstance(value, FileUpload) or shasattr(value, 'filename'):
             filename = value.filename
         elif isinstance(value, FileType) or shasattr(value, 'name'):
Giacomo Spettoli
  • 4,476
  • 1
  • 16
  • 24
  • Thanks Giacomo! I wish I didn't have to patch, but it makes sense at least. – aclark Oct 24 '11 at 23:08
  • 1
    Fixed with this monkeypatch: https://github.com/aclark4life/plone25_xmlrpc/tree/master/monkeypatch/monkeypatch – aclark Oct 24 '11 at 23:57