[Zodb-checkins] CVS: StandaloneZConfig/ZConfig - datatypes.py:1.20

Fred L. Drake, Jr. fred at zope.com
Wed Dec 31 20:59:19 EST 2003


Update of /cvs-repository/StandaloneZConfig/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv14171

Modified Files:
	datatypes.py 
Log Message:
two new datatypes: dotted-name and dotted-suffix


=== StandaloneZConfig/ZConfig/datatypes.py 1.19 => 1.20 ===
--- StandaloneZConfig/ZConfig/datatypes.py:1.19	Mon Dec 29 15:43:43 2003
+++ StandaloneZConfig/ZConfig/datatypes.py	Wed Dec 31 20:58:48 2003
@@ -108,10 +108,7 @@
         return RegularExpressionConversion.__call__(self, value).lower()
 
 
-class IdentifierConversion(RegularExpressionConversion):
-    def __init__(self):
-        RegularExpressionConversion.__init__(self, "[_a-zA-Z][_a-zA-Z0-9]*")
-
+class ASCIIConversion(RegularExpressionConversion):
     def __call__(self, value):
         value = RegularExpressionConversion.__call__(self, value)
         if UnicodeType is not None and isinstance(value, UnicodeType):
@@ -119,6 +116,26 @@
         return value
 
 
+_ident_re = "[_a-zA-Z][_a-zA-Z0-9]*"
+
+class IdentifierConversion(ASCIIConversion):
+    def __init__(self):
+        ASCIIConversion.__init__(self, _ident_re)
+
+
+class DottedNameConversion(ASCIIConversion):
+    def __init__(self):
+        ASCIIConversion.__init__(self,
+                                 r"%s(?:\.%s)*" % (_ident_re, _ident_re))
+
+
+class DottedNameSuffixConversion(ASCIIConversion):
+    def __init__(self):
+        ASCIIConversion.__init__(self,
+                                 r"(?:%s)(?:\.%s)*|(?:\.%s)+"
+                                 % (_ident_re, _ident_re, _ident_re))
+
+
 def integer(value):
     try:
         return int(value)
@@ -252,6 +269,8 @@
 
 stock_datatypes = {
     "boolean":           asBoolean,
+    "dotted-name":       DottedNameConversion(),
+    "dotted-suffix":     DottedNameSuffixConversion(),
     "identifier":        IdentifierConversion(),
     "integer":           integer,
     "float":             float_conversion,




More information about the Zodb-checkins mailing list