Modify ↓
Opened 15 years ago
Closed 15 years ago
#7203 closed enhancement (fixed)
Set up database on environment_create()
Reported by: | pipern | Owned by: | Mikael Relbe |
---|---|---|---|
Priority: | normal | Component: | TracTicketChangesetsPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.12 |
Description
I think it's nice to avoid an upgrade step if the plugin is enabled when the environment is first created, so I did this:
-
ticketchangesets/init.py
a b class TicketChangesetsInit(Component): 36 36 37 37 # IEnvironmentSetupParticipant. 38 38 def environment_created(self): 39 pass 39 """ Called when a new environment is created. Procedure is similar to 40 an environment upgrade, but we also need to commit the changes 41 ourselves. """ 42 db = self.env.get_db_cnx() 43 self.upgrade_environment(db) 44 db.commit() 40 45 41 46 def environment_needs_upgrade(self, db): 42 47 # Is database up to date?
Attachments (0)
Change History (6)
comment:1 Changed 15 years ago by
Status: | new → assigned |
---|
comment:3 Changed 15 years ago by
I think the patch should look like this:
-
ticketchangesets/init.py
36 36 37 37 # IEnvironmentSetupParticipant. 38 38 def environment_created(self): 39 pass 39 """Initialise a created environment for this plugin.""" 40 @self.env.with_transaction() 41 def do_create(db): 42 self.upgrade_environment(db) 40 43 41 44 def environment_needs_upgrade(self, db): 42 45 # Is database up to date?
BUT: How can the plugin be activated during the creation of an environment? I cannot verify this code...
comment:4 Changed 15 years ago by
#T9416 explains the problem, I will fix this when that is fixed first.
comment:6 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Type: | defect → enhancement |
Fix committed in [8111].
Note: See
TracTickets for help on using
tickets.
If you create an environment from scratch, this plugin cannot be activated. Therefore, the only use case must be when an environment is created with the "--inherit" option. Right?
But the problem is that something goes terribly wrong when I try this with Trac 0.12dev-r9818.
The provided patch is nevertheless a good suggestion, I'll get back when I found the problem with creating inherited environments.