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
93b5a98c
Commit
93b5a98c
authored
Apr 14, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Forward-port from 2.12 branch.
parent
a602b4de
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
9 deletions
+55
-9
doc/CHANGES.rst
doc/CHANGES.rst
+3
-0
src/Products/PluginIndexes/PathIndex/PathIndex.py
src/Products/PluginIndexes/PathIndex/PathIndex.py
+4
-9
src/Products/PluginIndexes/PathIndex/tests/testPathIndex.py
src/Products/PluginIndexes/PathIndex/tests/testPathIndex.py
+36
-0
src/Products/PluginIndexes/interfaces.py
src/Products/PluginIndexes/interfaces.py
+12
-0
No files found.
doc/CHANGES.rst
View file @
93b5a98c
...
@@ -153,6 +153,9 @@ Features Added
...
@@ -153,6 +153,9 @@ Features Added
Bugs Fixed
Bugs Fixed
++++++++++
++++++++++
- Document ``Products.PluginIndexes.PathIndex.PathIndex.insertEntry`` as
an API for use by subclasses.
- LP #143655: don'
t
prevent
sorting
using
a
path
index
.
- LP #143655: don'
t
prevent
sorting
using
a
path
index
.
-
LP
#
142478
:
normalize
terms
passed
to
``
PLexicon
.
queryLexicon
``
using
-
LP
#
142478
:
normalize
terms
passed
to
``
PLexicon
.
queryLexicon
``
using
...
...
src/Products/PluginIndexes/PathIndex/PathIndex.py
View file @
93b5a98c
...
@@ -226,18 +226,11 @@ class PathIndex(Persistent, SimpleItem):
...
@@ -226,18 +226,11 @@ class PathIndex(Persistent, SimpleItem):
"""
"""
return
self
.
_unindex
return
self
.
_unindex
#
Helper methods
#
IPathIndex implementation.
def
insertEntry
(
self
,
comp
,
id
,
level
):
def
insertEntry
(
self
,
comp
,
id
,
level
):
""" Insert an entry.
""" See IPathIndex
'comp' is an individual path component
'id' is the docid
.level'is the level of the component inside the path
"""
"""
if
not
self
.
_index
.
has_key
(
comp
):
if
not
self
.
_index
.
has_key
(
comp
):
self
.
_index
[
comp
]
=
IOBTree
()
self
.
_index
[
comp
]
=
IOBTree
()
...
@@ -248,6 +241,8 @@ class PathIndex(Persistent, SimpleItem):
...
@@ -248,6 +241,8 @@ class PathIndex(Persistent, SimpleItem):
if
level
>
self
.
_depth
:
if
level
>
self
.
_depth
:
self
.
_depth
=
level
self
.
_depth
=
level
# Helper methods
def
_search
(
self
,
path
,
default_level
=
0
):
def
_search
(
self
,
path
,
default_level
=
0
):
""" Perform the actual search.
""" Perform the actual search.
...
...
src/Products/PluginIndexes/PathIndex/tests/testPathIndex.py
View file @
93b5a98c
...
@@ -456,6 +456,42 @@ class PathIndexTests(unittest.TestCase):
...
@@ -456,6 +456,42 @@ class PathIndexTests(unittest.TestCase):
self
.
assertEqual
(
dict
(
index
.
documentToKeyMap
()),
self
.
assertEqual
(
dict
(
index
.
documentToKeyMap
()),
dict
([(
k
,
v
.
path
)
for
k
,
v
in
DUMMIES
.
items
()]))
dict
([(
k
,
v
.
path
)
for
k
,
v
in
DUMMIES
.
items
()]))
def
test_insertEntry_empty_depth_0
(
self
):
index
=
self
.
_makeOne
()
index
.
insertEntry
(
'xx'
,
123
,
level
=
0
)
self
.
assertEqual
(
index
.
_depth
,
0
)
self
.
assertEqual
(
len
(
index
.
_index
),
1
)
self
.
assertEqual
(
list
(
index
.
_index
[
'xx'
][
0
]),
[
123
])
# insertEntry oesn't update the length or the reverse index.
self
.
assertEqual
(
len
(
index
),
0
)
self
.
assertEqual
(
len
(
index
.
_unindex
),
0
)
self
.
assertEqual
(
index
.
_length
(),
0
)
def
test_insertEntry_empty_depth_1
(
self
):
index
=
self
.
_makeOne
()
index
.
insertEntry
(
'xx'
,
123
,
level
=
0
)
index
.
insertEntry
(
'yy'
,
123
,
level
=
1
)
self
.
assertEqual
(
index
.
_depth
,
1
)
self
.
assertEqual
(
len
(
index
.
_index
),
2
)
self
.
assertEqual
(
list
(
index
.
_index
[
'xx'
][
0
]),
[
123
])
self
.
assertEqual
(
list
(
index
.
_index
[
'yy'
][
1
]),
[
123
])
def
test_insertEntry_multiple
(
self
):
index
=
self
.
_makeOne
()
index
.
insertEntry
(
'xx'
,
123
,
level
=
0
)
index
.
insertEntry
(
'yy'
,
123
,
level
=
1
)
index
.
insertEntry
(
'aa'
,
456
,
level
=
0
)
index
.
insertEntry
(
'bb'
,
456
,
level
=
1
)
index
.
insertEntry
(
'cc'
,
456
,
level
=
2
)
self
.
assertEqual
(
index
.
_depth
,
2
)
self
.
assertEqual
(
len
(
index
.
_index
),
5
)
self
.
assertEqual
(
list
(
index
.
_index
[
'xx'
][
0
]),
[
123
])
self
.
assertEqual
(
list
(
index
.
_index
[
'yy'
][
1
]),
[
123
])
self
.
assertEqual
(
list
(
index
.
_index
[
'aa'
][
0
]),
[
456
])
self
.
assertEqual
(
list
(
index
.
_index
[
'bb'
][
1
]),
[
456
])
self
.
assertEqual
(
list
(
index
.
_index
[
'cc'
][
2
]),
[
456
])
def
test__search_empty_index_string_query
(
self
):
def
test__search_empty_index_string_query
(
self
):
index
=
self
.
_makeOne
()
index
=
self
.
_makeOne
()
self
.
assertEqual
(
list
(
index
.
_search
(
'/xxx'
)),
[])
self
.
assertEqual
(
list
(
index
.
_search
(
'/xxx'
)),
[])
...
...
src/Products/PluginIndexes/interfaces.py
View file @
93b5a98c
...
@@ -157,6 +157,18 @@ class IPathIndex(Interface):
...
@@ -157,6 +157,18 @@ class IPathIndex(Interface):
- the value is a mapping 'level of the path component' to
- the value is a mapping 'level of the path component' to
'all docids with this path component on this level'
'all docids with this path component on this level'
"""
"""
def
insertEntry
(
comp
,
id
,
level
):
""" Insert an entry.
This method is intended for use by subclasses: it is not
a normal API for the index.
'comp' is an individual path component
'id' is the docid
.level'is the level of the component inside the path
"""
class
IFilteredSet
(
Interface
):
class
IFilteredSet
(
Interface
):
...
...
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