[Modeling-cvs] ProjectModeling/Modeling Attribute.py,1.12,1.13 Entity.py,1.11,1.12 Model.py,1.4,1.5
Status: Abandoned
Brought to you by:
sbigaret
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv30996
Modified Files:
Attribute.py Entity.py Model.py ModelSet.py Relationship.py
XMLutils.py CHANGES
Log Message:
Loading a xml-model is now 5 to 6x faster: applied a patch submitted by
Yannick Gingras <ygi...@yg...>. Thanks!
This was done by replacing Sax2.Reader().fromStream() with
xml.dom.minidom.parseString(), and by removing most of the xpath.Evaluate()
Index: Attribute.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Attribute.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Attribute.py 22 Apr 2003 09:31:56 -0000 1.12
--- Attribute.py 27 May 2003 19:37:28 -0000 1.13
***************
*** 533,554 ****
"""
! _attrDict=self.xmlAttributesDict()
! _attrNode=aNode.attributes
! attributes=[attr.name for attr in aNode.attributes]
!
# Now we must make sure that the type is initialized BEFORE the default
# value is set --> we simply make sure that this will be the first one
# to be initialized
try:
! t=[a for a in attributes if a=='type'][0] #IndexError
! attributes.remove(t)
! attributes=[t]+attributes
except IndexError: pass
! for attributeName in attributes:
# Iterate on attributes declared in node
attrType=self.xmlAttributeType(attributeName)
set=self.xmlSetAttribute(attributeName)
- value=xpath.Evaluate(attrType+'(@'+attributeName+')', contextNode=aNode)
if attrType=='string': value=unicodeToStr(value, encoding)
set(value)
--- 533,550 ----
"""
! k_v=aNode.attributes.items()
# Now we must make sure that the type is initialized BEFORE the default
# value is set --> we simply make sure that this will be the first one
# to be initialized
try:
! t=[a for a in k_v if a[0]=='type'][0] #IndexError
! k_v.remove(t)
! k_v=[t]+k_v
except IndexError: pass
! for attributeName, value in k_v:
# Iterate on attributes declared in node
attrType=self.xmlAttributeType(attributeName)
set=self.xmlSetAttribute(attributeName)
if attrType=='string': value=unicodeToStr(value, encoding)
set(value)
Index: Entity.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Entity.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Entity.py 22 Apr 2003 09:31:56 -0000 1.11
--- Entity.py 27 May 2003 19:37:28 -0000 1.12
***************
*** 1259,1269 ****
if phase not in (1,2):
raise ValueError, 'Ooops, parameter phase should be 1 or 2!'
! _attrDict=self.xmlAttributesDict()
! _attrNode=aNode.attributes
! for attributeName in [attr.name for attr in aNode.attributes]:
# Iterate on attributes which are in the xml
attrType=self.xmlAttributeType(attributeName)
set=self.xmlSetAttribute(attributeName)
- value=xpath.Evaluate(attrType+'(@'+attributeName+')', contextNode=aNode)
if attrType=='string': value=unicodeToStr(value, encoding)
set(value)
--- 1259,1268 ----
if phase not in (1,2):
raise ValueError, 'Ooops, parameter phase should be 1 or 2!'
!
! k_v=aNode.attributes.items()
! for attributeName, value in k_v:
# Iterate on attributes which are in the xml
attrType=self.xmlAttributeType(attributeName)
set=self.xmlSetAttribute(attributeName)
if attrType=='string': value=unicodeToStr(value, encoding)
set(value)
Index: Model.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Model.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Model.py 22 Apr 2003 09:31:56 -0000 1.4
--- Model.py 27 May 2003 19:37:28 -0000 1.5
***************
*** 241,250 ****
if self.entities():
raise XMLImportError, "Cannot initialize a non-empty model"
! _attrDict=self.xmlAttributesDict()
! _attrNode=aNode.attributes
! for attributeName in [attr.name for attr in aNode.attributes]:
attrType=self.xmlAttributeType(attributeName)
set=self.xmlSetAttribute(attributeName)
- value=xpath.Evaluate(attrType+'(@'+attributeName+')', contextNode=aNode)
if attrType=='string': value=unicodeToStr(value, encoding)
set(value)
--- 241,249 ----
if self.entities():
raise XMLImportError, "Cannot initialize a non-empty model"
!
! k_v=aNode.attributes.items()
! for attributeName, value in k_v:
attrType=self.xmlAttributeType(attributeName)
set=self.xmlSetAttribute(attributeName)
if attrType=='string': value=unicodeToStr(value, encoding)
set(value)
Index: ModelSet.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelSet.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** ModelSet.py 7 May 2003 11:28:45 -0000 1.7
--- ModelSet.py 27 May 2003 19:37:28 -0000 1.8
***************
*** 55,58 ****
--- 55,59 ----
import ClassDescription
import types
+ from xml.dom.minidom import parseString
from logging import error, warn
***************
*** 221,232 ****
if xmlSource.has_key('string'):
encoding=autoDetectXMLEncoding(xmlSource['string'])
! reader=Sax2.Reader()
! xmldoc=reader.fromString(xmlSource['string'])
elif xmlSource.has_key('file'):
f=open(xmlSource['file'], 'rb')
encoding=autoDetectXMLEncoding(f.read())
f.close()
! reader=Sax2.Reader()
! xmldoc=reader.fromStream(xmlSource['file'])
else:
raise AttributeError, "xmlSource parameter has no key 'string' or 'file'"
--- 222,231 ----
if xmlSource.has_key('string'):
encoding=autoDetectXMLEncoding(xmlSource['string'])
! xmldoc=parseString(xmlSource['string'])
elif xmlSource.has_key('file'):
f=open(xmlSource['file'], 'rb')
encoding=autoDetectXMLEncoding(f.read())
f.close()
! xmldoc=parseString(open(xmlSource['file']).read())
else:
raise AttributeError, "xmlSource parameter has no key 'string' or 'file'"
Index: Relationship.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Relationship.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Relationship.py 22 Apr 2003 09:31:56 -0000 1.8
--- Relationship.py 27 May 2003 19:37:28 -0000 1.9
***************
*** 243,254 ****
Initializes a relationship with the supplied xml.dom.node.
"""
! _attrDict=self.xmlAttributesDict()
! _attrNode=aNode.attributes
! for attributeName in [attr.name for attr in aNode.attributes]:
# Iterate on attributes declared in node
attrType=self.xmlAttributeType(attributeName)
set=self.xmlSetAttribute(attributeName)
- value=xpath.Evaluate(attrType+'(@'+attributeName+')', contextNode=aNode)
if attrType=='string': value=unicodeToStr(value, encoding)
set(value)
--- 243,253 ----
Initializes a relationship with the supplied xml.dom.node.
"""
! k_v=aNode.attributes.items()
! for attributeName, value in k_v:
# Iterate on attributes declared in node
attrType=self.xmlAttributeType(attributeName)
set=self.xmlSetAttribute(attributeName)
if attrType=='string': value=unicodeToStr(value, encoding)
+ if attrType=='number': value=int(value)
set(value)
Index: XMLutils.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/XMLutils.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** XMLutils.py 14 Mar 2003 11:40:10 -0000 1.3
--- XMLutils.py 27 May 2003 19:37:28 -0000 1.4
***************
*** 51,62 ****
try:
- from xml.dom.ext.reader import Sax2
- from xml.dom.ext.reader.Sax import FromXmlStream
- except:
- raise 'ImportError', 'PyXML is not installed'
- try:
from xml import xpath
except:
! raise 'ImportError', 'XPath is not installed'
import codecs, encodings
--- 51,57 ----
try:
from xml import xpath
except:
! raise 'ImportError', 'PyXML is not installed: failed to import xml.xpath'
import codecs, encodings
Index: CHANGES
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v
retrieving revision 1.103
retrieving revision 1.104
diff -C2 -d -r1.103 -r1.104
*** CHANGES 26 May 2003 15:44:47 -0000 1.103
--- CHANGES 27 May 2003 19:37:28 -0000 1.104
***************
*** 3,11 ****
Module Modeling
---------------
! Current release is: 0.9-pre-7 / See also: TODO, INSTALL and doc/
* ** Distributed under the GNU General Public License **
--------------------------------------------------------
[Merged from brch-0_9pre6-1-ModelMasons_base_generation_scheme]
--- 3,20 ----
Module Modeling
---------------
! Current release is: 0.9-pre-8 / See also: TODO, INSTALL and doc/
* ** Distributed under the GNU General Public License **
--------------------------------------------------------
+ 0.9-pre-8 (2003/05/27)
+ ---------
+
+ * Loading a xml-model is now 5 to 6x faster: applied a patch submitted by
+ Yannick Gingras <ygi...@yg...>. Thanks!
+
+ * Fixed: creating/dropping a database could fail because of trying to
+ rollback a cursor in autocommit mode
+
[Merged from brch-0_9pre6-1-ModelMasons_base_generation_scheme]
***************
*** 33,37 ****
* Added the 'MDL' sub-directory containing the files that are overwritten
when mdl_generate_python_code.py (option: -B) regenerates a package
! [/merged]
* RFE #726839: Added environment variable MDL_DB_CONNECTIONS_CFG; it points
--- 42,46 ----
* Added the 'MDL' sub-directory containing the files that are overwritten
when mdl_generate_python_code.py (option: -B) regenerates a package
! [/merge]
* RFE #726839: Added environment variable MDL_DB_CONNECTIONS_CFG; it points
|