log_search.py
changeset 118 f530c158aa07
parent 99 8719ac564b22
child 121 86aebc9cb60b
--- a/log_search.py	Thu Feb 12 00:57:39 2009 +0200
+++ b/log_search.py	Thu Feb 12 01:53:52 2009 +0200
@@ -242,16 +242,16 @@
         
         if channel :
             # add channel attribute
-            cond.add_attr("channel STREQ %s" % (channel.id, ))
+            cond.add_attr(("channel STREQ %s" % channel.id).encode('utf8'))
         
         if attrs :
             # add attributes
             for attr in attrs :
-                cond.add_attr(attr)
+                cond.add_attr(attr.encode('utf8'))
 
         if phrase :
             # add phrase
-            cond.set_phrase(phrase)
+            cond.set_phrase(phrase.encode('utf8'))
         
         if order :
             # set order
@@ -268,11 +268,22 @@
         # execute
         return self.search_cond(cond)
 
-    def search_simple (self, channel, query, count=None, offset=None) :
+    def search_simple (self, channel, query, count=None, offset=None, search_msg=True, search_nick=False) :
         """
-            Search for lines from the given channel for the given simple query
+            Search for lines from the given channel for the given simple query.
+
+            The search_* params define which attributes to search for (using fulltext search for the message, STROR for
+            attributes).
         """
         
+        # search attributes
+        attrs = []
+
+        # nickname target query
+        if search_nick :
+            attrs.append("source_nickname STRINC %s" % query)
+#            attrs.append("target_nickname STRINC %s" % query)
+        
         # use search(), backwards
         results = list(self.search(
             # simplified phrase
@@ -282,7 +293,10 @@
             channel     = channel,
 
             # given phrase
-            phrase      = query,
+            phrase      = query if search_msg else None,
+
+            # attributes defined above
+            attrs       = attrs,
 
             # order by timestamp, descending (backwards)
             order       = "timestamp NUMD",