Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added adapter for data wrapped in xmlrpclib.Binary #1

Closed
wants to merge 6 commits into from

3 participants

@aclark4life
Owner

Binary content (images, audio, etc) uploaded via XML-RPC needs to be wrapped in xmlrpclib.Binary, but p.a.blob currently does not support this approach, failing with "could not adapt". These commits add an xmlrpclib.Binary adapter.

@witsch
Owner

Alex, thanks for taking care of this — the diff looks good to me. Would you mind adding a test, though, please? :)

@aclark4life
Owner

As soon as I can figure out how to run the tests, I will finish this ;-)

@witsch
Owner

does bin/test -m plone.app.blob not work (in a recent coredev buildout)?

@garbas
Collaborator

@aclark4life any progress on this one?

@aclark4life
Owner

No, sorry. It works but I don't have time to look into writing a test for it. Anyone who is already familiar with the tests for this package should be able to do it though.

@garbas
Collaborator

any idea how can i contribute to this pull request ... or you need to close it and create new one?

@aclark4life
Owner

I can merge it and you can continuing working on it, if @witsch doesn't mind.

@garbas garbas referenced this pull request from a commit
@garbas garbas added tests for #1 6c56e8a
@garbas garbas closed this
@garbas garbas referenced this pull request from a commit
@garbas garbas added change of #1 to CHANGES.rst file d8f3307
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
1  src/plone/app/blob/adapters/configure.zcml
@@ -10,5 +10,6 @@
<adapter factory=".file.BlobbableFile" />
<adapter factory=".pdata.BlobbablePdata" />
<adapter factory=".webdav.BlobbableWebDavUpload" />
+ <adapter factory=".xmlrpc.BlobbableBinary" />
</configure>
View
29 src/plone/app/blob/adapters/xmlrpc.py
@@ -0,0 +1,29 @@
+from zope.interface import implements
+from zope.component import adapts
+
+from xmlrpclib import Binary
+
+from plone.app.blob.interfaces import IBlobbable
+
+
+class BlobbableBinary(object):
+ """ adapter for xmlrpclib Binary instance to work with blobs """
+ implements(IBlobbable)
+ adapts(Binary)
+
+ def __init__(self, context):
+ self.context = context
+
+ def feed(self, blob):
+ """ see interface ... """
+ blobfile = blob.open('w')
+ blobfile.writelines(self.context.data)
+ blobfile.close()
+
+ def filename(self):
+ """ see interface ... """
+ return None
+
+ def mimetype(self):
+ """ see interface ... """
+ return 'application/octet-stream'
View
3  src/plone/app/blob/tests/test_adapters.py
@@ -7,6 +7,7 @@
from plone.app.blob.tests.base import BlobTestCase
from plone.app.blob.tests.utils import getFile, getImage
from StringIO import StringIO
+from xmlrpclib import Binary
class AdapterTests(BlobTestCase):
@@ -55,6 +56,8 @@ def testBlobbableEmptyATFile(self):
target = Blob()
blobbable.feed(target)
+ def testBlobbableBinaryFile(self):
+ self.assertEquals(True, False)
def test_suite():
return defaultTestLoader.loadTestsFromName(__name__)
Something went wrong with that request. Please try again.