Subversion Repositories SmartDukaan

Rev

Rev 447 | Rev 3135 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 447 Rev 3124
Line 1... Line 1...
1
'''
1
'''
2
Created on 17-Aug-2010
2
Updated on 31-Aug-2011
3
 
3
 
4
@author: ashish
4
@author: rajveer
5
'''
5
'''
6
from shop2020.thriftpy.model.v1.order import TransactionService
6
from shop2020.thriftpy.model.v1.order.TransactionService import Client
7
from thrift.protocol.TBinaryProtocol import TBinaryProtocol
-
 
8
from thrift.transport.TTransport import TFramedTransport
-
 
9
from thrift.transport.TSocket import TSocket
-
 
10
from shop2020.utils.Utils import log_entry
-
 
11
from shop2020.config.client.ConfigClient import ConfigClient
7
from shop2020.clients.GenericClient import GenericClient
12
 
8
 
13
class TransactionClient:
9
class UserClient(GenericClient):
14
    
-
 
15
    host = "localhost"
-
 
16
    port = "9003"
-
 
17
    
-
 
18
    def __init__(self):
-
 
19
        try:
-
 
20
            self.config_client = ConfigClient()
-
 
21
            self.host = self.config_client.get_property("transaction_service_server_host")
-
 
22
            self.port = self.config_client.get_property("transaction_service_server_port")
-
 
23
            self.__start__()
-
 
24
        except:
-
 
25
            log_entry(self, "error getting data from config")
-
 
26
            
10
            
-
 
11
    def __init__(self):
-
 
12
        GenericClient.__init__(self, "transaction_service_server_host", "transaction_service_server_port")
-
 
13
        self.__start__()
27
        
14
        
28
    def __start__(self):
15
    def __start__(self):
29
        self.transport = TSocket(self.host, self.port)
-
 
30
        self.transport = TFramedTransport(self.transport)
-
 
31
        self.protocol = TBinaryProtocol(self.transport)    
-
 
32
        self.client = TransactionService.Client(self.protocol)
16
        self.client = Client(self.protocol)
33
        self.transport.open()
-
 
34
        
17
        
35
    def get_client(self):
18
    def get_client(self):
36
        if self.transport.isOpen():
-
 
37
            return self.client
-
 
38
        self.transport.open()
-
 
39
        return self.client
19
        return self.client
40
20