Author: phd
Date: 2006-03-09 08:57:40 -0700 (Thu, 09 Mar 2006)
New Revision: 1643
Modified:
SQLObject/branches/0.7-bugfix/docs/SQLObject.txt
SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_parse.py
Log:
Merged patches from revisions 1641, 1642 from the trunk:
postgres DB URIs with a non-default path to unix socket.
Modified: SQLObject/branches/0.7-bugfix/docs/SQLObject.txt
===================================================================
--- SQLObject/branches/0.7-bugfix/docs/SQLObject.txt 2006-03-09 15:56:32 UTC (rev 1642)
+++ SQLObject/branches/0.7-bugfix/docs/SQLObject.txt 2006-03-09 15:57:40 UTC (rev 1643)
@@ -137,7 +137,7 @@
scheme://[user[:password]@]host[:port]/database[?parameters]
Scheme is one of ``sqlite``, ``mysql``, ``postgres``, ``firebird``,
-``interbase``, ``maxdb``, ``sapdb``, ``sybase``.
+``interbase``, ``maxdb``, ``sapdb``, ``mssql``, ``sybase``.
Examples::
Modified: SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py 2006-03-09 15:56:32 UTC (rev 1642)
+++ SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py 2006-03-09 15:57:40 UTC (rev 1643)
@@ -90,6 +90,10 @@
def connectionFromURI(cls, uri):
user, password, host, port, path, args = cls._parseURI(uri)
path = path.strip('/')
+ if (host is None) and path.count('/'): # Non-default unix socket
+ path_parts = path.split('/')
+ host = '/' + '/'.join(path_parts[:-1])
+ path = path_parts[-1]
return cls(host=host, port=port, db=path, user=user, passwd=password, **args)
connectionFromURI = classmethod(connectionFromURI)
Modified: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_parse.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/test_parse.py 2006-03-09 15:56:32 UTC (rev 1642)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/test_parse.py 2006-03-09 15:57:40 UTC (rev 1643)
@@ -8,21 +8,21 @@
def test_parse():
_parseURI = DBConnection._parseURI
- user, password, host, port, path, args = _parseURI("mysql://user:passwd@host/database")
- assert user == "user"
- assert password == "passwd"
+ user, password, host, port, path, args = _parseURI("mysql://host/database")
+ assert user is None
+ assert password is None
assert host == "host"
assert port is None
assert path == "/database"
assert args == {}
- user, password, host, port, path, args = _parseURI("mysql://host/database")
- assert user is None
- assert password is None
+ user, password, host, port, path, args = _parseURI("mysql://user:pass%20word@host/database?unix_socket=/var/mysql/socket")
+ assert user == "user"
+ assert password == "pass%20word"
assert host == "host"
assert port is None
assert path == "/database"
- assert args == {}
+ assert args == {"unix_socket": "/var/mysql/socket"}
user, password, host, port, path, args = _parseURI("postgres://user@host/database")
assert user == "user"
@@ -40,6 +40,14 @@
assert path == "/database"
assert args == {}
+ user, password, host, port, path, args = _parseURI("postgres:///full/path/to/socket/database")
+ assert user == None
+ assert password is None
+ assert host == None
+ assert port is None
+ assert path == "/full/path/to/socket/database"
+ assert args == {}
+
user, password, host, port, path, args = _parseURI("sqlite:///full/path/to/database")
assert user is None
assert password is None
|