Modify ↓
Opened 8 years ago
Closed 8 years ago
#13038 closed defect (fixed)
ValuePropagationPlugin [patch] fix "AttributeError: 'Environment' object has no attribute 'get_db_cnx'"
Reported by: | komar | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Component: | ValuePropagationPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 1.2 |
Description
After upgrading trac to 1.2 I get error:
AttributeError: 'Environment' object has no attribute 'get_db_cnx'
there is a patch
--- a/valuepropagation.py 2017-01-05 13:38:50.379971566 +0100 +++ b/valuepropagation.py 2017-01-05 15:03:44.000000000 +0100 @@ -99,13 +99,13 @@ self.enums = {} self.enums['priority_value'] = 'priority' - db = self.env.get_db_cnx() - cursor = db.cursor() - cursor.execute("SELECT name," + - db.cast('value', 'int') + - " FROM enum WHERE type=%s", ('priority',)) - for name, value in cursor: - self.p_values[name] = value + with self.env.db_query as db: + cursor = db.cursor() + cursor.execute("SELECT name," + + db.cast('value', 'int') + + " FROM enum WHERE type=%s", ('priority',)) + for name, value in cursor: + self.p_values[name] = value # ============================================================ # A propagation method is called from a ticket change listener @@ -260,11 +260,11 @@ if q == None: self.env.log.debug("%s has no query configured" % r) else: - db = self.env.get_db_cnx() - cursor = db.cursor() - cursor.execute(q, (ticket.id,)) - for id in [int(row[0]) for row in cursor]: - self._propagate(r, ticket, old_values, id, id) + with self.env.db_query as db: + cursor = db.cursor() + cursor.execute(q, (ticket.id,)) + for id in [int(row[0]) for row in cursor]: + self._propagate(r, ticket, old_values, id, id) # Propagate values from ticket to the ticket whose ID is @@ -323,15 +323,15 @@ # Determine sequence number. cnum = 0 tm = TicketModule(self.env) - db = self.env.get_db_cnx() - for change in tm.grouped_changelog_entries(ticket, db): - # FIXME - should this say "and change['cnum'] > cnum? - if change['permanent']: - cnum = change['cnum'] - # FIXME - Put something in the message? - # FIXME - the ticket_changed method gets an author, should - # this say "value propagation on behalf of <author>"? - ticket.save_changes('value propagation', '', when, db, cnum+1) + with self.env.db_query as db: + for change in tm.grouped_changelog_entries(ticket, db): + # FIXME - should this say "and change['cnum'] > cnum? + if change['permanent']: + cnum = change['cnum'] + # FIXME - Put something in the message? + # FIXME - the ticket_changed method gets an author, should + # this say "value propagation on behalf of <author>"? + ticket.save_changes('value propagation', '', when, db, cnum+1) # All the propagation is done, save the new values when = datetime.datetime.now()
Attachments (0)
Change History (4)
comment:1 Changed 8 years ago by
Trac Release: | → 1.2 |
---|
comment:3 Changed 8 years ago by
Owner: | changed from Chris Nelson to Ryan J Ollos |
---|---|
Status: | new → accepted |
Note: See
TracTickets for help on using
tickets.
db
parameter has been removed fromTicketModule.grouped_changelog_entries()
andTicket.save_changes()
in trac:r12826. I believe suggested patch is incomplete.