[OGo-XML-RPC] Re: questions regarding ZOGi, WAS: [OGo-Users]custom fields and synchronizing ogo
Sebastian Reitenbach
xmlrpc@opengroupware.org
Thu, 27 Mar 2008 12:41:06 +0100
Hi Adam,
xmlrpc@opengroupware.org wrote:
> > I assume the two lines below the import line have to be on a single
line?
>
> yep.
>
> > Then I see a lot of, maybe only in my eyes, magic numbers, e.g.:
> > permissions = [ { 'operations' : 'rw',
> > 'targetObjectId' : 970990 },
> > { 'operations' : 'rw',
> > 'targetObjectId' : 11530 } ]
> > are 11530 and 970990 object ID values of accounts or teams in ogo?
>
> Teams; these permissions "rw" for teams 970990 & 11530 are set on all
> imported values. Obviously that would be different or unnecessary
> depending on the site. They can be objectIds of accounts or teams.
>
> > then, a little bit later when creating the Enterprise:
> > ...
> > '_ACCESS' : permissions,
> > '_COMPANYVALUES' : [ { 'attribute' : 'division',
> > 'value' : 'WYC' },
> > { 'attribute' : 'salesperson',
> > 'value' : row[0] },
> > ...
> > I assume this will create all companies with a "division" attribute with
> > value WYC?
>
> Yep.
>
I took a look at the example scripts on the zogi wiki, and I am able to
create a company, also the extended attributes. I am having a problem
creating adding the contact_id to an enterprise.
I took a look into the wiki, putObject examples, there you do sth like this:
...
person = {}
person['targetObjectId'] = 10160
...
enterprise['_CONTACTS'] = [ person ]
...
enterprise = server.zogi.putObject(enterprise)
The script I use, is:
#!/usr/bin/env python
# all intranet: 10003
#
import sys, csv, xmlrpclib, time
server = xmlrpclib.Server('http://admin:pw@localhost/zidestore/so/ogoroot')
permissions = [ { 'operations' : 'rw',
'targetObjectId' : 10003 } ]
counter = 0
reader = csv.reader(open("/root/bin/company.csv", "rb"), delimiter='|',
quoting=csv.QUOTE_NONE)
for row in reader:
print 'Creating new enterprise'
person = {}
person['targetObjectId'] = row[11]
enterprise = server.zogi.putObject(
{ 'objectId' : 0,
'entityName' : 'Enterprise',
'name' : row[1],
'url' : row[2],
'_ADDRESSES' : [ { 'name1' : row[1],
'street' : row[3],
'city' : row[6],
'state' : row[5],
'zip' : row[4],
'type' : 'ship' } ],
'_ACCESS' : permissions,
'_CONTACTS' : person,
'_COMPANYVALUES' : [ { 'attribute' : 'contact_segments',
'value' : row[7] },
{ 'attribute' : 'contact_markets',
'value' : row[8] },
{ 'attribute' : 'country',
'value' : row[9] },
{ 'attribute' : 'continent',
'value' : row[10] },
{ 'attribute' : 'CSDB_Import',
'value' : 'YES' },
{ 'attribute' : 'csdb_id',
'value' : row[0] }
] }
)
print 'Created Enterprise#%d' % enterprise['objectId']
And I get an exception:
Creating new enterprise
/usr/lib64/python2.4/xmllib.py:9: DeprecationWarning: The xmllib module is
obsolete. Use xml.sax instead.
warnings.warn("The xmllib module is obsolete. Use xml.sax instead.",
DeprecationWarning)
Traceback (most recent call last):
File "./create_company.py", line 15, in ?
enterprise = server.zogi.putObject(
File "/usr/lib64/python2.4/xmlrpclib.py", line 1096, in __call__
return self.__send(self.__name, args)
File "/usr/lib64/python2.4/xmlrpclib.py", line 1383, in __request
verbose=self.__verbose
File "/usr/lib64/python2.4/xmlrpclib.py", line 1147, in request
return self._parse_response(h.getfile(), sock)
File "/usr/lib64/python2.4/xmlrpclib.py", line 1286, in _parse_response
return u.close()
File "/usr/lib64/python2.4/xmlrpclib.py", line 744, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 0: 'ObjcRuntimeException: NSShortInline8BitString
(instance) does not recognize objectForKey: {\n methodName
= "zogi.putObject";\n methodParameters = (\n
{\n "_ACCESS" = (\n {\n
operations = rw;\n targetObjectId = 10003;
\n }\n );\n "_ADDRESSES" = (\n
{\n city = asdf;\n name1 =
TESTCOMPANY;\n state = "";\n street =
Testblah;\n type = ship;\n zip = ZIP;
\n }\n );\n "_COMPANYVALUES" = (\n
{\n attribute = "contact_segments";\n
value = 2;\n },\n {\n
attribute = "contact_markets";\n value = 1;
\n },\n {\n attribute =
country;\n value = 10;\n },\n
{\n attribute = continent;\n value =
1;\n },\n {\n attribute
= "CSDB_Import";\n value = YES;\n },\n
{\n attribute = "csdb_id";\n value =
401;\n }\n );\n "_CONTACTS" = {\n
targetObjectId = 894900;\n };\n entityName =
Enterprise;\n name = TESTCOMPANY;\n objectId = 0;\n
url = "www.testcompany.de";\n }\n );\n}'>
The CSV file had the following contents:
401|TESTCOMPANY|www.testcompany.de|Testblah|ZIP||asdf|2|1|10|1|894900
Maybe I am completely wrong, and _CONTACTS are the persons associated to the
company?
I'm on a sles10sp1, using an ogo, about two or three months old.
kind regards
Sebastian