Re: Re: questions regarding ZOGi, WAS: [OGo-Users]custom fields and synchronizing ogo
"Sebastian Reitenbach" <[email protected]> Thu, 27 Mar 2008 14:08:29 +0100
| Newsgroups | gmane.comp.cms.opengroupware.xmlrpc.devel |
|---|---|
| Organization | L00 bugdead prods. |
| Message-ID | <[email protected]> |
[email protected] wrote: > Hi Adam, > > [email protected] 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'] > After reading about assignments in the Wiki, I changed the script, so that it looks like this: '_ACCESS' : permissions, '_CONTACTS' : [ { 'targetObjectId' : row[11] } ], '_COMPANYVALUES' : [ { 'attribute' : 'contact_segments', Now, the exception is gone, and the entry is created, but the contact_id field in the database is still empty. > > The CSV file had the following contents: > 401|TESTCOMPANY|www.testcompany.de|Testblah|ZIP||asdf|2|1|10|1|894900 > kind regards Sebastian -- OpenGroupware.org XML-RPC [email protected] http://mail.opengroupware.org/mailman/listinfo/xmlrpc