Package etl :: Package component :: Package output :: Module xmlrpc_out
[hide private]
[frames] | no frames]

Source Code for Module etl.component.output.xmlrpc_out

 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   To get the response for the request made to xmlrpc server. 
24   
25   Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).  
26   GNU General Public License. 
27  """ 
28   
29  from etl.component import component 
30   
31 -class xmlrpc_out(component):
32 """ 33 To get the response for the request made to xmlrpc server. 34 """
35 - def __init__(self, xmlrpc_connector, name='component.output.xmlrpc_out', transformer=None, row_limit=0):
36 super(xmlrpc_out, self).__init__(name=name, connector=xmlrpc_connector, transformer=transformer, row_limit=row_limit) 37 self._type = 'component.output.xmlrpc_out'
38
39 - def __copy__(self):
40 res = xmlrpc_out(self.connector, self.name, self.transformer, self.row_limit) 41 return res
42
43 - def end(self):
44 super(xmlrpc_out, self).end() 45 if self.server: 46 self.connector.close(self.server) 47 self.server = False
48
49 - def process(self):
50 self.server = False 51 for channel, trans in self.input_get().items(): 52 for iterator in trans: 53 for d in iterator: 54 if not self.server: 55 self.server = self.connector.connect() 56 self.server.import_data([d]) 57 yield d, 'main'
58
59 -def test():
60 from etl_test import etl_test 61 import etl 62 xmlrpc_conn = etl.connector.xmlrpc_connector('localhost', 8050) 63 test1 = etl_test.etl_component_test(xmlrpc_out(xmlrpc_conn)) 64 server = xmlrpc_conn.connect() 65 server.import_data([])
66 67 if __name__ == '__main__': 68 test() 69 70 #s = xmlrpclib.ServerProxy('http://localhost:5000') 71 #s.import_data([ 72 # {'org':'X.Ltd','fn':'Mr.X','email':'x@xmail.com'}, 73 # {'org':'Y.Ltd','fn':'Mr.Y','email':'y@ymail.com'}, 74 # {'org':'X.Ltd','fn':'Mr.XX','email':'xx@xmail.com'}, 75 # {'org':'X.Ltd','fn':'Mr.X2','email':'x2@xmail.com'}, 76 # {'org':'Y.Ltd','fn':'Mr.Y1','email':'y1@ymail.com'}, 77 # ]) 78