Author: ianb
Date: 2005-02-08 08:00:25 +0000 (Tue, 08 Feb 2005)
New Revision: 574
Modified:
trunk/SQLObject/sqlobject/dbconnection.py
trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py
Log:
* Made dbconnection.DBConnection.uri() a bit more tollerant of missing
attributes
* Gave sqlite.SQLiteConnection a uri method, since it's not like the
other databases.
Modified: trunk/SQLObject/sqlobject/dbconnection.py
===================================================================
--- trunk/SQLObject/sqlobject/dbconnection.py 2005-02-08 07:59:38 UTC (rev 573)
+++ trunk/SQLObject/sqlobject/dbconnection.py 2005-02-08 08:00:25 UTC (rev 574)
@@ -44,13 +44,14 @@
atexit.register(_closeConnection, weakref.ref(self))
def uri(self):
- auth = self.user or ''
+ auth = getattr(self, 'user', None) or ''
if auth:
if self.password:
auth = auth + '@' + self.password
auth = auth + ':'
else:
- assert not self.password, 'URIs cannot express passwords without usernames'
+ assert not getattr(self, 'password', None), (
+ 'URIs cannot express passwords without usernames')
uri = '%s://%s' % (self.dbName, auth)
if self.host:
uri += self.host + '/'
Modified: trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py
===================================================================
--- trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py 2005-02-08 07:59:38 UTC (rev 573)
+++ trunk/SQLObject/sqlobject/sqlite/sqliteconnection.py 2005-02-08 08:00:25 UTC (rev 574)
@@ -23,11 +23,18 @@
def connectionFromURI(cls, uri):
user, password, host, path, args = cls._parseURI(uri)
- assert host is None, "SQLite can only be used locally (with a URI like sqlite:///file or sql:/file, not %r)" % uri
- assert user is None and password is None, "You may not provide usernames or passwords for SQLite databases"
+ assert host is None, (
+ "SQLite can only be used locally (with a URI like "
+ "sqlite:///file or sqlite:/file, not %r)" % uri)
+ assert user is None and password is None, (
+ "You may not provide usernames or passwords for SQLite "
+ "databases")
return cls(filename=path, **args)
connectionFromURI = classmethod(connectionFromURI)
+ def uri(self):
+ return 'sqlite:///%s' % self.filename
+
def _setAutoCommit(self, conn, auto):
conn.autocommit = auto
|