Home | Trees | Indices | Help |
---|
|
1 # -*- encoding: utf-8 -*- 2 ############################################################################## 3 # 4 # ETL system- Extract Transfer Load system 5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved 6 # $Id$ 7 # 8 # This program is free software: you can redistribute it and/or modify 9 # it under the terms of the GNU General Public License as published by 10 # the Free Software Foundation, either version 3 of the License, or 11 # (at your option) any later version. 12 # 13 # This program is distributed in the hope that it will be useful, 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 # GNU General Public License for more details. 17 # 18 # You should have received a copy of the GNU General Public License 19 # along with this program. If not, see <http://www.gnu.org/licenses/>. 20 # 21 ############################################################################## 22 23 from etl.connector import connector 2426 """ 27 This is an ETL connector that provides connectivity with SugarCRM server. 28 """12129 - def __init__(self, username, password, url='http://localhost/sugarcrm', encoding='utf-8', name='sugarcrm_connector'):30 """ 31 Required Parameters 32 username: Userid of SugarCRM server. 33 password: Password. 34 35 Extra Parameters 36 url : URL of SugarCRM server. 37 encoding: Encoding format. 38 name : Name of connector. 39 """ 40 super(sugarcrm_connector, self).__init__(name) 41 self._type = 'connector.sugarcrm_connector' 42 self.url=url 43 self.username = username 44 self.password = password 45 self.encoding = encoding46 4749 super(sugarcrm_connector, self).open() 50 from sugarcrm.sugarsoap_services_types import * 51 from sugarcrm.sugarsoap_services import * 52 loc = sugarsoapLocator(); 53 request = loginRequest(); 54 uauth = ns0.user_auth_Def(request); 55 request._user_auth = uauth; 56 uauth._user_name = self.username; 57 uauth._password = md5.new(self.password).hexdigest(); 58 uauth._version = '1.1'; 59 portType = loc.getsugarsoapPortType(self.url); 60 response = portType.login(request); 61 if -1 == response._return._id: 62 raise LoginError(response._return._error._description); 63 return (portType, response._return._id);6466 from sugarcrm.sugarsoap_services_types import * 67 from sugarcrm.sugarsoap_services import * 68 se_req = get_entry_listRequest() 69 se_req._session = session_id; 70 se_req._module_name = module 71 se_req._offset = offset; 72 se_req._max_results = row_limit; 73 #se_req._order_by = 'id'; 74 if query != None: 75 se_req._query = query; 76 #end if 77 se_resp = portType.get_entry_list(se_req); 78 list = se_resp._return._entry_list; 79 80 ans_list = []; 81 82 for i in list: 83 ans_dir = {}; 84 for j in i._name_value_list: 85 ans_dir[j._name.encode(self.encoding)] = j._value.encode(self.encoding) 86 #end for 87 ans_list.append(ans_dir); 88 #end for 89 return ans_list;9092 from sugarcrm.sugarsoap_services_types import * 93 from sugarcrm.sugarsoap_services import * 94 gui_req = get_user_idRequest(); 95 gui_req._session = session_id; 96 user_id = portType.get_user_id(gui_req)._return; 97 98 se_req = set_entryRequest(); 99 se_req._session = session_id; 100 se_req._module_name = module; 101 se_req._name_value_list = []; 102 name = []; 103 104 for (n, v) in values: 105 nvl = ns0.name_value_Def('name_value'); 106 nvl._name = n; 107 nvl._value = v; 108 se_req._name_value_list.append(nvl); 109 #end for 110 se_resp = portType.set_entry(se_req); 111 account_id = se_resp._return._id; 112 return account_id;113 117119 res = sugarcrm_connector(self.username, self.password, self.url, self.encoding, self.name) 120 return res123 from etl_test import etl_test 124 import etl 125 sugarcrm_conn=sugarcrm_connector('admin','sugarpasswd',url='http://192.168.0.7/sugarcrm/soap.php') 126 test = etl_test.etl_component_test(etl.component.input.sugarcrm_in(sugarcrm_conn, 'Contacts')) 127 res=test.output() 128 print res129 130 131 if __name__ == '__main__': 132 test() 133
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0beta1 on Wed Apr 29 20:37:25 2009 | http://epydoc.sourceforge.net |