[Zope3-checkins] CVS: Packages/ZConfig - datatypes.py:1.1.2.10

Fred L. Drake, Jr. fred@zope.com
Fri, 13 Dec 2002 13:37:36 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	datatypes.py 
Log Message:
- basic-key no longer allows a leading underscore
- integer should not be range-restricted on older Python's


=== Packages/ZConfig/datatypes.py 1.1.2.9 => 1.1.2.10 ===
--- Packages/ZConfig/datatypes.py:1.1.2.9	Fri Dec 13 12:58:05 2002
+++ Packages/ZConfig/datatypes.py	Fri Dec 13 13:37:36 2002
@@ -14,6 +14,7 @@
 """Selection of standard datatypes for ZConfig."""
 
 import re
+import sys
 
 try:
     True
@@ -89,7 +90,7 @@
 
 class BasicKeyConversion(RegularExpressionConversion):
     def __init__(self):
-        RegularExpressionConversion.__init__(self, "[_a-zA-Z][-._a-zA-Z0-9]*")
+        RegularExpressionConversion.__init__(self, "[a-zA-Z][-._a-zA-Z0-9]*")
 
     def convert(self, value):
         value = str(value)
@@ -123,6 +124,16 @@
             return v
 
 
+if sys.version[:3] < "2.3":
+    def integer(value):
+        try:
+            return int(value)
+        except ValueError:
+            return long(value)
+else:
+    integer = int
+
+
 def asBoolean(s):
     """Convert a string value to a boolean value."""
     ss = str(s).lower()
@@ -136,7 +147,7 @@
 
 stock_datatypes = {
     "boolean":       asBoolean,
-    "integer":       int,
+    "integer":       integer,
     "float":         float,
     "str":           str,
     "locale":        MemoizedConversion(check_locale).convert,