[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/RDB - ZopeDatabaseAdapter.py:1.9

Marius Gedminas mgedmin@codeworks.lt
Mon, 18 Nov 2002 06:33:06 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/RDB
In directory cvs.zope.org:/tmp/cvs-serv20347

Modified Files:
	ZopeDatabaseAdapter.py 
Log Message:
Explain parseDSN return value in the docstring

=== Zope3/lib/python/Zope/App/RDB/ZopeDatabaseAdapter.py 1.8 => 1.9 ===
--- Zope3/lib/python/Zope/App/RDB/ZopeDatabaseAdapter.py:1.8	Fri Nov  8 07:46:58 2002
+++ Zope3/lib/python/Zope/App/RDB/ZopeDatabaseAdapter.py	Mon Nov 18 06:33:05 2002
@@ -2,14 +2,14 @@
 #
 # Copyright (c) 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
-# 
+#
 ##############################################################################
 """The connection adapters contained by ConnectionService.
 
@@ -32,11 +32,11 @@
 
     def __init__(self, dsn):
         self.setDSN(dsn)
-        
+
     def _connection_factory(self):
         """This method should be overwritten by all subclasses"""
         conn_info = parseDSN(self.dsn)
-        
+
     ############################################################
     # Implementation methods for interface
     # Zope.App.RDB.IZopeDatabaseAdapter.
@@ -94,7 +94,9 @@
     return x
 
 def parseDSN(dsn):
-    """We could have the following cases:
+    """Parses a database connection string.
+
+    We could have the following cases:
 
        dbi://dbname
        dbi://dbname;param1=value...
@@ -102,6 +104,15 @@
        dbi://user:passwd/dbname;param1=value...
        dbi://user:passwd@host:port/dbname
        dbi://user:passwd@host:port/dbname;param1=value...
+
+    Return value is a mapping with the following keys:
+
+       username     username (if given) or an empty string
+       password     password (if given) or an empty string
+       host         host (if given) or an empty string
+       port         port (if given) or an empty string
+       dbname       database name
+       parameters   a mapping of additional parameters to their values
     """
     assert isinstance(dsn, StringTypes), 'The dsn is not a string.'
     assert dsn.startswith('dbi://'), 'Invalid DSN; must start with "dbi://"'
@@ -136,7 +147,7 @@
 
     result['host'] = host
     result['port'] = port
-    
+
     # Get username and password from DSN
     if dsn:
         username, password = dsn.split(':')
@@ -147,9 +158,3 @@
     result['password'] = password
 
     return result
-
-
-
-
-
-