def find_row(self, params, results=None):
        results = SimpleDAO.find_row(self, params, results)
        
        tuples = []
        results['lookup_messages'] = tuples
        
        try:
            user_id = params['user_id']
            query_text = params['query_text']

            tokens = map(lambda s: s.lower().strip(), query_text.split())
            
            
            
            tx = params.tx
        
            schema = tx.schema
            
            
            
            m = schema.message('m')
            
            condition = None
            for t in tokens:
                clause = m.text.ilike("%%%s%%" % (t))
                if condition is None:
                    condition = clause
                else:
                    condition = condition & clause
                    
            condition = (m.user_id == user_id) & condition
            
            
            rows = tx.execute(schema.
                              select(m.id, m.text).
                              from_(m).
                              where(condition).
                              order_by(m.id) )
        
            for id, text in rows:
                tuples.append((text, id))
            
        except KeyError:
            pass
        
        return results
Beispiel #2
0
    def find_row(self, params, results=None):
        results = SimpleDAO.find_row(self, params, results)

        tuples = []
        results['lookup_messages'] = tuples

        try:
            user_id = params['user_id']
            query_text = params['query_text']

            tokens = map(lambda s: s.lower().strip(), query_text.split())

            tx = params.tx

            schema = tx.schema

            m = schema.message('m')

            condition = None
            for t in tokens:
                clause = m.text.ilike("%%%s%%" % (t))
                if condition is None:
                    condition = clause
                else:
                    condition = condition & clause

            condition = (m.user_id == user_id) & condition

            rows = tx.execute(
                schema.select(m.id,
                              m.text).from_(m).where(condition).order_by(m.id))

            for id, text in rows:
                tuples.append((text, id))

        except KeyError:
            pass

        return results
Beispiel #3
0
 def __init__(self, db):
     SimpleDAO.__init__(self)
     self.database = db
 def __init__(self, db):
     SimpleDAO.__init__(self)
     self.database = db