nodes have a node_type (NodeType object and api calls still missing)
[plcapi.git] / PLC / Filter.py
index 4e950f1..807ce00 100644 (file)
@@ -1,3 +1,4 @@
+# $Id$
 from types import StringTypes
 try:
     set
@@ -55,11 +56,11 @@ class Filter(Parameter, dict):
 
     * fields starting with - are special and relate to row selection, i.e. sorting and clipping
     * '-SORT' : a field name, or an ordered list of field names that are used for sorting
-    * these fields may start with + (default) or - for denoting increasing or decreasing order
+      these fields may start with + (default) or - for denoting increasing or decreasing order
     example : filter = { '-SORT' : [ '+node_id', '-hostname' ] }
     * '-OFFSET' : the number of first rows to be ommitted
     * '-LIMIT' : the amount of rows to be returned 
-    example : filter = { '-OFFSET' : 100, 'LIMIT':25}
+    example : filter = { '-OFFSET' : 100, '-LIMIT':25}
 
     A realistic example would read
     GetNodes ( { 'hostname' : '*.edu' , '-SORT' : 'hostname' , '-OFFSET' : 30 , '-LIMIT' : 25 } )
@@ -73,28 +74,13 @@ class Filter(Parameter, dict):
         # Declare ourselves as a type of parameter that can take
         # either a value or a list of values for each of the specified
         # fields.
-        self.fields = {}
-
-        for field, expected in fields.iteritems():
-            # Cannot filter on sequences
-            if python_type(expected) in (list, tuple, set):
-                continue
-            
-            # Accept either a value or a list of values of the specified type
-            self.fields[field] = Mixed(expected, [expected])
+        self.fields = dict ( [ ( field, Mixed (expected, [expected])) 
+                                 for (field,expected) in fields.iteritems()
+                                 if python_type(expected) not in (list, tuple, set) ] )
 
         # Null filter means no filter
         Parameter.__init__(self, self.fields, doc = doc, nullok = True)
 
-    # this code is not used anymore
-    # at some point the select in the DB for event objects was done on
-    # the events table directly, that is stored as a timestamp, thus comparisons
-    # needed to be done based on SQL timestamps as well
-    def unix2timestamp (self,unix):
-       s = time.gmtime(unix)
-       return "TIMESTAMP'%04d-%02d-%02d %02d:%02d:%02d'" % (s.tm_year,s.tm_mon,s.tm_mday,
-                                                            s.tm_hour,s.tm_min,s.tm_sec)
-
     def sql(self, api, join_with = "AND"):
         """
         Returns a SQL conditional that represents this filter.