Edgewall Software
Modify

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#8646 closed task (duplicate)

Remove support for obsolete DB bindings

Reported by: Remy Blank Owned by: Remy Blank
Priority: normal Milestone:
Component: database backend Version: none
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Support for pysqlite-1.0.x and pyPgSql is deprecated in 0.11 and should be removed in 0.12.

Attachments (0)

Change History (6)

comment:1 by Christian Boos, 15 years ago

We already had tickets for that! ;-)

#8539 and #8625

I have the deprecation patch for 0.11.6 ready to go, is that OK for you or had you something more elaborate in mind?

  • trac/db/sqlite_backend.py

    diff --git a/trac/db/sqlite_backend.py b/trac/db/sqlite_backend.py
    a b  
    118118
    119119    def get_connection(self, path, log=None, params={}):
    120120        if not self._version:
    121             global sqlite_version_string
     121            global sqlite_version_string, have_pysqlite
    122122            self._version = get_pkginfo(sqlite).get(
    123123                'version', '%d.%d.%s' % sqlite.version_info)
    124124            self.env.systeminfo.extend([('SQLite', sqlite_version_string),
    125125                                        ('pysqlite', self._version)])
     126            if have_pysqlite == 1:
     127                self.log.warning("Support for SQLite v2 and PySqlite 1.0.x "
     128                                 "will be dropped in version 0.12, see "
     129                                 "http://trac.edgewall.org/wiki/"
     130                                 "PySqlite#UpgradingSQLitefrom2.xto3.x")
    126131        return SQLiteConnection(path, log, params)
    127132
    128133    def init_db(cls, path, log=None, params={}):

comment:2 by Remy Blank, 15 years ago

Milestone: 0.12
Resolution: duplicate
Status: newclosed

Oops, sorry. I was going through TracDev/ToDo and thought that I could probably handle that. There was no ticket number next to these items, and I didn't bother to check.

Your patch looks fine (except that you could remove the global declaration altogether, as long as the variables are not written to, they will be found in the global scope anyway). Please apply.

I am working on 0.12, and have the SQLite part ready.

So, closing as a duplicate of #8539 and #8625.

in reply to:  2 ; comment:3 by Christian Boos, 15 years ago

Replying to rblank:

… you could remove the global declaration altogether, as long as the variables are not written to, they will be found in the global scope anyway

Yes, but it seems that elsewhere in the code we use that as a hint to indicate where the variable comes from. I remember having been confused at least once when such a qualifier was not there, so I prefer to do it that way.

OTOH, I'm not against making a stricter usage of the keyword, if you think it's worth it, but then we should probably do it consistently and document it in the TracDev/CodingStyle as PEP:0008 doesn't say a word about this.

in reply to:  3 ; comment:4 by Remy Blank, 15 years ago

Replying to cboos:

OTOH, I'm not against making a stricter usage of the keyword, if you think it's worth it, but then we should probably do it consistently and document it in the TracDev/CodingStyle as PEP:0008 doesn't say a word about this.

It's just the normal way of looking up names in Python. For example, every time you access a name that was imported from another module in the global scope, you do the same kind of lookup.

The global declaration is only needed if you want to write to a global variable from inside a function. From the Python docs:

The global statement is a declaration which holds for the entire current code block. It means that the listed identifiers are to be interpreted as globals. It would be impossible to assign to a global variable without global, although free variables may refer to globals without being declared global.

So I don't really think this needs to be documented…

in reply to:  4 ; comment:5 by Christian Boos, 15 years ago

Replying to rblank:

Replying to cboos:

OTOH, I'm not against making a stricter usage of the keyword, if you think it's worth it, but then we should probably do it consistently and document it in the TracDev/CodingStyle as PEP:0008 doesn't say a word about this.

It's just the normal way of looking up names in Python. For example, every time you access a name that was imported from another module in the global scope, you do the same kind of lookup.

The global declaration is only needed if you want to write

I know, my point was that that using the "global" keyword as a hint that the variable we use (for read) is a global, seems to be an idiom in the Trac code (counted 19 occurrences). But we could change that.

in reply to:  5 comment:6 by Remy Blank, 15 years ago

Replying to cboos:

I know, my point was that that using the "global" keyword as a hint that the variable we use (for read) is a global, seems to be an idiom in the Trac code (counted 19 occurrences).

That's not a lot, considering the actual number of accesses to global variables we do ;-) My feeling is that there were a few "legitimate" instances to start with, and this was misunderstood as an idiom.

Counting actual instances, I see 10 legitimate uses of global in 0.11-stable, versus 9 non-necessary uses. Not really what you'd call an idiom, I would say.

Anyway, I'll remove the unnecessary global declarations in 0.12 and document the change.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.