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
aa7d9cb8
Commit
aa7d9cb8
authored
Aug 01, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename the catalog report to plan to fit its new purpose
parent
16671146
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
43 deletions
+43
-43
src/Products/ZCatalog/Catalog.py
src/Products/ZCatalog/Catalog.py
+6
-6
src/Products/ZCatalog/ZCatalog.py
src/Products/ZCatalog/ZCatalog.py
+17
-18
src/Products/ZCatalog/dtml/catalogPlan.dtml
src/Products/ZCatalog/dtml/catalogPlan.dtml
+4
-4
src/Products/ZCatalog/plan.py
src/Products/ZCatalog/plan.py
+3
-2
src/Products/ZCatalog/tests/test_plan.py
src/Products/ZCatalog/tests/test_plan.py
+13
-13
No files found.
src/Products/ZCatalog/Catalog.py
View file @
aa7d9cb8
...
@@ -31,8 +31,8 @@ from BTrees.OIBTree import OIBTree
...
@@ -31,8 +31,8 @@ from BTrees.OIBTree import OIBTree
from
BTrees.IOBTree
import
IOBTree
from
BTrees.IOBTree
import
IOBTree
from
Lazy
import
LazyMap
,
LazyCat
,
LazyValues
from
Lazy
import
LazyMap
,
LazyCat
,
LazyValues
from
CatalogBrains
import
AbstractCatalogBrain
,
NoBrainer
from
CatalogBrains
import
AbstractCatalogBrain
,
NoBrainer
from
.
report
import
CatalogReport
from
.
plan
import
CatalogPlan
from
.
report
import
make_key
from
.
plan
import
make_key
LOG
=
logging
.
getLogger
(
'Zope.ZCatalog'
)
LOG
=
logging
.
getLogger
(
'Zope.ZCatalog'
)
...
@@ -507,7 +507,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -507,7 +507,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
# Canonicalize the request into a sensible query before passing it on
# Canonicalize the request into a sensible query before passing it on
query
=
self
.
make_query
(
query
)
query
=
self
.
make_query
(
query
)
cr
=
self
.
getCatalog
Report
(
query
)
cr
=
self
.
getCatalog
Plan
(
query
)
cr
.
start
()
cr
.
start
()
plan
=
cr
.
plan
()
plan
=
cr
.
plan
()
...
@@ -819,12 +819,12 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -819,12 +819,12 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
__call__
=
searchResults
__call__
=
searchResults
def
getCatalog
Report
(
self
,
query
=
None
):
def
getCatalog
Plan
(
self
,
query
=
None
):
"""
Reports about the duration of queries
.
"""
Query time reporting and planning
.
"""
"""
parent
=
aq_base
(
aq_parent
(
self
))
parent
=
aq_base
(
aq_parent
(
self
))
threshold
=
getattr
(
parent
,
'long_query_time'
,
0.1
)
threshold
=
getattr
(
parent
,
'long_query_time'
,
0.1
)
return
Catalog
Report
(
self
,
query
,
threshold
)
return
Catalog
Plan
(
self
,
query
,
threshold
)
class
CatalogSearchArgumentsMap
(
object
):
class
CatalogSearchArgumentsMap
(
object
):
...
...
src/Products/ZCatalog/ZCatalog.py
View file @
aa7d9cb8
...
@@ -103,7 +103,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -103,7 +103,7 @@ class ZCatalog(Folder, Persistent, Implicit):
{
'label'
:
'Metadata'
,
'action'
:
'manage_catalogSchema'
},
{
'label'
:
'Metadata'
,
'action'
:
'manage_catalogSchema'
},
{
'label'
:
'Find Objects'
,
'action'
:
'manage_catalogFind'
},
{
'label'
:
'Find Objects'
,
'action'
:
'manage_catalogFind'
},
{
'label'
:
'Advanced'
,
'action'
:
'manage_catalogAdvanced'
},
{
'label'
:
'Advanced'
,
'action'
:
'manage_catalogAdvanced'
},
{
'label'
:
'Query Report'
,
'action'
:
'manage_catalog
Report
'
},
{
'label'
:
'Query Report'
,
'action'
:
'manage_catalog
Plan
'
},
{
'label'
:
'Undo'
,
'action'
:
'manage_UndoForm'
},
{
'label'
:
'Undo'
,
'action'
:
'manage_UndoForm'
},
{
'label'
:
'Security'
,
'action'
:
'manage_access'
},
{
'label'
:
'Security'
,
'action'
:
'manage_access'
},
{
'label'
:
'Ownership'
,
'action'
:
'manage_owner'
},
{
'label'
:
'Ownership'
,
'action'
:
'manage_owner'
},
...
@@ -127,9 +127,8 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -127,9 +127,8 @@ class ZCatalog(Folder, Persistent, Implicit):
'manage_catalogAdvanced'
)
'manage_catalogAdvanced'
)
manage_catalogAdvanced
=
DTMLFile
(
'dtml/catalogAdvanced'
,
globals
())
manage_catalogAdvanced
=
DTMLFile
(
'dtml/catalogAdvanced'
,
globals
())
security
.
declareProtected
(
manage_zcatalog_entries
,
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogPlan'
)
'manage_catalogReport'
)
manage_catalogPlan
=
DTMLFile
(
'dtml/catalogPlan'
,
globals
())
manage_catalogReport
=
DTMLFile
(
'dtml/catalogReport'
,
globals
())
security
.
declareProtected
(
manage_zcatalog_entries
,
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_objectInformation'
)
'manage_objectInformation'
)
...
@@ -874,36 +873,36 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -874,36 +873,36 @@ class ZCatalog(Folder, Persistent, Implicit):
def
delColumn
(
self
,
name
):
def
delColumn
(
self
,
name
):
return
self
.
_catalog
.
delColumn
(
name
)
return
self
.
_catalog
.
delColumn
(
name
)
# Catalog
report
methods
# Catalog
plan
methods
security
.
declareProtected
(
manage_zcatalog_entries
,
'getCatalog
Report
'
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'getCatalog
Plan
'
)
def
getCatalog
Report
(
self
):
def
getCatalog
Plan
(
self
):
"""
Reports about the duration of queries
"""
"""
Query time reporting and planning.
"""
rval
=
self
.
_catalog
.
getCatalog
Report
().
report
()
rval
=
self
.
_catalog
.
getCatalog
Plan
().
report
()
rval
.
sort
(
key
=
operator
.
itemgetter
(
'duration'
),
reverse
=
True
)
rval
.
sort
(
key
=
operator
.
itemgetter
(
'duration'
),
reverse
=
True
)
return
rval
return
rval
security
.
declareProtected
(
manage_zcatalog_entries
,
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_resetCatalog
Report
'
)
'manage_resetCatalog
Plan
'
)
def
manage_resetCatalog
Report
(
self
,
REQUEST
=
None
):
def
manage_resetCatalog
Plan
(
self
,
REQUEST
=
None
):
"""
resets the catalog report
"""
"""
Resets the catalog plan.
"""
self
.
_catalog
.
getCatalog
Report
().
reset
()
self
.
_catalog
.
getCatalog
Plan
().
reset
()
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
REQUEST
.
response
.
redirect
(
REQUEST
.
URL1
+
REQUEST
.
response
.
redirect
(
REQUEST
.
URL1
+
'/manage_catalog
Report?manage_tabs_message=Report
%20cleared'
)
'/manage_catalog
Plan?manage_tabs_message=Plan
%20cleared'
)
security
.
declareProtected
(
manage_zcatalog_entries
,
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_editCatalog
Report
'
)
'manage_editCatalog
Plan
'
)
def
manage_editCatalog
Report
(
self
,
long_query_time
=
0.1
,
REQUEST
=
None
):
def
manage_editCatalog
Plan
(
self
,
long_query_time
=
0.1
,
REQUEST
=
None
):
"""
edit the long query time
"""
"""
Edit the long query time.
"""
if
not
isinstance
(
long_query_time
,
float
):
if
not
isinstance
(
long_query_time
,
float
):
long_query_time
=
float
(
long_query_time
)
long_query_time
=
float
(
long_query_time
)
self
.
long_query_time
=
long_query_time
self
.
long_query_time
=
long_query_time
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
REQUEST
.
response
.
redirect
(
REQUEST
.
URL1
+
REQUEST
.
response
.
redirect
(
REQUEST
.
URL1
+
'/manage_catalog
Report
?manage_tabs_message='
+
'/manage_catalog
Plan
?manage_tabs_message='
+
'Long%20query%20time%20changed'
)
'Long%20query%20time%20changed'
)
InitializeClass
(
ZCatalog
)
InitializeClass
(
ZCatalog
)
...
...
src/Products/ZCatalog/dtml/catalog
Report
.dtml
→
src/Products/ZCatalog/dtml/catalog
Plan
.dtml
View file @
aa7d9cb8
...
@@ -29,8 +29,8 @@
...
@@ -29,8 +29,8 @@
</div>
</div>
</td>
</td>
</tr>
</tr>
<dtml-if getCatalog
Report
>
<dtml-if getCatalog
Plan
>
<dtml-in getCatalog
Report
mapping>
<dtml-in getCatalog
Plan
mapping>
<dtml-if sequence-odd>
<dtml-if sequence-odd>
<tr class="row-normal">
<tr class="row-normal">
<dtml-else>
<dtml-else>
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
<p class="form-help">Resetting the catalog report will reinitialize the report log.</p>
<p class="form-help">Resetting the catalog report will reinitialize the report log.</p>
</td>
</td>
<td colspan="2" align="right" valign="top">
<td colspan="2" align="right" valign="top">
<form action="manage_resetCatalog
Report
" method=POST>
<form action="manage_resetCatalog
Plan
" method=POST>
<div class="form-element">
<div class="form-element">
<input class="form-element" type="submit" value="Reset Report">
<input class="form-element" type="submit" value="Reset Report">
</div>
</div>
...
@@ -86,7 +86,7 @@
...
@@ -86,7 +86,7 @@
</dtml-if>
</dtml-if>
</table>
</table>
<form action="manage_editCatalog
Report
" method="post">
<form action="manage_editCatalog
Plan
" method="post">
<table width="100%" style="padding-top:1em;" cellspacing="0" cellpadding="2" border="0">
<table width="100%" style="padding-top:1em;" cellspacing="0" cellpadding="2" border="0">
<tr class="section-bar">
<tr class="section-bar">
<td colspan="3" align="left">
<td colspan="3" align="left">
...
...
src/Products/ZCatalog/
report
.py
→
src/Products/ZCatalog/
plan
.py
View file @
aa7d9cb8
...
@@ -102,8 +102,9 @@ def make_key(catalog, query):
...
@@ -102,8 +102,9 @@ def make_key(catalog, query):
return
key
return
key
class
CatalogReport
(
object
):
class
CatalogPlan
(
object
):
"""Catalog report class to meassure and identify catalog queries.
"""Catalog plan class to measure and identify catalog queries and plan
their execution.
"""
"""
def
__init__
(
self
,
catalog
,
query
=
None
,
threshold
=
0.1
):
def
__init__
(
self
,
catalog
,
query
=
None
,
threshold
=
0.1
):
...
...
src/Products/ZCatalog/tests/test_
report
.py
→
src/Products/ZCatalog/tests/test_
plan
.py
View file @
aa7d9cb8
...
@@ -26,7 +26,7 @@ class dummy(object):
...
@@ -26,7 +26,7 @@ class dummy(object):
return
(
self
.
num
,
self
.
num
+
1
)
return
(
self
.
num
,
self
.
num
+
1
)
class
TestCatalog
Report
(
unittest
.
TestCase
):
class
TestCatalog
Plan
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
from
Products.ZCatalog.ZCatalog
import
ZCatalog
from
Products.ZCatalog.ZCatalog
import
ZCatalog
...
@@ -41,12 +41,12 @@ class TestCatalogReport(unittest.TestCase):
...
@@ -41,12 +41,12 @@ class TestCatalogReport(unittest.TestCase):
self
.
zcat
.
catalog_object
(
obj
,
str
(
i
))
self
.
zcat
.
catalog_object
(
obj
,
str
(
i
))
def
tearDown
(
self
):
def
tearDown
(
self
):
from
Products.ZCatalog.
report
import
clear_value_indexes
from
Products.ZCatalog.
plan
import
clear_value_indexes
clear_value_indexes
()
clear_value_indexes
()
def
test_ReportLength
(
self
):
def
test_ReportLength
(
self
):
""" tests the report aggregation """
""" tests the report aggregation """
self
.
zcat
.
manage_resetCatalog
Report
()
self
.
zcat
.
manage_resetCatalog
Plan
()
self
.
zcat
.
searchResults
(
numbers
=
4
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
numbers
=
4
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
numbers
=
1
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
numbers
=
1
,
sort_on
=
'num'
)
...
@@ -58,49 +58,49 @@ class TestCatalogReport(unittest.TestCase):
...
@@ -58,49 +58,49 @@ class TestCatalogReport(unittest.TestCase):
self
.
zcat
.
searchResults
(
num
=
[
5
,
4
,
3
],
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
num
=
[
5
,
4
,
3
],
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
num
=
(
3
,
4
,
5
),
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
num
=
(
3
,
4
,
5
),
sort_on
=
'num'
)
self
.
assertEqual
(
4
,
len
(
self
.
zcat
.
getCatalog
Report
()))
self
.
assertEqual
(
4
,
len
(
self
.
zcat
.
getCatalog
Plan
()))
def
test_ReportCounter
(
self
):
def
test_ReportCounter
(
self
):
""" tests the counter of equal queries """
""" tests the counter of equal queries """
self
.
zcat
.
manage_resetCatalog
Report
()
self
.
zcat
.
manage_resetCatalog
Plan
()
self
.
zcat
.
searchResults
(
numbers
=
5
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
numbers
=
5
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
numbers
=
6
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
numbers
=
6
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
numbers
=
8
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
numbers
=
8
,
sort_on
=
'num'
)
r
=
self
.
zcat
.
getCatalog
Report
()[
0
]
r
=
self
.
zcat
.
getCatalog
Plan
()[
0
]
self
.
assertEqual
(
r
[
'counter'
],
3
)
self
.
assertEqual
(
r
[
'counter'
],
3
)
def
test_ReportKey
(
self
):
def
test_ReportKey
(
self
):
""" tests the query keys for uniqueness """
""" tests the query keys for uniqueness """
# query key 1
# query key 1
key
=
(
'sort_on'
,
(
'big'
,
'True'
))
key
=
(
'sort_on'
,
(
'big'
,
'True'
))
self
.
zcat
.
manage_resetCatalog
Report
()
self
.
zcat
.
manage_resetCatalog
Plan
()
self
.
zcat
.
searchResults
(
big
=
True
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
big
=
True
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
big
=
True
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
big
=
True
,
sort_on
=
'num'
)
r
=
self
.
zcat
.
getCatalog
Report
()[
0
]
r
=
self
.
zcat
.
getCatalog
Plan
()[
0
]
self
.
assertEqual
(
r
[
'query'
],
key
)
self
.
assertEqual
(
r
[
'query'
],
key
)
self
.
assertEqual
(
r
[
'counter'
],
2
)
self
.
assertEqual
(
r
[
'counter'
],
2
)
# query key 2
# query key 2
key
=
(
'sort_on'
,
(
'big'
,
'False'
))
key
=
(
'sort_on'
,
(
'big'
,
'False'
))
self
.
zcat
.
manage_resetCatalog
Report
()
self
.
zcat
.
manage_resetCatalog
Plan
()
self
.
zcat
.
searchResults
(
big
=
False
,
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
big
=
False
,
sort_on
=
'num'
)
r
=
self
.
zcat
.
getCatalog
Report
()[
0
]
r
=
self
.
zcat
.
getCatalog
Plan
()[
0
]
self
.
assertEqual
(
r
[
'query'
],
key
)
self
.
assertEqual
(
r
[
'query'
],
key
)
self
.
assertEqual
(
r
[
'counter'
],
1
)
self
.
assertEqual
(
r
[
'counter'
],
1
)
# query key 3
# query key 3
key
=
(
'sort_on'
,
(
'num'
,
'[3, 4, 5]'
))
key
=
(
'sort_on'
,
(
'num'
,
'[3, 4, 5]'
))
self
.
zcat
.
manage_resetCatalog
Report
()
self
.
zcat
.
manage_resetCatalog
Plan
()
self
.
zcat
.
searchResults
(
num
=
[
5
,
4
,
3
],
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
num
=
[
5
,
4
,
3
],
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
num
=
(
3
,
4
,
5
),
sort_on
=
'num'
)
self
.
zcat
.
searchResults
(
num
=
(
3
,
4
,
5
),
sort_on
=
'num'
)
r
=
self
.
zcat
.
getCatalog
Report
()[
0
]
r
=
self
.
zcat
.
getCatalog
Plan
()[
0
]
self
.
assertEqual
(
r
[
'query'
],
key
)
self
.
assertEqual
(
r
[
'query'
],
key
)
self
.
assertEqual
(
r
[
'counter'
],
2
)
self
.
assertEqual
(
r
[
'counter'
],
2
)
...
@@ -108,5 +108,5 @@ class TestCatalogReport(unittest.TestCase):
...
@@ -108,5 +108,5 @@ class TestCatalogReport(unittest.TestCase):
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestCatalog
Report
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestCatalog
Plan
))
return
suite
return
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