[Commits] (grant) Fix Bug 2243 (Duplicate item definitions not
detected) r=lisa
commits at osafoundation.org
commits at osafoundation.org
Fri Feb 25 10:15:59 PST 2005
Commit by: grant
Modified files:
chandler/application/Parcel.py 1.50 1.51
chandler/application/tests/TestNamespaceErrors.py None 1.1
chandler/application/tests/TestParcelErrors.py 1.1 1.2
chandler/application/tests/__init__.py 1.5 1.6
chandler/application/tests/badnamespaceparcels/duplicate/one/parcel.xml None 1.1
chandler/application/tests/badnamespaceparcels/duplicate/two/parcel.xml None 1.1
chandler/application/tests/testparcels/errors/dupitems/parcel.xml None 1.1
chandler/parcels/osaf/contentmodel/calendar/parcel.xml 1.58 1.59
chandler/parcels/osaf/framework/blocks/detail/parcel.xml 1.68 1.69
Log message:
Fix Bug 2243 (Duplicate item definitions not detected) r=lisa
- Update Parcel.py to check for duplicate items, and duplicate parcel
namespaces.
- Update parcel loader unit tests to check for duplicate namespaces,
and duplicate items within a given namespace.
- Remove duplicate items from two of Chandler's parcel.xml files.
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/application/Parcel.py.diff?r1=text&tr1=1.50&r2=text&tr2=1.51
http://cvs.osafoundation.org/index.cgi/chandler/application/tests/TestNamespaceErrors.py?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/chandler/application/tests/TestParcelErrors.py.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/chandler/application/tests/__init__.py.diff?r1=text&tr1=1.5&r2=text&tr2=1.6
http://cvs.osafoundation.org/index.cgi/chandler/application/tests/badnamespaceparcels/duplicate/one/parcel.xml?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/chandler/application/tests/badnamespaceparcels/duplicate/two/parcel.xml?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/chandler/application/tests/testparcels/errors/dupitems/parcel.xml?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/contentmodel/calendar/parcel.xml.diff?r1=text&tr1=1.58&r2=text&tr2=1.59
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/detail/parcel.xml.diff?r1=text&tr1=1.68&r2=text&tr2=1.69
Index: chandler/parcels/osaf/contentmodel/calendar/parcel.xml
diff -u chandler/parcels/osaf/contentmodel/calendar/parcel.xml:1.58 chandler/parcels/osaf/contentmodel/calendar/parcel.xml:1.59
--- chandler/parcels/osaf/contentmodel/calendar/parcel.xml:1.58 Tue Feb 15 22:39:11 2005
+++ chandler/parcels/osaf/contentmodel/calendar/parcel.xml Fri Feb 25 10:15:56 2005
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.58 $ -->
-<!-- $Date: 2005/02/16 06:39:11 $ -->
+<!-- $Revision: 1.59 $ -->
+<!-- $Date: 2005/02/25 18:15:56 $ -->
<!-- Copyright (c) 2003-2004 Open Source Applications Foundation -->
<!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
@@ -189,10 +189,6 @@
<attribute value="location"/>
</Endpoint>
<endpoints itemref="cal:CalendarEventMixin/SharingCloud/location"/>
- <Endpoint itsName="allDay">
- <attribute value="allDay"/>
- </Endpoint>
- <endpoints itemref="cal:CalendarEventMixin/SharingCloud/allDay"/>
<Endpoint itsName="organizer">
<attribute value="organizer"/>
<includePolicy value="byCloud"/>
Index: chandler/application/Parcel.py
diff -u chandler/application/Parcel.py:1.50 chandler/application/Parcel.py:1.51
--- chandler/application/Parcel.py:1.50 Thu Feb 24 14:00:46 2005
+++ chandler/application/Parcel.py Fri Feb 25 10:15:54 2005
@@ -243,7 +243,7 @@
# Do a Parcel-kind query for existing parcels; populate a dictionary
# of "parcel descriptors" (pDesc) which cache parcel information.
# After reading info from existing parcel items, this info may be
- # overriden from parcel.xml files further down.
+ # overridden from parcel.xml files further down.
parcelKind = self.repo.findPath("//Schema/Core/Parcel")
for parcel in KindQuery().run([parcelKind]):
pDesc = {
@@ -353,6 +353,16 @@
namespace = "%s/%s" % \
( self._repo2ns[parentPath], myName )
+ # Check for duplicate namespaces
+ if self._ns2parcel.has_key(namespace):
+ pDesc = self._ns2parcel[namespace]
+ explanation = \
+ "Duplicate Namespace '%s: defined at %s and %s" % \
+ (namespace, pDesc["path"], parcelFile)
+
+ self.saveExplanation(explanation)
+ raise ParcelException(explanation)
+
# Set up the parcel descriptor
pDesc = {
"time" : DateTime.now(),
@@ -953,7 +963,15 @@
currentItem = parent.getItemChild(nameString)
if currentItem is not None:
- self.reloadingCurrentItem = True
+ try:
+ index = self.itemsCreated.index(currentItem)
+ explanation = \
+ "Child '%s' of item '%s' is already in this parcel" % \
+ (nameString, self.itemsCreated[index].itsPath)
+ self.saveExplanation(explanation)
+ raise ParcelException(explanation)
+ except ValueError:
+ self.reloadingCurrentItem = True
else:
self.reloadingCurrentItem = False
@@ -1320,7 +1338,7 @@
#@@@Temporary testing tool written by Morgen -- DJA
if timing: tools.timing.begin("Creating items")
-
+
try:
if className:
# Use the given class to instantiate the item
Index: chandler/parcels/osaf/framework/blocks/detail/parcel.xml
diff -u chandler/parcels/osaf/framework/blocks/detail/parcel.xml:1.68 chandler/parcels/osaf/framework/blocks/detail/parcel.xml:1.69
--- chandler/parcels/osaf/framework/blocks/detail/parcel.xml:1.68 Thu Feb 17 14:23:09 2005
+++ chandler/parcels/osaf/framework/blocks/detail/parcel.xml Fri Feb 25 10:15:56 2005
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.68 $ -->
-<!-- $Date: 2005/02/17 22:23:09 $ -->
+<!-- $Revision: 1.69 $ -->
+<!-- $Date: 2005/02/25 18:15:56 $ -->
<!-- Copyright (c) 2003-2005 Open Source Applications Foundation -->
<!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
@@ -239,26 +239,6 @@
<stretchFactor>0.0</stretchFactor>
</ContentItemDetail>
- <StaticText itsName="FromString">
- <blockName value="FromString"/>
- <title>from</title>
- <characterStyle itemref="doc:LabelStyle"/>
- <textAlignmentEnum>Right</textAlignmentEnum>
- <stretchFactor>0.0</stretchFactor>
- <minimumSize>70, 24</minimumSize>
- <border>0.0, 0.0, 0.0, 5.0</border>
- </StaticText>
-
- <EditText itsName="FromEditField"
- itemClass="osaf.framework.blocks.detail.Detail.FromEditField">
- <blockName value="FromEditField"/>
- <characterStyle itemref="doc:TextStyle"/>
- <lineStyleEnum>SingleLine</lineStyleEnum>
- <readOnly>True</readOnly>
- <textAlignmentEnum>Left</textAlignmentEnum>
- <minimumSize>100, 24</minimumSize>
- </EditText>
-
<Button itsName="AcceptShareButton"
itemClass="osaf.framework.blocks.detail.Detail.AcceptShareButton">
<blockName value="AcceptShareButton"/>
Index: chandler/application/tests/__init__.py
diff -u chandler/application/tests/__init__.py:1.5 chandler/application/tests/__init__.py:1.6
--- chandler/application/tests/__init__.py:1.5 Thu Feb 24 14:00:46 2005
+++ chandler/application/tests/__init__.py Fri Feb 25 10:15:54 2005
@@ -6,10 +6,11 @@
"""
__all__ = [
- 'TestAllParcels', 'TestAttributes', 'TestCircular', 'TestClasses',
- 'TestClouds', 'TestCollections', 'TestCopying', 'TestDependency',
- 'TestItems', 'TestKindAndItem', 'TestLocalAttrs', 'TestParcelLoader',
- 'TestUuidOf', 'TestParcelPerf'
+ 'TestAllParcels', 'TestAnonymous', 'TestAttributes', 'TestCircular',
+ 'TestClasses', 'TestClouds', 'TestCollections', 'TestCopying',
+ 'TestDependency','TestItems', 'TestKindAndItem', 'TestLocalAttrs',
+ 'TestNamespaceErrors', 'TestParcelErrors', 'TestParcelLoader','TestUuidOf',
+ 'TestParcelPerf'
]
def suite():
Index: chandler/application/tests/TestParcelErrors.py
diff -u chandler/application/tests/TestParcelErrors.py:1.1 chandler/application/tests/TestParcelErrors.py:1.2
--- chandler/application/tests/TestParcelErrors.py:1.1 Tue Feb 22 20:21:20 2005
+++ chandler/application/tests/TestParcelErrors.py Fri Feb 25 10:15:54 2005
@@ -1,8 +1,8 @@
"""
Error handling tests for the Parcel Loader
"""
-__revision__ = "$Revision: 1.1 $"
-__date__ = "$Date: 2005/02/23 04:21:20 $"
+__revision__ = "$Revision: 1.2 $"
+__date__ = "$Date: 2005/02/25 18:15:54 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -20,8 +20,8 @@
os.path.join(
os.path.dirname(ParcelLoaderTestCase.__file__),
'testparcels',
- 'errors')
- )
+ 'errors'
+ ))
def testItsnameParcel(self):
"""
@@ -32,6 +32,13 @@
self.assertRaises(ParcelException, self.loadParcels, ["http://testparcels.org/itsname"])
+ def testDuplicateItems(self):
+ """
+ Test to ensure we raise a ParcelException when parsing a parcel
+ that attempts to define the same Item twice.
+ """
+
+ self.assertRaises(ParcelException, self.loadParcels, ["http://testparcels.org/dupitems"])
if __name__ == "__main__":
unittest.main()
More information about the Commits
mailing list