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
d532b3b6
Commit
d532b3b6
authored
Jul 15, 2004
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- simplified implementation
- renamed handlers - added zlog handler
parent
eead7c05
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
28 deletions
+14
-28
lib/python/Products/ZCatalog/ProgressHandler.py
lib/python/Products/ZCatalog/ProgressHandler.py
+6
-21
lib/python/Products/ZCatalog/ZCatalog.py
lib/python/Products/ZCatalog/ZCatalog.py
+8
-7
No files found.
lib/python/Products/ZCatalog/ProgressHandler.py
View file @
d532b3b6
...
...
@@ -16,8 +16,9 @@ $Id: ZCatalog.py 25050 2004-05-27 15:06:40Z chrisw $
"""
import
time
,
sys
from
zLOG
import
LOG
,
INFO
class
DefaultProgress
Handler
:
class
Stdout
Handler
:
""" A simple progress handler """
def
__init__
(
self
,
steps
=
100
):
...
...
@@ -42,25 +43,9 @@ class DefaultProgressHandler:
print
>>
self
.
fp
,
'%s: %s'
%
(
self
.
_ident
,
text
)
class
ProgressMixin
:
""" A simple machinery to provide progres informations for long running
ZCatalog operations like reindexing.
"""
class
ZLogHandler
(
StdoutHandler
):
""" Use zLOG """
def
pg_register
(
self
,
handler
=
None
):
self
.
_v_pg_handler
=
handler
def
pg_init
(
self
,
ident
,
max
):
handler
=
getattr
(
self
,
'_v_pg_handler'
,
None
)
if
not
handler
:
return
handler
.
init
(
ident
,
max
)
def
pg_finish
(
self
):
handler
=
getattr
(
self
,
'_v_pg_handler'
,
None
)
if
not
handler
:
return
handler
.
finish
()
def
output
(
self
,
text
):
LOG
(
self
.
_ident
,
INFO
,
text
)
def
pg_report
(
self
,
current
,
*
args
,
**
kw
):
handler
=
getattr
(
self
,
'_v_pg_handler'
,
None
)
if
not
handler
:
return
handler
.
report
(
current
,
*
args
,
**
kw
)
lib/python/Products/ZCatalog/ZCatalog.py
View file @
d532b3b6
...
...
@@ -38,7 +38,6 @@ from Products.PluginIndexes.TextIndex import Splitter
import
urllib
,
time
,
sys
import
string
,
logging
from
IZCatalog
import
IZCatalog
from
ProgressHandler
import
ProgressMixin
,
DefaultProgressHandler
LOG
=
logging
.
getLogger
(
'Zope.ZCatalog'
)
...
...
@@ -57,7 +56,7 @@ def manage_addZCatalog(self, id, title,
return
self
.
manage_main
(
self
,
REQUEST
,
update_menu
=
1
)
class
ZCatalog
(
Folder
,
Persistent
,
Implicit
,
ProgressMixin
):
class
ZCatalog
(
Folder
,
Persistent
,
Implicit
):
"""ZCatalog object
A ZCatalog contains arbirary index like references to Zope
...
...
@@ -461,7 +460,7 @@ class ZCatalog(Folder, Persistent, Implicit, ProgressMixin):
'/manage_catalogIndexes?manage_tabs_message=Index%20Cleared'
)
def
reindexIndex
(
self
,
name
,
REQUEST
):
def
reindexIndex
(
self
,
name
,
REQUEST
,
pghandler
=
None
):
if
isinstance
(
name
,
str
):
name
=
(
name
,)
...
...
@@ -469,12 +468,13 @@ class ZCatalog(Folder, Persistent, Implicit, ProgressMixin):
num_paths
=
len
(
paths
)
# inefficient
i
=
0
self
.
pg_register
(
DefaultProgressHandler
(
steps
=
10
))
self
.
pg_
init
(
'reindexing %s'
%
name
,
num_paths
)
if
pghandler
:
pghandler
.
init
(
'reindexing %s'
%
name
,
num_paths
)
for
p
in
paths
:
i
+=
1
self
.
pg_report
(
i
)
if
pghandler
:
pghandler
.
report
(
i
)
obj
=
self
.
resolve_path
(
p
)
if
not
obj
:
obj
=
self
.
resolve_url
(
p
,
REQUEST
)
...
...
@@ -498,7 +498,8 @@ class ZCatalog(Folder, Persistent, Implicit, ProgressMixin):
DeprecationWarning
)
self
.
catalog_object
(
obj
,
p
,
idxs
=
name
)
self
.
pg_finish
()
if
pghandler
:
pghandler
.
finish
()
def
manage_reindexIndex
(
self
,
ids
=
None
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
...
...
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