[Zodb-checkins] CVS: Packages/ZConfig - datatypes.py:1.3

Fred L. Drake, Jr. fred@zope.com
Tue, 7 Jan 2003 18:09:50 -0500


Update of /cvs-repository/Packages/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv4143

Modified Files:
	datatypes.py 
Log Message:
Change the return value of the socket-address data type conversion so that
AF_UNIX addresses can be parsed even on Windows.
This requires code that uses the socket-address values to change.


=== Packages/ZConfig/datatypes.py 1.2 => 1.3 ===
--- Packages/ZConfig/datatypes.py:1.2	Fri Jan  3 16:05:51 2003
+++ Packages/ZConfig/datatypes.py	Tue Jan  7 18:09:15 2003
@@ -174,17 +174,19 @@
     return host, port
 
 
-def socket_address(s):
-    # returns (family, address) tuple
-    import socket
-    if "/" in s:
-        if hasattr(socket, "AF_UNIX"):
-            return socket.AF_UNIX, s
+class SocketAddress:
+    def __init__(self, s):
+        # returns (family, address) tuple
+        import socket
+        if "/" in s:
+            if hasattr(socket, "AF_UNIX"):
+                self.family = socket.AF_UNIX
+            else:
+                self.family = None
+            self.address = s
         else:
-            raise ValueError(
-                "AF_UNIX sockets are not supported on this platform")
-    else:
-        return socket.AF_INET, inet_address(s)
+            self.family = socket.AF_INET
+            self.address = inet_address(s)
 
 def float_conversion(v):
     if isinstance(v, type('')) or isinstance(v, type(u'')):
@@ -311,7 +313,7 @@
     "basic-key":         BasicKeyConversion(),
     "logging-level":     LogLevelConversion(),
     "inet-address":      inet_address,
-    "socket-address":    socket_address,
+    "socket-address":    SocketAddress,
     "ipaddr-or-hostname":IpaddrOrHostname(),
     "existing-directory":existing_directory,
     "existing-path":     existing_path,