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
35de9c78
Commit
35de9c78
authored
Sep 28, 1999
by
Michel Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vastly improved mass indexing speed and memory usage. Indexed 56MB of
text in 8MB
parent
3b8d0f35
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
113 additions
and
18 deletions
+113
-18
lib/python/Products/ZCatalog/Catalog.py
lib/python/Products/ZCatalog/Catalog.py
+3
-0
lib/python/Products/ZCatalog/ZCatalog.py
lib/python/Products/ZCatalog/ZCatalog.py
+110
-18
No files found.
lib/python/Products/ZCatalog/Catalog.py
View file @
35de9c78
...
...
@@ -570,3 +570,6 @@ class Catalog(Persistent, Acquisition.Implicit):
lib/python/Products/ZCatalog/ZCatalog.py
View file @
35de9c78
...
...
@@ -109,7 +109,7 @@ def manage_addZCatalog(self,id,title,REQUEST=None):
return
self
.
manage_main
(
self
,
REQUEST
)
class
ZCatalog
(
Folder
,
FindSupport
,
Persistent
,
Implicit
):
class
ZCatalog
(
Folder
,
Persistent
,
Implicit
):
"""ZCatalog object
A ZCatalog contains arbirary index like references to Zope
...
...
@@ -287,7 +287,9 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
c_elapse
=
time
.
clock
()
words
=
0
results
=
self
.
ZopeFind
(
REQUEST
.
PARENTS
[
1
],
path
=
string
.
split
(
URL2
,
REQUEST
.
script
)[
1
][
1
:]
results
=
self
.
ZopeFindAndApply
(
REQUEST
.
PARENTS
[
1
],
obj_metatypes
=
obj_metatypes
,
obj_ids
=
obj_ids
,
obj_searchterm
=
obj_searchterm
,
...
...
@@ -297,13 +299,9 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
obj_permission
=
obj_permission
,
obj_roles
=
obj_roles
,
search_sub
=
1
,
REQUEST
=
REQUEST
)
for
n
in
results
:
if
REQUEST
.
script
!=
""
:
abs_path
=
string
.
split
((
URL2
+
'/'
+
n
[
0
]),
REQUEST
.
script
)[
1
][
1
:]
self
.
catalog_object
(
n
[
1
],
abs_path
)
REQUEST
=
REQUEST
,
apply_func
=
self
.
catalog_object
,
apply_path
=
path
)
elapse
=
time
.
time
()
-
elapse
c_elapse
=
time
.
clock
()
-
c_elapse
...
...
@@ -450,6 +448,100 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
roles
.
sort
()
return
roles
def
ZopeFindAndApply
(
self
,
obj
,
obj_ids
=
None
,
obj_metatypes
=
None
,
obj_searchterm
=
None
,
obj_expr
=
None
,
obj_mtime
=
None
,
obj_mspec
=
None
,
obj_permission
=
None
,
obj_roles
=
None
,
search_sub
=
0
,
REQUEST
=
None
,
result
=
None
,
pre
=
''
,
apply_func
=
None
,
apply_path
=
''
):
"""Zope Find interface and apply"""
if
result
is
None
:
result
=
[]
if
obj_metatypes
and
'all'
in
obj_metatypes
:
obj_metatypes
=
None
if
obj_mtime
and
type
(
obj_mtime
)
==
type
(
's'
):
obj_mtime
=
DateTime
(
obj_mtime
).
timeTime
()
if
obj_permission
:
obj_permission
=
p_name
(
obj_permission
)
if
obj_roles
and
type
(
obj_roles
)
is
type
(
's'
):
obj_roles
=
[
obj_roles
]
if
obj_expr
:
# Setup expr machinations
md
=
td
()
if
hasattr
(
REQUEST
,
'AUTHENTICATED_USER'
):
md
.
AUTHENTICATED_USER
=
REQUEST
.
AUTHENTICATED_USER
obj_expr
=
(
Eval
(
obj_expr
,
expr_globals
),
md
,
md
.
_push
,
md
.
_pop
)
base
=
obj
if
hasattr
(
obj
,
'aq_base'
):
base
=
obj
.
aq_base
if
not
hasattr
(
base
,
'objectItems'
):
return
result
try
:
items
=
base
.
objectItems
()
except
:
return
result
try
:
add_result
=
result
.
append
except
:
raise
AttributeError
,
`result`
for
id
,
ob
in
items
:
if
pre
:
p
=
"%s/%s"
%
(
pre
,
id
)
else
:
p
=
id
dflag
=
0
if
hasattr
(
ob
,
'_p_changed'
)
and
(
ob
.
_p_changed
==
None
):
dflag
=
1
if
hasattr
(
ob
,
'aq_base'
):
bs
=
ob
.
aq_base
else
:
bs
=
ob
if
(
(
not
obj_ids
or
absattr
(
bs
.
id
)
in
obj_ids
)
and
(
not
obj_metatypes
or
(
hasattr
(
bs
,
'meta_type'
)
and
bs
.
meta_type
in
obj_metatypes
))
and
(
not
obj_searchterm
or
(
hasattr
(
ob
,
'PrincipiaSearchSource'
)
and
find
(
ob
.
PrincipiaSearchSource
(),
obj_searchterm
)
>=
0
))
and
(
not
obj_expr
or
expr_match
(
ob
,
obj_expr
))
and
(
not
obj_mtime
or
mtime_match
(
ob
,
obj_mtime
,
obj_mspec
))
and
(
(
not
obj_permission
or
not
obj_roles
)
or
\
role_match
(
ob
,
obj_permission
,
obj_roles
)
)
):
if
apply_func
:
apply_func
(
ob
,
(
apply_path
+
'/'
+
p
))
else
:
add_result
((
p
,
ob
))
dflag
=
0
if
search_sub
and
hasattr
(
bs
,
'objectItems'
):
self
.
ZopeFindAndApply
(
ob
,
obj_ids
,
obj_metatypes
,
obj_searchterm
,
obj_expr
,
obj_mtime
,
obj_mspec
,
obj_permission
,
obj_roles
,
search_sub
,
REQUEST
,
result
,
p
,
apply_func
,
apply_path
)
if
dflag
:
ob
.
_p_deactivate
()
return
result
def
resolve_url
(
self
,
path
,
REQUEST
):
"""
...
...
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