Package etl :: Package component :: Package input :: Module sugarcrm_in'
[hide private]
[frames] | no frames]

Source Code for Module etl.component.input.sugarcrm_in'

 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  This is an ETL Component that reads data from SugarCRM. 
24  """ 
25   
26  from etl.component import component 
27 -class sugarcrm_in(component):
28 """ 29 This is an ETL Component that reads data from SugarCRM 30 31 """
32 - def __init__(self, sugarcrm_connector, module, name='componet.input.sugarcrm_in', transformer=False, row_limit=0):
33 """ 34 Required Parameters 35 sugarcrm_connector : SugarCRM connector. 36 module : Name of the module. 37 38 Extra Parameters 39 name : Name of Component. 40 transformer : Transformer object to transform string data into particular type. 41 row_limit : Limited records are sent to destination if row limit is specified. If row limit is 0, all records are sent. 42 """ 43 44 super(sugarcrm_in, self).__init__(name=name, connector=sugarcrm_connector, transformer=transformer, row_limit=row_limit) 45 self._type = 'componet.input.sugarcrm_in' 46 self.module = module
47
48 - def __copy__(self):
49 res = sugarcrm_in(self.sugarcrm_connector, self.module, self.name, self.transformer, self.row_limit) 50 return res
51
52 - def process(self):
53 res = [] 54 (portType, session_id,) = self.connector.open() 55 res = self.connector.search(portType, session_id, self.module) 56 for data in res: 57 if data: 58 print data['first_name'], data['account_name'] 59 yield data, 'main'
60
61 -def test():
62 #TODO 63 from etl_test import etl_test 64 import etl 65 sugarcrm_conn=etl.connector.sugarcrm_connector('admin','sugarpasswd',url='http://192.168.0.7/sugarcrm/soap.php') 66 test = etl_test.etl_component_test(sugarcrm_in(sugarcrm_conn, 'Contacts')) 67 res=test.output() 68 print res
69 70 if __name__ == '__main__': 71 test() 72