- add support for query on fault_code field
authorTony Mack <tmack@cs.princeton.edu>
Thu, 19 Oct 2006 15:41:37 +0000 (15:41 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Thu, 19 Oct 2006 15:41:37 +0000 (15:41 +0000)
PLC/Events.py

index e72563e..4dd6288 100644 (file)
@@ -43,7 +43,7 @@ class Events(Table):
                     object_types = None, object_ids = None, fault_codes = None):
        
                self.api = api
-                       
+       
                sql = "SELECT %s from view_events WHERE True" % ", ".join(Event.fields)
                
                if event_ids:
@@ -60,9 +60,12 @@ class Events(Table):
 
                if object_types:
                        sql += " AND object_type in (%s)" % ", ".join(api.db.quote(object_types))
-
+               
+               if fault_codes:
+                       sql += " And fault_code in (%s)" % ", ".join(map(str, fault_codes))
+       
                rows = self.api.db.selectall(sql)
-                       
+       
                for row in rows:
                        self[row['event_id']] = event = Event(api, row)
                        for aggregate in ['object_ids']: