Changes between Version 6 and Version 7 of Development/1.2/Plugin


Ignore:
Timestamp:
08/28/2009 02:09:20 AM (13 years ago)
Author:
andar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Development/1.2/Plugin

    v6 v7  
    108108}}} 
    109109 
    110 We won't worry about the imports at the top, you should be able to surmise what these are for and if not, you'll see them in use later in this example.  What we will worry about, and what seems to be right in our face, is plugin configuration. 
     110==== Imports ==== 
     111 
     112There are a number of imports at the top of this file and you may not end up using all of them.  I will describe what they are for. 
     113 
     114 * log - This is the Deluge logging object.  It can be handy for logging debug information or anything else you want printed to the log.  It has a few methods: log.debug("Message"), log.error("Message"), log.info("Message"), etc..  You can see the rest defined in the python logging module documentation. 
     115 * CorePluginBase - This is the base class we use for our Core plugin. 
     116 * component - This provides access to the component registry where you can reference any of the Deluge components for use in your plugin. 
     117 * configmanager - This allows access to the Deluge ConfigManager which is how you will access config files. 
     118 * export - This is a decorator function we use to ''export'' RPC methods. 
     119 
     120==== Special Methods ==== 
     121 
     122You may notice that we have a few methods at the top of this class: `enable()`, `disable()`, `update()`.  These methods are overloaded from the base class and are called at different times. 
     123 * enable() - This method is called when the plugin is enabled, either by the user or when the program starts. 
     124 * disable() - This method is called when the plugin is disabled, either by the user or by exiting the program. 
     125 * update() - This method is called every second while the plugin is disabled. 
     126 
     127You don't need to necessarily ''do'' anything in these methods, but you should at least define them and put a `pass` statement in. 
     128 
     129 
     130==== Configuration ==== 
     131 
     132We'll get started by examining what is already going on in this plugin template and that is a basic setup to handle configuration setting and getting. 
     133 
     134The first thing that is done, is creating the Config object when the plugin is enabled. 
    111135 
    112136{{{ 
     
    118142 
    119143You can read here: http://deluge-torrent.org/docs/current/modules/config.html for more information on the Config class. 
    120  
    121 Before we go too much further, you'll notice that this config file loading is done within the `enable` method of our Core plugin class.  Whenever a plugin is enabled by the user or on start-up, this method will be called.  Likewise for the `disable` method which is called whenever the plugin is disabled.  Simple, right? 
    122144 
    123145{{{