Changes between Version 15 and Version 16 of TracDev/PluginDevelopment/ExtensionPoints/trac.env.IEnvironmentSetupParticipant
- Timestamp:
- Mar 23, 2017, 3:50:01 AM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/PluginDevelopment/ExtensionPoints/trac.env.IEnvironmentSetupParticipant
v15 v16 32 32 def environment_created(self): 33 33 self.log.debug("creating environment for sample plugin.") 34 pass35 34 36 35 def environment_needs_upgrade(self): … … 40 39 def upgrade_environment(self): 41 40 self.log.debug("upgrading existing environment for sample plugin.") 42 pass43 41 }}} 44 42 … … 86 84 87 85 def environment_created(self): 88 dbm = DatabaseManager(self.env) 89 dbm.create_tables(PLUGIN_SCHEMA) 90 dbm.insert_into_tables(INITIAL_PLUGIN_DATA) 91 dbm.set_database_version(PLUGIN_VERSION, PLUGIN_NAME) 86 # Same work is done for environment created and 87 # upgraded, in almost all use-cases. 88 self.upgrade_environment() 92 89 93 90 def environment_needs_upgrade(self): … … 116 113 117 114 * [source:trunk/trac/env.py#L556 trac.env.EnvironmentSetup][[br]] 118 This is the setup participant that will initialize the trac database and also the sample configuration provided with each trac instance, providing sane initial defaults for use with both an existing environment and a newly created one. For the creation of a new environment it uses [source:trunk/trac/db_default.py the default db structure]. and on upgrade it will use [source:trunk/trac/upgrades a db upgrade path] defined in the individual db*.pymodules therein. The version number of the trac database schema is available from the ''system'' table, the key to look for is ''database_version.'' The value of this system property will be updated on environment upgrade. In addition to that, trac will also keep track of the initial database version that was installed when first creating the environment. The key to look for in the ''system'' table is ''initial_database_version''.115 This is the setup participant that will initialize the trac database and also the sample configuration provided with each trac instance, providing sane initial defaults for use with both an existing environment and a newly created one. For the creation of a new environment it uses [source:trunk/trac/db_default.py the default db structure]. and on upgrade it will use [source:trunk/trac/upgrades a db upgrade path] defined in the individual `db*.py` modules therein. The version number of the trac database schema is available from the ''system'' table, the key to look for is ''database_version.'' The value of this system property will be updated on environment upgrade. In addition to that, trac will also keep track of the initial database version that was installed when first creating the environment. The key to look for in the ''system'' table is ''initial_database_version''. 119 116 120 117 … … 132 129 * [http://www.edgewall.org/docs/trac-trunk/html/api/trac_env.html#trac.env.IEnvironmentSetupParticipant API Reference] 133 130 134 * #8172 aims to introduce more helper methods that simplify implementing this interface according to best practices.131 * `environment_created` is only called for a plugin if the plugin is enabled at the time the environment is created. To have a plugin enabled at the time the environment is created the `--inherit` (comment:42:ticket:8172) or `--config` (//since 1.2//) argument must be used to specify a configuration with the plugin enabled. 135 132 136 133 ==== API History … … 139 136 * Added `environment_needs_upgrade` and `upgrade_environment` methods. (changeset:1840) 140 137 * 1.1.2 deprecated `db` parameters. (changeset:12829, #11605) 138 * 1.1.5 added database helper methods (#8172) 141 139 * 1.3.1 removed `db` parameters. (changeset:14888, #11901)