Modify

Opened 14 years ago

Closed 14 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): 
    3636
    3737    # IEnvironmentSetupParticipant.
    3838    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()
    4045
    4146    def environment_needs_upgrade(self, db):
    4247        # Is database up to date?

Attachments (0)

Change History (6)

comment:1 Changed 14 years ago by Mikael Relbe

Status: newassigned

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.

comment:2 Changed 14 years ago by Mikael Relbe

The problem was me ;) I'm going to apply the patch now.

comment:3 Changed 14 years ago by Mikael Relbe

I think the patch should look like this:

  • ticketchangesets/init.py

     
    3636
    3737    # IEnvironmentSetupParticipant.
    3838    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)
    4043
    4144    def environment_needs_upgrade(self, db):
    4245        # 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 14 years ago by anonymous

#T9416 explains the problem, I will fix this when that is fixed first.

comment:5 Changed 14 years ago by Mikael Relbe

[T9847] makes it possible to test this.

comment:6 Changed 14 years ago by Mikael Relbe

Resolution: fixed
Status: assignedclosed
Type: defectenhancement

Fix committed in [8111].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Mikael Relbe.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.