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
bda58f12
Commit
bda58f12
authored
Aug 01, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move index restriction to _sorted_search_indexes method
parent
ed315987
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
src/Products/ZCatalog/Catalog.py
src/Products/ZCatalog/Catalog.py
+2
-6
src/Products/ZCatalog/tests/test_catalog.py
src/Products/ZCatalog/tests/test_catalog.py
+14
-1
No files found.
src/Products/ZCatalog/Catalog.py
View file @
bda58f12
...
...
@@ -470,7 +470,8 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
def
_sorted_search_indexes
(
self
,
query
):
# Simple implementation doing no ordering.
return
self
.
indexes
.
keys
()
query_keys
=
query
.
keys
()
return
[
i
for
i
in
self
.
indexes
.
keys
()
if
i
in
query_keys
]
def
search
(
self
,
query
,
sort_index
=
None
,
reverse
=
0
,
limit
=
None
,
merge
=
1
):
"""Iterate through the indexes, applying the query to each one. If
...
...
@@ -500,11 +501,6 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
cr
.
start
()
for
i
in
self
.
_sorted_search_indexes
(
query
):
if
i
not
in
query_keys
:
# Do not ask indexes to restrict the result, which aren't
# part of the query
continue
index
=
self
.
getIndex
(
i
)
_apply_index
=
getattr
(
index
,
"_apply_index"
,
None
)
if
_apply_index
is
None
:
...
...
src/Products/ZCatalog/tests/test_catalog.py
View file @
bda58f12
...
...
@@ -199,7 +199,6 @@ class TestCatalog(CatalogBase, unittest.TestCase):
att3
=
KeywordIndex
(
'att3'
)
num
=
FieldIndex
(
'num'
)
self
.
_catalog
.
addIndex
(
'att1'
,
att1
)
self
.
_catalog
.
addIndex
(
'att2'
,
att2
)
self
.
_catalog
.
addIndex
(
'att3'
,
att3
)
...
...
@@ -285,6 +284,20 @@ class TestCatalog(CatalogBase, unittest.TestCase):
# getIndexDataForRID
# make_query
# _sorted_search_indexes
def
test_sorted_search_indexes_empty
(
self
):
result
=
self
.
_catalog
.
_sorted_search_indexes
({})
self
.
assertEquals
(
len
(
result
),
0
)
def
test_sorted_search_indexes_one
(
self
):
result
=
self
.
_catalog
.
_sorted_search_indexes
({
'att1'
:
'a'
})
self
.
assertEquals
(
result
,
[
'att1'
])
def
test_sorted_search_indexes_many
(
self
):
query
=
{
'att1'
:
'a'
,
'att2'
:
'b'
,
'num'
:
1
}
result
=
self
.
_catalog
.
_sorted_search_indexes
(
query
)
self
.
assertEquals
(
set
(
result
),
set
([
'att1'
,
'att2'
,
'num'
]))
# search
# sortResults
# _get_sort_attr
...
...
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