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
297bdd33
Commit
297bdd33
authored
Nov 28, 2002
by
seb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- fix for #703 merged from 2.6 branch
parent
9154b5a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
9 deletions
+50
-9
lib/python/Products/PluginIndexes/PathIndex/PathIndex.py
lib/python/Products/PluginIndexes/PathIndex/PathIndex.py
+18
-9
lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py
...n/Products/PluginIndexes/PathIndex/tests/testPathIndex.py
+32
-0
No files found.
lib/python/Products/PluginIndexes/PathIndex/PathIndex.py
View file @
297bdd33
...
...
@@ -11,7 +11,7 @@
#
##############################################################################
__version__
=
'$Id: PathIndex.py,v 1.2
8 2002/10/03 13:42:22 andreasjung
Exp $'
__version__
=
'$Id: PathIndex.py,v 1.2
9 2002/11/28 13:03:11 beacon
Exp $'
from
Products.PluginIndexes
import
PluggableIndex
from
Products.PluginIndexes.common.util
import
parseIndexRequest
...
...
@@ -23,6 +23,7 @@ from BTrees.IOBTree import IOBTree
from
BTrees.OOBTree
import
OOBTree
from
BTrees.IIBTree
import
IISet
,
intersection
,
union
from
OFS.SimpleItem
import
SimpleItem
from
zLOG
import
LOG
,
ERROR
from
types
import
StringType
,
ListType
,
TupleType
import
re
,
warnings
...
...
@@ -141,21 +142,30 @@ class PathIndex(Persistent, Implicit, SimpleItem):
""" hook for (Z)Catalog """
if
not
self
.
_unindex
.
has_key
(
documentId
):
LOG
(
self
.
__class__
.
__name__
,
ERROR
,
'Attempt to unindex nonexistent document'
' with id %s'
%
documentId
)
return
path
=
self
.
_unindex
[
documentId
]
comps
=
path
.
split
(
'/'
)
for
level
in
range
(
len
(
comps
[
1
:])):
comp
=
comps
[
level
+
1
]
self
.
_index
[
comp
][
level
].
remove
(
documentId
)
try
:
self
.
_index
[
comp
][
level
].
remove
(
documentId
)
if
len
(
self
.
_index
[
comp
][
level
])
==
0
:
del
self
.
_index
[
comp
][
level
]
if
len
(
self
.
_index
[
comp
][
level
])
==
0
:
del
self
.
_index
[
comp
][
level
]
if
len
(
self
.
_index
[
comp
])
==
0
:
del
self
.
_index
[
comp
]
except
KeyError
:
LOG
(
self
.
__class__
.
__name__
,
ERROR
,
'Attempt to unindex document'
' with id %s failed'
%
documentId
)
if
len
(
self
.
_index
[
comp
])
==
0
:
del
self
.
_index
[
comp
]
del
self
.
_unindex
[
documentId
]
...
...
@@ -209,14 +219,13 @@ class PathIndex(Persistent, Implicit, SimpleItem):
results
=
[]
for
i
in
range
(
len
(
comps
)):
comp
=
comps
[
i
]
if
not
self
.
_index
.
has_key
(
comp
):
return
IISet
()
if
not
self
.
_index
[
comp
].
has_key
(
level
+
i
):
return
IISet
()
results
.
append
(
self
.
_index
[
comp
][
level
+
i
]
)
res
=
results
[
0
]
for
i
in
range
(
1
,
len
(
results
)):
...
...
lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py
View file @
297bdd33
...
...
@@ -78,6 +78,38 @@ class TestCase( unittest.TestCase ):
assert
len
(
self
.
_index
.
_index
)
==
0
assert
len
(
self
.
_index
.
_unindex
)
==
0
def
testUnIndexError
(
self
):
self
.
_populateIndex
()
# this should not raise an error
self
.
_index
.
unindex_object
(
-
1
)
# nor should this
self
.
_index
.
_unindex
[
1
]
=
"/broken/thing"
self
.
_index
.
unindex_object
(
1
)
def
testRoot
(
self
):
self
.
_populateIndex
()
tests
=
[
(
"/"
,
0
,
range
(
1
,
19
)),
]
for
comp
,
level
,
results
in
tests
:
for
path
in
[
comp
,
"/"
+
comp
,
"/"
+
comp
+
"/"
]:
res
=
self
.
_index
.
_apply_index
(
{
"path"
:{
'query'
:
path
,
"level"
:
level
}})
lst
=
list
(
res
[
0
].
keys
())
self
.
assertEqual
(
lst
,
results
)
for
comp
,
level
,
results
in
tests
:
for
path
in
[
comp
,
"/"
+
comp
,
"/"
+
comp
+
"/"
]:
res
=
self
.
_index
.
_apply_index
(
{
"path"
:{
'query'
:(
(
path
,
level
),)}})
lst
=
list
(
res
[
0
].
keys
())
self
.
assertEqual
(
lst
,
results
)
def
testRoot
(
self
):
...
...
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