-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
I'm trying to resolve db compatibility issues [1][2] for the
TracFormsPlugin [3] lately.
A big step forwards was replacing it's proprietary db cursor
implementation with the generic old syntax (for Trac < 0.12 for
compatibility with Trac 0.11):
> def _get_db(self, db=None):
> return db or self.env.get_db_cnx()
> db = self._get_db(db)
> cursor = db.cursor()
But I've encountered an issue using the fetchone attribute for different
db types. I went straight at the cursor.fetchone() before but got an
AttributeError: 'NoneType' object has no attribute 'fetchone'
with PostgreSQL.
Reading through the different db connectors I've got the impression,
that only SQLite is returning an (empty) object in the no-results case.
I wrote some debug statements into the code as follows:
> r = cursor.execute(sql, src)
> self.env.log.debug('CURSOR = ' + str(r))
> self.env.log.debug('ROWSATTR = ' + str(getattr(r, 'rows', None)))
> if not r is None:
> row = r.fetchone()
> self.env.log.debug('ROW = ' + str(row))
> if not row is None:
> return row
[If you wonder, 'src' is guaranteed to be a tuple matching SQL
statements in 'sql' here.]
with SQLite
Trac[formdb] DEBUG: CURSOR = <trac.db.sqlite_backend.EagerCursor object
at 0xb2860cc>
Trac[formdb] DEBUG: ROWSATTR = []
Trac[formdb] DEBUG: ROW = None
with PostgreSQL
Trac[formdb] DEBUG: CURSOR = None
Trac[formdb] DEBUG: ROWSATTR = None
(not hitting 3rd debug because not going past preceding IF statement)
This is unexpected, and I can't see any such logic at similar places in
Trac core (looked i.e. at ticket.model) where fetchone() is used to
decide on INSERT vs. UPDATE like I'd like to do it too.
This is certainly a remaining flaw in the plugin code, right? The
aforementioned change is a rather big patch, so would be no wonder, if I
missed something.
Any thoughts? Thank you in advance for taking care.
Yours,
Steffen Hoffmann
(hasienda)
[1] https://trac-hacks.org/ticket/5608
[2] https://trac-hacks.org/ticket/5667
[3] http://trac-hacks.org/wiki/TracFormsPlugin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk3N/UoACgkQ31DJeiZFuHeXfgCgseBU4fCqTIUtLWXJIeF5VORc
3FsAoJOkR9Xi9Ga97Px6lgrWZQ94I2vR
=1i1z
-----END PGP SIGNATURE-----
--
You received this message because you are subscribed to the Google Groups "Trac
Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/trac-dev?hl=en.