Prototype of bcmagic search plugin.
[htsworkflow.git] / htsworkflow / frontend / bcmagic / plugin.py
index 6653fd9261331b6d43cec48e8810ee4feabd3ebb..d701cf383d3bd91b12d5ade1db3e8beb55629015 100644 (file)
@@ -2,6 +2,7 @@
 
 #BCM_PLUGINS = {'cmd_move_sample': bcm_cmds.cmd_move_sample}
 
+_SEARCH_FUNCTIONS = {}
 
 def bcm_plugin_processor(keyword, text, bcm_mode):
     """
@@ -15,4 +16,19 @@ def bcm_plugin_processor(keyword, text, bcm_mode):
         d['status'] = 'bcm_mode plugin called "%s" was not found' % (bcm_mode)
         return d
     
-    return BCM_PLUGINS[bcm_mode](keyword, text, bcm_mode)
\ No newline at end of file
+    return BCM_PLUGINS[bcm_mode](keyword, text, bcm_mode)
+    
+
+def register_search_plugin(label, search_function):
+    """
+    Registers a group label and search_function
+    
+    search_function(search_string) --> (text_display, obj_url)
+    """
+    
+    if label in _SEARCH_FUNCTIONS:
+        msg = "search function for label (%s) already registered." % (label)
+        raise ValueError, msg
+    
+    _SEARCH_FUNCTIONS[label] = search_function
+    
\ No newline at end of file