Changes between Version 12 and Version 13 of TracDev/PluginDevelopment
- Timestamp:
- Jun 22, 2006, 11:26:01 AM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/PluginDevelopment
v12 v13 66 66 Storing any other objects as instance variables of your component is probably a bad idea: remember that a component is only instantiated once for a given environment; unless your plugin is used in a CGI deployment of Trac, that means that the same component instance will get invoked for multiple HTTP requests; if the server is multi-threaded, this will even happen concurrently. 67 67 68 == Packaging and deployingplugins ==68 == Packaging plugins == 69 69 70 TracPlugins are packaged as [http://peak.telecommunity.com/DevCenter/PythonEggs Python Eggs]. You can use [http://peak.telecommunity.com/DevCenter/setuptools setuptools] to make a `setup.py` script that will produce a Python Egg for your plugin.70 TracPlugins are packaged as [http://peak.telecommunity.com/DevCenter/PythonEggs Python Eggs]. You can use [http://peak.telecommunity.com/DevCenter/setuptools setuptools] to make a `setup.py` script that will produce a Python egg for your plugin. 71 71 72 The egg needs to export an [http://peak.telecommunity.com/DevCenter/setuptools#dynamic-discovery-of-services-and-plugins entry point] group named `trac.plugins`, listing the names of the modules that Trac should import for the plugin-provided components to get registered. For example: 72 73 73 The egg file needs to have a file named `trac_plugin.txt` in its `EGG-INFO` directory. This file should contain the names of all modules that need to be imported by Trac to register your components. 74 {{{ 75 #!python 76 from setuptools import find_packages, setup 74 77 75 ''Note that this will change in the very near future: setuptools 0.6 will introduce the concept of “entry points”, which will be used instead of the `trac_plugin.txt` descriptor.''. See TracPlugins for details. 78 setup( 79 name='TracHelloWorld', version='1.0', 80 packages=find_packages(exclude=['*.tests*']), 81 entry_points = """ 82 [trac.plugins] 83 helloworld = myplugs.helloworld 84 """, 85 ) 86 }}} 87 88 This assumes that the `HelloWorldPlugin` example above is defined in the module `helloworld.py` in the `myplugs` package. The entry point ''name'' (in this example “helloworld”) is required by the Python egg runtime, but not currently used by Trac. In most cases, you can simply use the qualified module name there. 89 90 ''For backwards-compatibility reasons, Trac still supports an alternative to entry points: you can have a file named `trac_plugin.txt` in the `EGG-INFO` directory. This file should contain the names of all modules that need to be imported by Trac to register your components. Note that this method is '''deprecated''' and will be removed in a future version of Trac (probably as soon as [milestone:0.11].'' 91 92 == Plugin deployment == 76 93 77 94 A plugin can either be deployed globally, or only for a specific environment. Global deployment is done by installing the plugin: