[Modeling-users] [patch] Handle boolean values in xml model for python 2.3
Status: Abandoned
Brought to you by:
sbigaret
|
From: John G. <ig...@do...> - 2003-12-08 14:01:55
|
Hi,
This is a 2nd try on a patch sent last week about handling boolean values
in the xml model generated with python 2.3. It is less intrusive than the
previous and it doesn't use the bool() built-in, so it runs under python
2.1 as well.
diff -urN --exclude=Python_bricks Modeling.orig/Attribute.py Modeling/Attribute.py
--- Modeling.orig/Attribute.py 2003-08-30 20:22:56.000000000 +0300
+++ Modeling/Attribute.py 2003-12-08 13:29:19.000000000 +0200
@@ -572,6 +572,8 @@
attrType=self.xmlAttributeType(attributeName)
set=self.xmlSetAttribute(attributeName)
if attrType=='string': value=unicodeToStr(value, encoding)
+ elif attrType=='number': value=int(value)
+ elif attrType=='bool': value=int(value)
set(value)
def getXMLDOM(self, doc=None, parentNode=None, encoding='iso-8859-1'):
@@ -596,7 +598,9 @@
exportAttrDict=self.xmlAttributesDict(select=1)
for attr in exportAttrDict.keys():
+ attrType=self.xmlAttributeType(attr)
value=self.xmlGetAttribute(attr)()
+ if attrType=='bool': value=int(value)
value=strToUnicode(str(value), encoding)
node.setAttribute(attr, value)
@@ -634,10 +638,10 @@
'externalType' : ('string',
self.setExternalType,
self.externalType),
- 'isClassProperty' : ('string',
+ 'isClassProperty' : ('bool',
self.setIsClassProperty,
self.isClassProperty),
- 'isRequired' : ('string',
+ 'isRequired' : ('bool',
self.setIsRequired,
self.isRequired),
# defaultValue must be loaded AFTER type is set, or we will get the
@@ -659,7 +663,7 @@
setType(aType=aType,
check=0),
self.type),
- 'isFlattened' : ('string',
+ 'isFlattened' : ('bool',
self.setIsFlattened,
self.isFlattened),
'width' : ('string',
diff -urN --exclude=Python_bricks Modeling.orig/Entity.py Modeling/Entity.py
--- Modeling.orig/Entity.py 2003-10-04 15:29:43.000000000 +0300
+++ Modeling/Entity.py 2003-12-08 13:31:19.000000000 +0200
@@ -1278,6 +1278,8 @@
attrType=self.xmlAttributeType(attributeName)
set=self.xmlSetAttribute(attributeName)
if attrType=='string': value=unicodeToStr(value, encoding)
+ elif attrType=='number': value=int(value)
+ elif attrType=='bool': value=int(value)
set(value)
if phase==1:
@@ -1359,7 +1361,9 @@
exportAttrDict=self.xmlAttributesDict()
for attr in exportAttrDict.keys():
+ attrType=self.xmlAttributeType(attr)
value=self.xmlGetAttribute(attr)()
+ if attrType=='bool': value=int(value)
value=strToUnicode(str(value), encoding)
node.setAttribute(attr, value)
@@ -1405,10 +1409,10 @@
'externalName': ( 'string',
self.setExternalName,
self.externalName ),
- 'isReadOnly': ( 'string',
+ 'isReadOnly': ( 'bool',
self.setReadOnly,
self.isReadOnly ),
- 'isAbstract': ( 'string',
+ 'isAbstract': ( 'bool',
self.setIsAbstract,
self.isAbstract ),
'moduleName': ( 'string',
diff -urN --exclude=Python_bricks Modeling.orig/Relationship.py Modeling/Relationship.py
--- Modeling.orig/Relationship.py 2003-07-28 10:18:59.000000000 +0300
+++ Modeling/Relationship.py 2003-12-08 13:34:29.000000000 +0200
@@ -252,6 +252,7 @@
set=self.xmlSetAttribute(attributeName)
if attrType=='string': value=unicodeToStr(value, encoding)
if attrType=='number': value=int(value)
+ elif attrType=='bool': value=int(value)
set(value)
return
@@ -278,7 +279,9 @@
#
exportAttrDict=self.xmlAttributesDict()
for attr in exportAttrDict.keys():
+ attrType=self.xmlAttributeType(attr)
value=self.xmlGetAttribute(attr)()
+ if attrType=='bool': value=int(value)
value=strToUnicode(str(value), encoding)
node.setAttribute(attr, value)
@@ -303,7 +306,7 @@
'displayLabel' : ('string',
self.setDisplayLabel,
self.displayLabel),
- 'isClassProperty' : ('number',
+ 'isClassProperty' : ('bool',
self.setIsClassProperty,
self.isClassProperty),
'multiplicityLowerBound': ('number',
|