~openerp-commiter/openobject-addons/stable-sja-branch

« back to all changes in this revision

Viewing changes to etl/lib/etl/connector/connector.py

  • Committer: sja-axelor
  • Date: 2009-10-13 09:52:57 UTC
  • Revision ID: suniljagyasi@gmail.com-20091013095257-8u26ww0r20z9y6ey
add

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 ETL Connector.
 
24
 
 
25
 Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). 
 
26
 GNU General Public License.
 
27
"""
 
28
from etl import signal
 
29
import datetime
 
30
class connector(signal):
 
31
    """
 
32
    Base class of ETL Connector.
 
33
    """   
 
34
 
 
35
    def __init__(self,name='connector'):
 
36
        """
 
37
        Parameters 
 
38
        name : Name of the connector.
 
39
        """
 
40
        self._type = 'connector'
 
41
        super(connector, self).__init__()
 
42
        self.name = name or ''
 
43
        self.status = 'close'        
 
44
 
 
45
    def __copy__(self):       
 
46
        res = connector(name=self.name)
 
47
        return res
 
48
 
 
49
    def __str__(self):        
 
50
        return '<Connector name = "%s" type = "%s">'%(self.name, self._type)
 
51
 
 
52
    def __getstate__(self):
 
53
        return {'name' : self.name, 'status': self.status , '_type' :self._type}
 
54
 
 
55
    def __setstate__(self, state):
 
56
        self.__dict__ = state
 
57
 
 
58
    def open(self):
 
59
        self.status = 'open'
 
60
        self.signal('open', {'date': datetime.datetime.today()})
 
61
 
 
62
    def close(self, connector=False):
 
63
        """
 
64
        Parameters
 
65
        connector : Connector that is to be closed.
 
66
        """
 
67
        self.status = 'close'
 
68
        self.signal('close', {'date': datetime.datetime.today()})
 
69
 
 
70
    def execute(self):
 
71
        return True
 
72