Package brisa :: Package core :: Module plugin
[hide private]
[frames] | no frames]

Source Code for Module brisa.core.plugin

  1  # Licensed under the MIT license 
  2  # http://opensource.org/licenses/mit-license.php or see LICENSE file. 
  3  # Copyright 2007-2008 Brisa Team <brisa-develop@garage.maemo.org> 
  4   
  5  """ Defines a interface for plugins. These plugins can be managed by the 
  6  PluginManager. 
  7  """ 
  8   
9 -class PluginInterface(object):
10 """ The base class to all plugins. For writing plugins inherit from this 11 class and set the appropriate values for your plugin: 12 13 - name: friendly name for your plugin. All objects inside your plugin 14 will be named in the form name:id. 15 16 - usage: can be on or off. This value is automatically set when your 17 plugin has an entry on the configuration file. When set to 'off', the 18 plugin manager will not instantiate the plugin. 19 20 - has_browse_filter: can be True or False. If your plugin implements 21 the browse() function in a way that it uses the slicing/sorting 22 (filters) parameters, has_browse_filter should be set to True. If 23 not, it should be False (which means that the filter will be applied 24 by the plugin manager - your plugin returns browse result). 25 """ 26 name = 'plugin_stub' 27 usage = False 28 watch = False 29 has_browse_filter = False 30
31 - def __init__(self, *args, **kwargs):
32 """ Initializes the base plugin. If overwritten, remember to set 33 plugin_manager to PluginManagerSingleton. 34 """ 35 self.plugin_manager = None
36
37 - def execute(self):
38 """ Loads the plugin media information into the database. 39 """ 40 self.load()
41
42 - def load(self):
43 """ Forces subclasses to implement the load method. 44 """ 45 raise NotImplementedError("%s: load method not implemented" % 46 self.name)
47
48 - def publish(self, webserver):
49 """ Publishes the plugin resources on the service's webserver. Optional. 50 """ 51 pass
52
53 - def unload(self):
54 """ Unloads the plugin media information from memory. 55 """ 56 raise NotImplementedError("%s: unload method not implemented" % 57 self.name)
58
59 - def browse(self, str_object_id, browse_flag, filter, starting_index, 60 requested_count, sort_criteria):
61 """ Browse implementation for the plugin. See Plugin documentation for 62 information about the has_browse_filter flag. 63 64 @param str_object_id: object to be browsed 65 @param browse_flag: UPnP flag 66 @param filter: filter parameter 67 @param starting_index: The starting intex of the browser 68 @param requested_count: Requested number of entries under the object 69 @param sort_criteria: sorting criteria 70 71 @type str_object_id: string 72 @type browse_flag: string 73 @type filter: string 74 @type starting_index: ui4 75 @type requested_count: ui4 76 @type sort_criteria: string 77 78 @return: the results of the browsing action 79 @rtype: string 80 """ 81 raise NotImplementedError("browse not implemented for plugin %s" % 82 self.name)
83
84 - def search(self, str_object_id, browse_flag, filter, starting_index, 85 requested_count, sort_criteria):
86 """ Search implementation for the plugin. 87 88 @param str_object_id: object to be searched 89 @param browse_flag: UPnP flag 90 @param filter: filter parameter 91 @param starting_index: The starting intex of the browser 92 @param requested_count: Requested number of entries under the object 93 @param sort_criteria: sorting criteria 94 95 @type str_object_id: string 96 @type browse_flag: string 97 @type filter: string 98 @type starting_index: ui4 99 @type requested_count: ui4 100 @type sort_criteria: string 101 102 @return: the results of the searching action 103 @rtype: string 104 """ 105 raise NotImplementedError("search not implemented for plugin %s" % 106 self.name)
107