def get_user_by_login(self, email, password):
     
     
     criteria = {
                 'email' : email,
                 'password' : password,
                 'status' : self.active_user_status
                 }
     
     table_cols = ['id', 'email', 'first_name', 'last_name']
     
     
     record = self.mysql_util.execute_select(
         table_name='accounts', 
         conditions=criteria, 
         operator='AND', table_cols=table_cols, 
         fetchall=False)
     
     valid_user = None
     
     if record :
         
         valid_user = Account()
         
         valid_user.account_id = record['id']
         valid_user.email = record['email']
         valid_user.first_name = record['first_name']
         valid_user.last_name = record['last_name']
         valid_user._is_active = True
         
     
     return valid_user
    def get_raw_info(self, id=None, email=None ):
        
        conditions={}
        
        if id :
            conditions['id'] = id

        if email :
            conditions['email'] = email
        
        if not conditions :
            return None 
        
        table_cols = [ 'id', 'suffix', 'package', 'address','company','first_name','last_name', 'email', 'suffix', 'test_min','change_mobile_ctr',
                      'date_created', 'date_updated', 'change_mobile_ctr', 'test_min', 'test_mo_reply', 'status', 'password']
        
        try :
            
            account_object = None
            
            result = self.mysql_util.execute_select(
                table_name='accounts', 
                conditions=conditions, 
                operator='AND', table_cols=table_cols, 
                fetchall=False)
                
            if result :
                
                #map the values to 
                account_object = Account() 
                account_object.account_id = result['id'] 
                account_object.first_name = result['first_name']
                account_object.last_name = result['last_name']
                account_object._password = result['password']
                
                # should deprecate
                account_object.status = result['status']
            
                # set user status
                if result['status'] == 'PENDING' :
                    account_object._is_pending = True
                elif result['status'] == 'ACTIVE' :
                    account_object._is_active = True
                elif result['status'] == 'INACTIVE' :
                    account_object._is_inactive = True

            
        except Exception, e:
            
            raise AccountLoadException('unable to load account id=%s email=%s ; %s' % (id,email,e) )
    def get(self, account_id=None, email=None , suffix=None, **kwargs):
        
        criteria = {}
        
        
        # maybe we can also get account object via email address
        if account_id :
            criteria['id'] = account_id
            
        if email :
            criteria['email'] = email
        
        if suffix :
            criteria['suffix'] = suffix
        
        
            
        if not criteria :
            return None
        
        table_cols = [
            'id', 'first_name', 'last_name','email', 'suffix', 'test_min', 'change_mobile_ctr', 
            'test_mo_reply', 'status', 'address', 'company', 'package', 'password', 
            'secret_key', 'client_id', 'name', 'billing_email', 'with_balance_notif', 'balance_threshold'
        ]
        
        
        account_object = None
        
        try :
            
            result = self.mysql_util.execute_select(
            table_name='accounts', 
            conditions=criteria, 
            operator='AND', table_cols=table_cols, 
            fetchall=False)
            
            if result :
                account_object = Account() 
                account_object.account_id = result['id'] 
                account_object.first_name = result['first_name']
                account_object.last_name = result['last_name']
                account_object.test_min = result['test_min']
                account_object._change_mobile_ctr = result['change_mobile_ctr']
                account_object.test_mo_reply = result['test_mo_reply']
                account_object.suffix = result['suffix']
                account_object.address = result['address']
                account_object.company = result['company']
                account_object._password = result['password']

                account_object.email = result['email']
                account_object.package = result['package']
                account_object.secret_key = result['secret_key']
                account_object.client_id = result['client_id']
                account_object.name = result['name']
                account_object.billing_email = result['billing_email']
                
                account_object.balance_notif_enabled = True if result['with_balance_notif'] else False
                account_object.balance_notif_threshold = result['balance_threshold']
                

                if result['package'] == 'FREE' :
                    account_object.package_type = Account.PACKAGE_FREE
                elif result['package'] == 'PAID' :
                    account_object.package_type = Account.PACKAGE_PAID
                elif result['package'] == 'INACTIVE' :
                    account_object.package_type = Account.PACKAGE_INACTIVE
                elif result['package'] == 'UNPAID' :
                    account_object.package_type = Account.PACKAGE_UNPAID
                
                
                
                # set user status
                if result['status'] == 'PENDING' :
                    account_object._is_pending = True
                elif result['status'] == 'ACTIVE' :
                    account_object._is_active = True
                elif result['status'] == 'INACTIVE' :
                    account_object._is_inactive = True
                
        except Exception, e :
            # @todo raise error
            pass