2014-10-01 93 views
0

我試圖從SugarCRM的收集數據,並有下面的代碼:SugarCRM的實例沒有屬性「模塊」

import sugarcrm 

sugarcrm_user = "user" 
sugarcrm_pass = "pass" 
sugarcrm_url = "url/service/v4/rest.php" 

sugarcrm_conn= None 

try: 
    sugarcrm_conn = sugarcrm.Sugarcrm(url = sugarcrm_url, username = sugarcrm_user, password = 
    sugarcrm_pass) 
    accounts = sugarcrm_conn.module('Accounts') 
except ValueError: 
    print "cann't connect to " + sugarcrm_url 
    exit(1) 

的連接工作正常,但是當我嘗試使用SugarCRM的對象是說

SugarCRM的實例沒有屬性 '模塊'

回答

0

使用this link#1.B - 方法2:使用純JSON是一個很好的選擇:

filtered_accounts = sugarcrm_conn.get_entry_list('Accounts', 'accounts.name like "%batman%"', 'accounts.name DESC', 0, ['name','date_entered','email1']) #here offset is 0 
print filtered_accounts 
for account in filtered_accounts['entry_list']: 
    name_value_list = account['name_value_list'] 
    print "name=%s,email=%s" % (name_value_list['name']['value'],name_value_list['email1']['value'])