Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
6e8a132a
Commit
6e8a132a
authored
Jul 05, 2005
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Collector #1832: UnIndex swallowed ConflictErrors (bare 'except:' is evil).
parent
abbd78bf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
7 deletions
+81
-7
doc/CHANGES.txt
doc/CHANGES.txt
+2
-0
lib/python/Products/PluginIndexes/common/UnIndex.py
lib/python/Products/PluginIndexes/common/UnIndex.py
+11
-7
lib/python/Products/PluginIndexes/common/tests/__init__.py
lib/python/Products/PluginIndexes/common/tests/__init__.py
+13
-0
lib/python/Products/PluginIndexes/common/tests/test_UnIndex.py
...ython/Products/PluginIndexes/common/tests/test_UnIndex.py
+55
-0
No files found.
doc/CHANGES.txt
View file @
6e8a132a
...
...
@@ -38,6 +38,8 @@ Zope Changes
Bugs Fixed
- Collector #1832: UnIndex swallowed ConflictErrors.
- Collector #1815: ZCTextIndex accepts (again) sequences of strings to
be indexed.
...
...
lib/python/Products/PluginIndexes/common/UnIndex.py
View file @
6e8a132a
...
...
@@ -24,6 +24,7 @@ from BTrees.IOBTree import IOBTree
import
BTrees.Length
from
BTrees.OOBTree
import
OOBTree
from
OFS.SimpleItem
import
SimpleItem
from
ZODB.POSException
import
ConflictError
from
zope.interface
import
implements
from
Products.PluginIndexes
import
PluggableIndex
...
...
@@ -169,6 +170,9 @@ class UnIndex(SimpleItem):
del
self
.
_index
[
entry
]
self
.
_length
.
change
(
-
1
)
except
ConflictError
:
raise
except
AttributeError
:
# index row is an int
del
self
.
_index
[
entry
]
...
...
@@ -209,9 +213,7 @@ class UnIndex(SimpleItem):
def
index_object
(
self
,
documentId
,
obj
,
threshold
=
None
):
""" wrapper to handle indexing of multiple attributes """
# needed for backward compatibility
try
:
fields
=
self
.
indexed_attrs
except
:
fields
=
[
self
.
id
]
fields
=
self
.
getIndexSourceNames
()
res
=
0
for
attr
in
fields
:
...
...
@@ -235,6 +237,8 @@ class UnIndex(SimpleItem):
if
datum
is
_marker
:
try
:
del
self
.
_unindex
[
documentId
]
except
ConflictError
:
raise
except
:
LOG
.
error
(
'Should not happen: oldDatum was there, now its not,'
'for document with id %s'
%
documentId
)
...
...
@@ -279,6 +283,8 @@ class UnIndex(SimpleItem):
try
:
del
self
.
_unindex
[
documentId
]
except
ConflictError
:
raise
except
:
LOG
.
error
(
'Attempt to unindex nonexistent document'
' with id %s'
%
documentId
)
...
...
@@ -391,10 +397,8 @@ class UnIndex(SimpleItem):
def
getIndexSourceNames
(
self
):
""" return sequence of indexed attributes """
try
:
return
self
.
indexed_attrs
except
:
return
[
self
.
id
]
# BBB: older indexes didn't have 'indexed_attrs'
return
getattr
(
self
,
'indexed_attrs'
,
[
self
.
id
])
def
uniqueValues
(
self
,
name
=
None
,
withLengths
=
0
):
"""returns the unique values for name
...
...
lib/python/Products/PluginIndexes/common/tests/__init__.py
0 → 100644
View file @
6e8a132a
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
#############################################################################
lib/python/Products/PluginIndexes/common/tests/test_UnIndex.py
0 → 100644
View file @
6e8a132a
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
#############################################################################
""" Tests for common UnIndex features.
$Id$
"""
import
unittest
class
UnIndexTests
(
unittest
.
TestCase
):
def
_getTargetClass
(
self
):
from
Products.PluginIndexes.common.UnIndex
import
UnIndex
return
UnIndex
def
_makeOne
(
self
,
*
args
,
**
kw
):
return
self
.
_getTargetClass
()(
*
args
,
**
kw
)
def
_makeConflicted
(
self
):
from
ZODB.POSException
import
ConflictError
class
Conflicted
:
def
__str__
(
self
):
return
'Conflicted'
__repr__
=
__str__
def
__getattr__
(
self
,
id
,
default
=
object
()):
raise
ConflictError
,
'testing'
return
Conflicted
()
def
test_empty
(
self
):
unindex
=
self
.
_makeOne
(
id
=
'empty'
)
self
.
assertEqual
(
unindex
.
indexed_attrs
,
[
'empty'
])
def
test_removeForwardIndexEntry_with_ConflictError
(
self
):
from
ZODB.POSException
import
ConflictError
unindex
=
self
.
_makeOne
(
id
=
'conflicted'
)
unindex
.
_index
[
'conflicts'
]
=
self
.
_makeConflicted
()
self
.
assertRaises
(
ConflictError
,
unindex
.
removeForwardIndexEntry
,
'conflicts'
,
42
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
UnIndexTests
))
return
suite
if
__name__
==
'__main__'
:
unittest
.
main
(
defaultTest
=
'test_suite'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment