Subversion Repositories SmartDukaan

Rev

Rev 873 | Blame | Compare with Previous | Last modification | View Log | RSS feed

import time
from shop2020.test.DataService import initialize, session
from shop2020.test.DataService import UserTable
from shop2020.thriftpy.test.ttypes import Address
from sqlalchemy.sql.expression import select

class TestServiceHandler:

        
    def __init__(self):
        initialize()
        
    def sayHello(self, message):
        """
        Parameters:
         - message
        """
        time.sleep(6)
        print message
        
    def getAddressId(self):
        print "hello"
        return None
    
    def getAddress(self):
        address = Address()
        address.address = "Hello address"
        address.addressId = None
        return address
    
    def getUser(self, id):
        """
        Parameters:
         - id
        """
        print select([UserTable.id], distinct=True).order_by(UserTable.name) 


        user = UserTable.get_by(id=id)
        if user is None:
            name = "No User"
        else:
            name = user.name
        #session.commit()
        #session.close()
        print name
        return name
    
    def createUser(self, name):
        """
        Parameters:
         - name
        """
        user = UserTable()
        user.name = name
        session.commit()
        
    def closeSession(self, ):
        if session.is_active:
            print "session is active. closing it."
            session.close()