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
c5e35d7a
Commit
c5e35d7a
authored
Aug 12, 2004
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- added test to verify the interface
- synced interface and help file with implementation
parent
41e836ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
40 deletions
+82
-40
lib/python/Products/ZCatalog/IZCatalog.py
lib/python/Products/ZCatalog/IZCatalog.py
+10
-10
lib/python/Products/ZCatalog/help/ZCatalog.py
lib/python/Products/ZCatalog/help/ZCatalog.py
+18
-2
lib/python/Products/ZCatalog/tests/testCatalog.py
lib/python/Products/ZCatalog/tests/testCatalog.py
+54
-28
No files found.
lib/python/Products/ZCatalog/IZCatalog.py
View file @
c5e35d7a
...
@@ -228,25 +228,25 @@ class IZCatalog(Interface):
...
@@ -228,25 +228,25 @@ class IZCatalog(Interface):
queries (even across catalogs) and merge and sort the combined results.
queries (even across catalogs) and merge and sort the combined results.
"""
"""
def
refreshCatalog
(
clear
=
0
,
REQUEST
=
None
,
pghandler
=
None
):
def
refreshCatalog
(
clear
=
0
,
pghandler
=
None
):
"""Reindex every object we can find, removing the unreachable
"""Reindex every object we can find, removing the unreachable
ones from the index.
ones from the index.
clear -- values: 1|0 clear the catalog before reindexing
clear -- values: 1|0 clear the catalog before reindexing
REQUEST -- optional REQUEST object
pghandler -- optional Progresshandler as defined in ProgressHandler.py
(see also README.txt)
pghandler -- optional Progresshandler as defined in ProgressHandler.py
(see also README.txt)
"""
"""
def
reindexIndex
(
name
,
pghandler
=
None
):
def
reindexIndex
(
name
,
REQUEST
,
pghandler
=
None
):
"""Reindex a single index.
"""Reindex a single index.
name -- id of index
name -- id of index
pghandler -- optional Progresshandler as defined in ProgressHandler.py
REQUEST -- REQUEST object
(see also README.txt)
pghandler -- optional Progresshandler as defined in ProgressHandler.py
(see also README.txt)
"""
"""
__doc__
=
IZCatalog
.
__doc__
+
__doc__
__doc__
=
IZCatalog
.
__doc__
+
__doc__
lib/python/Products/ZCatalog/help/ZCatalog.py
View file @
c5e35d7a
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
.
#
#
##############################################################################
##############################################################################
...
@@ -229,7 +229,23 @@ class ZCatalog:
...
@@ -229,7 +229,23 @@ class ZCatalog:
queries (even across catalogs) and merge and sort the combined results.
queries (even across catalogs) and merge and sort the combined results.
"""
"""
def
refreshCatalog
():
def
refreshCatalog
(
clear
=
0
,
pghandler
=
None
):
"""Reindex every object we can find, removing the unreachable
"""Reindex every object we can find, removing the unreachable
ones from the index.
ones from the index.
clear -- values: 1|0 clear the catalog before reindexing
pghandler -- optional Progresshandler as defined in ProgressHandler.py
(see also README.txt)
"""
def
reindexIndex
(
name
,
REQUEST
,
pghandler
=
None
):
"""Reindex a single index.
name -- id of index
REQUEST -- REQUEST object
pghandler -- optional Progresshandler as defined in ProgressHandler.py
(see also README.txt)
"""
"""
lib/python/Products/ZCatalog/tests/testCatalog.py
View file @
c5e35d7a
#!/usr/bin/env python, unittest
##############################################################################
#
# 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.
#
##############################################################################
""" Unittests for Catalog.
$Id:$
"""
# Unittests for Catalog
import
os
import
random
import
unittest
import
unittest
import
Testing
import
Zope
Zope
.
startup
()
from
Interface.Verify
import
verifyClass
from
itertools
import
chain
from
itertools
import
chain
import
random
import
ZODB
,
OFS
.
Application
from
ZODB.DemoStorage
import
DemoStorage
from
ZODB.DB
import
DB
from
Products
import
ZCatalog
from
Products.ZCatalog
import
ZCatalog
,
Vocabulary
from
Products.ZCatalog.Catalog
import
Catalog
,
CatalogError
import
ExtensionClass
import
ExtensionClass
import
OFS.Application
from
Products.ZCatalog
import
Vocabulary
from
Products.ZCatalog.Catalog
import
Catalog
from
Products.ZCatalog.Catalog
import
CatalogError
from
ZODB.DB
import
DB
from
ZODB.DemoStorage
import
DemoStorage
from
Products.PluginIndexes.FieldIndex.FieldIndex
import
FieldIndex
from
Products.PluginIndexes.FieldIndex.FieldIndex
import
FieldIndex
from
Products.PluginIndexes.TextIndex.TextIndex
import
TextIndex
from
Products.PluginIndexes.TextIndex.Lexicon
import
Lexicon
from
Products.PluginIndexes.KeywordIndex.KeywordIndex
import
KeywordIndex
from
Products.PluginIndexes.KeywordIndex.KeywordIndex
import
KeywordIndex
from
Products.PluginIndexes.TextIndex.Lexicon
import
Lexicon
from
Products.PluginIndexes.TextIndex.TextIndex
import
TextIndex
def
createDatabase
():
def
createDatabase
():
...
@@ -129,7 +146,8 @@ class zdummy(ExtensionClass.Base):
...
@@ -129,7 +146,8 @@ class zdummy(ExtensionClass.Base):
class
TestZCatalog
(
unittest
.
TestCase
):
class
TestZCatalog
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
_catalog
=
ZCatalog
.
ZCatalog
(
'Catalog'
)
from
Products.ZCatalog.ZCatalog
import
ZCatalog
self
.
_catalog
=
ZCatalog
(
'Catalog'
)
self
.
_catalog
.
resolve_path
=
self
.
_resolve_num
self
.
_catalog
.
resolve_path
=
self
.
_resolve_num
self
.
_catalog
.
addIndex
(
'title'
,
'KeywordIndex'
)
self
.
_catalog
.
addIndex
(
'title'
,
'KeywordIndex'
)
self
.
_catalog
.
addColumn
(
'title'
)
self
.
_catalog
.
addColumn
(
'title'
)
...
@@ -184,6 +202,13 @@ class TestZCatalog(unittest.TestCase):
...
@@ -184,6 +202,13 @@ class TestZCatalog(unittest.TestCase):
data
=
self
.
_catalog
.
getMetadataForUID
(
'0'
)
data
=
self
.
_catalog
.
getMetadataForUID
(
'0'
)
self
.
assertEqual
(
data
[
'title'
],
'0'
)
self
.
assertEqual
(
data
[
'title'
],
'0'
)
def
test_interface
(
self
):
from
Products.ZCatalog.IZCatalog
import
IZCatalog
from
Products.ZCatalog.ZCatalog
import
ZCatalog
verifyClass
(
IZCatalog
,
ZCatalog
)
class
dummy
(
ExtensionClass
.
Base
):
class
dummy
(
ExtensionClass
.
Base
):
att1
=
'att1'
att1
=
'att1'
att2
=
'att2'
att2
=
'att2'
...
@@ -425,7 +450,7 @@ class TestCatalogObject(unittest.TestCase):
...
@@ -425,7 +450,7 @@ class TestCatalogObject(unittest.TestCase):
self
.
_catalog
.
catalogObject
(
ob
,
`9999`
)
self
.
_catalog
.
catalogObject
(
ob
,
`9999`
)
brain
=
self
.
_catalog
(
num
=
9999
)[
0
]
brain
=
self
.
_catalog
(
num
=
9999
)[
0
]
self
.
assertEqual
(
brain
.
att1
,
'foobar'
)
self
.
assertEqual
(
brain
.
att1
,
'foobar'
)
class
objRS
(
ExtensionClass
.
Base
):
class
objRS
(
ExtensionClass
.
Base
):
...
@@ -461,7 +486,7 @@ class TestRS(unittest.TestCase):
...
@@ -461,7 +486,7 @@ class TestRS(unittest.TestCase):
class
TestMerge
(
unittest
.
TestCase
):
class
TestMerge
(
unittest
.
TestCase
):
# Test merging results from multiple catalogs
# Test merging results from multiple catalogs
def
setUp
(
self
):
def
setUp
(
self
):
vocabulary
=
Vocabulary
.
Vocabulary
(
vocabulary
=
Vocabulary
.
Vocabulary
(
'Vocabulary'
,
'Vocabulary'
,
globbing
=
1
)
'Vocabulary'
,
'Vocabulary'
,
globbing
=
1
)
...
@@ -478,7 +503,7 @@ class TestMerge(unittest.TestCase):
...
@@ -478,7 +503,7 @@ class TestMerge(unittest.TestCase):
obj
.
big
=
i
>
5
obj
.
big
=
i
>
5
cat
.
catalogObject
(
obj
,
str
(
i
))
cat
.
catalogObject
(
obj
,
str
(
i
))
self
.
catalogs
.
append
(
cat
)
self
.
catalogs
.
append
(
cat
)
def
testNoFilterOrSort
(
self
):
def
testNoFilterOrSort
(
self
):
from
Products.ZCatalog.Catalog
import
mergeResults
from
Products.ZCatalog.Catalog
import
mergeResults
results
=
[
cat
.
searchResults
(
_merge
=
0
)
for
cat
in
self
.
catalogs
]
results
=
[
cat
.
searchResults
(
_merge
=
0
)
for
cat
in
self
.
catalogs
]
...
@@ -486,20 +511,20 @@ class TestMerge(unittest.TestCase):
...
@@ -486,20 +511,20 @@ class TestMerge(unittest.TestCase):
results
,
has_sort_keys
=
False
,
reverse
=
False
)]
results
,
has_sort_keys
=
False
,
reverse
=
False
)]
expected
=
[
r
.
getRID
()
for
r
in
chain
(
*
results
)]
expected
=
[
r
.
getRID
()
for
r
in
chain
(
*
results
)]
self
.
assertEqual
(
sort
(
merged_rids
),
sort
(
expected
))
self
.
assertEqual
(
sort
(
merged_rids
),
sort
(
expected
))
def
testSortedOnly
(
self
):
def
testSortedOnly
(
self
):
from
Products.ZCatalog.Catalog
import
mergeResults
from
Products.ZCatalog.Catalog
import
mergeResults
results
=
[
cat
.
searchResults
(
sort_on
=
'num'
,
_merge
=
0
)
results
=
[
cat
.
searchResults
(
sort_on
=
'num'
,
_merge
=
0
)
for
cat
in
self
.
catalogs
]
for
cat
in
self
.
catalogs
]
merged_rids
=
[
r
.
getRID
()
for
r
in
mergeResults
(
merged_rids
=
[
r
.
getRID
()
for
r
in
mergeResults
(
results
,
has_sort_keys
=
True
,
reverse
=
False
)]
results
,
has_sort_keys
=
True
,
reverse
=
False
)]
expected
=
sort
(
chain
(
*
results
))
expected
=
sort
(
chain
(
*
results
))
expected
=
[
rid
for
sortkey
,
rid
,
getitem
in
expected
]
expected
=
[
rid
for
sortkey
,
rid
,
getitem
in
expected
]
self
.
assertEqual
(
merged_rids
,
expected
)
self
.
assertEqual
(
merged_rids
,
expected
)
def
testSortReverse
(
self
):
def
testSortReverse
(
self
):
from
Products.ZCatalog.Catalog
import
mergeResults
from
Products.ZCatalog.Catalog
import
mergeResults
results
=
[
cat
.
searchResults
(
sort_on
=
'num'
,
_merge
=
0
)
results
=
[
cat
.
searchResults
(
sort_on
=
'num'
,
_merge
=
0
)
for
cat
in
self
.
catalogs
]
for
cat
in
self
.
catalogs
]
merged_rids
=
[
r
.
getRID
()
for
r
in
mergeResults
(
merged_rids
=
[
r
.
getRID
()
for
r
in
mergeResults
(
results
,
has_sort_keys
=
True
,
reverse
=
True
)]
results
,
has_sort_keys
=
True
,
reverse
=
True
)]
...
@@ -507,38 +532,39 @@ class TestMerge(unittest.TestCase):
...
@@ -507,38 +532,39 @@ class TestMerge(unittest.TestCase):
expected
.
reverse
()
expected
.
reverse
()
expected
=
[
rid
for
sortkey
,
rid
,
getitem
in
expected
]
expected
=
[
rid
for
sortkey
,
rid
,
getitem
in
expected
]
self
.
assertEqual
(
merged_rids
,
expected
)
self
.
assertEqual
(
merged_rids
,
expected
)
def
testLimitSort
(
self
):
def
testLimitSort
(
self
):
from
Products.ZCatalog.Catalog
import
mergeResults
from
Products.ZCatalog.Catalog
import
mergeResults
results
=
[
cat
.
searchResults
(
sort_on
=
'num'
,
sort_limit
=
2
,
_merge
=
0
)
results
=
[
cat
.
searchResults
(
sort_on
=
'num'
,
sort_limit
=
2
,
_merge
=
0
)
for
cat
in
self
.
catalogs
]
for
cat
in
self
.
catalogs
]
merged_rids
=
[
r
.
getRID
()
for
r
in
mergeResults
(
merged_rids
=
[
r
.
getRID
()
for
r
in
mergeResults
(
results
,
has_sort_keys
=
True
,
reverse
=
False
)]
results
,
has_sort_keys
=
True
,
reverse
=
False
)]
expected
=
sort
(
chain
(
*
results
))
expected
=
sort
(
chain
(
*
results
))
expected
=
[
rid
for
sortkey
,
rid
,
getitem
in
expected
]
expected
=
[
rid
for
sortkey
,
rid
,
getitem
in
expected
]
self
.
assertEqual
(
merged_rids
,
expected
)
self
.
assertEqual
(
merged_rids
,
expected
)
def
testScored
(
self
):
def
testScored
(
self
):
from
Products.ZCatalog.Catalog
import
mergeResults
from
Products.ZCatalog.Catalog
import
mergeResults
results
=
[
cat
.
searchResults
(
title
=
'4 or 5 or 6'
,
_merge
=
0
)
results
=
[
cat
.
searchResults
(
title
=
'4 or 5 or 6'
,
_merge
=
0
)
for
cat
in
self
.
catalogs
]
for
cat
in
self
.
catalogs
]
merged_rids
=
[
r
.
getRID
()
for
r
in
mergeResults
(
merged_rids
=
[
r
.
getRID
()
for
r
in
mergeResults
(
results
,
has_sort_keys
=
True
,
reverse
=
False
)]
results
,
has_sort_keys
=
True
,
reverse
=
False
)]
expected
=
sort
(
chain
(
*
results
))
expected
=
sort
(
chain
(
*
results
))
expected
=
[
rid
for
sortkey
,
(
nscore
,
score
,
rid
),
getitem
in
expected
]
expected
=
[
rid
for
sortkey
,
(
nscore
,
score
,
rid
),
getitem
in
expected
]
self
.
assertEqual
(
merged_rids
,
expected
)
self
.
assertEqual
(
merged_rids
,
expected
)
def
testSmallIndexSort
(
self
):
def
testSmallIndexSort
(
self
):
# Test that small index sort optimization is not used for merging
# Test that small index sort optimization is not used for merging
from
Products.ZCatalog.Catalog
import
mergeResults
from
Products.ZCatalog.Catalog
import
mergeResults
results
=
[
cat
.
searchResults
(
sort_on
=
'big'
,
_merge
=
0
)
results
=
[
cat
.
searchResults
(
sort_on
=
'big'
,
_merge
=
0
)
for
cat
in
self
.
catalogs
]
for
cat
in
self
.
catalogs
]
merged_rids
=
[
r
.
getRID
()
for
r
in
mergeResults
(
merged_rids
=
[
r
.
getRID
()
for
r
in
mergeResults
(
results
,
has_sort_keys
=
True
,
reverse
=
False
)]
results
,
has_sort_keys
=
True
,
reverse
=
False
)]
expected
=
sort
(
chain
(
*
results
))
expected
=
sort
(
chain
(
*
results
))
expected
=
[
rid
for
sortkey
,
rid
,
getitem
in
expected
]
expected
=
[
rid
for
sortkey
,
rid
,
getitem
in
expected
]
self
.
assertEqual
(
merged_rids
,
expected
)
self
.
assertEqual
(
merged_rids
,
expected
)
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestAddDelColumn
)
)
suite
.
addTest
(
unittest
.
makeSuite
(
TestAddDelColumn
)
)
...
...
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