Opened 7 years ago

Closed 6 years ago

#7203 closed enhancement (fixed)

Set up database on environment_create()

Reported by: pipern Owned by: mrelbe
Priority: normal Component: TracTicketChangesetsPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12


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/

    a b class TicketChangesetsInit(Component): 
    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()
    4146    def environment_needs_upgrade(self, db):
    4247        # Is database up to date?

Attachments (0)

Change History (6)

comment:1 Changed 7 years ago by mrelbe

  • Status changed from new to assigned

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 6 years ago by mrelbe

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

comment:3 Changed 6 years ago by mrelbe

I think the patch should look like this:

  • ticketchangesets/

    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)
    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 6 years ago by anonymous

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

comment:5 Changed 6 years ago by mrelbe

[T9847] makes it possible to test this.

comment:6 Changed 6 years ago by mrelbe

  • Resolution set to fixed
  • Status changed from assigned to closed
  • Type changed from defect to enhancement

Fix committed in [8111].

Add Comment

Modify Ticket

as closed The owner will remain mrelbe.
The resolution will be deleted. Next status will be 'reopened'.

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

Note: See TracTickets for help on using tickets.