I'm trying to create some documents in a CPS Default Site (3.4) from a client python application using CPSRemoteController. I have problems when creating a "News Item" with a photo (photo field in schema). I've used the xmlrpc Binary object (like File document examples in "Understanding and using the CPS Remote Controller") but when I access the News Item created in CPS it appears a blinking "!!!". If I try to edit the document created, there's an AttributeError?: Binary instance has no attribute 'size'.
# -*- coding: ISO-8859-15 -*-
from xmlrpclib import ServerProxy, Binary
SERVER = 'myIPaddress'
PORT = '8081'
PORTAL = 'myportal'
USER = 'myuser'
PWD = 'mypwd'
connectString = 'http://%s:%s@%s:%s/%s/portal_remote_controller' % (USER,PWD,SERVER,PORT,PORTAL) proxy = ServerProxy(connectString)
# Read image from file
f = open('banner.jpg')
binary = Binary(f.read())
f.close()
# Document definition
doc_def = {
'Title': 'A news item example',
'Description': 'The description goes here',
'photo': binary,
}
try:
proxy.createDocument('News Item', doc_def, 'workspaces', 0, 'No comment')
except:
print 'Error'
print "End ---"