[Checkins] SVN: GenericSetup/trunk/ - don't raise an error if index
is already removed (patch contributed by Maurits)
Yvo Schubbe
y.2007- at wcm-solutions.de
Mon Apr 9 12:08:16 EDT 2007
Log message for revision 74051:
- don't raise an error if index is already removed (patch contributed by Maurits)
- clear DOM in _exportBody after using it
Changed:
U GenericSetup/trunk/ZCatalog/exportimport.py
U GenericSetup/trunk/ZCatalog/tests/test_exportimport.py
U GenericSetup/trunk/utils.py
-=-
Modified: GenericSetup/trunk/ZCatalog/exportimport.py
===================================================================
--- GenericSetup/trunk/ZCatalog/exportimport.py 2007-04-09 16:07:34 UTC (rev 74050)
+++ GenericSetup/trunk/ZCatalog/exportimport.py 2007-04-09 16:08:16 UTC (rev 74051)
@@ -96,7 +96,11 @@
idx_id = str(child.getAttribute('name'))
if child.hasAttribute('remove'):
- zcatalog.delIndex(idx_id)
+ # Remove index if it is there; then continue to the next
+ # index. Removing a non existing index should not cause an
+ # error, so you can apply the profile twice without problems.
+ if idx_id in zcatalog.indexes():
+ zcatalog.delIndex(idx_id)
continue
if idx_id not in zcatalog.indexes():
Modified: GenericSetup/trunk/ZCatalog/tests/test_exportimport.py
===================================================================
--- GenericSetup/trunk/ZCatalog/tests/test_exportimport.py 2007-04-09 16:07:34 UTC (rev 74050)
+++ GenericSetup/trunk/ZCatalog/tests/test_exportimport.py 2007-04-09 16:08:16 UTC (rev 74051)
@@ -77,6 +77,7 @@
<extra name="index_type" value="Okapi BM25 Rank"/>
<extra name="lexicon_id" value="foo_plexicon"/>
</index>
+ <index name="non_existing" remove="True"/>
</object>
"""
Modified: GenericSetup/trunk/utils.py
===================================================================
--- GenericSetup/trunk/utils.py 2007-04-09 16:07:34 UTC (rev 74050)
+++ GenericSetup/trunk/utils.py 2007-04-09 16:08:16 UTC (rev 74051)
@@ -484,7 +484,9 @@
"""Export the object as a file body.
"""
self._doc.appendChild(self._exportNode())
- return self._doc.toprettyxml(' ')
+ xml = self._doc.toprettyxml(' ')
+ self._doc.unlink()
+ return xml
def _importBody(self, body):
"""Import the object from the file body.
More information about the Checkins
mailing list