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
07bc1644
Commit
07bc1644
authored
Aug 01, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More PEP8
parent
63070380
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
78 deletions
+86
-78
src/Products/ZCatalog/ZCatalog.py
src/Products/ZCatalog/ZCatalog.py
+86
-78
No files found.
src/Products/ZCatalog/ZCatalog.py
View file @
07bc1644
...
@@ -53,17 +53,18 @@ LOG = logging.getLogger('Zope.ZCatalog')
...
@@ -53,17 +53,18 @@ LOG = logging.getLogger('Zope.ZCatalog')
manage_addZCatalogForm
=
DTMLFile
(
'dtml/addZCatalog'
,
globals
())
manage_addZCatalogForm
=
DTMLFile
(
'dtml/addZCatalog'
,
globals
())
def
manage_addZCatalog
(
self
,
id
,
title
,
def
manage_addZCatalog
(
self
,
id
,
title
,
vocab_id
=
None
,
# Deprecated
vocab_id
=
None
,
REQUEST
=
None
):
REQUEST
=
None
):
"""Add a ZCatalog object
"""Add a ZCatalog object
. The vocab_id argument is deprecated.
"""
"""
id
=
str
(
id
)
id
=
str
(
id
)
title
=
str
(
title
)
title
=
str
(
title
)
c
=
ZCatalog
(
id
,
title
,
vocab_id
,
self
)
c
=
ZCatalog
(
id
,
title
,
vocab_id
,
self
)
self
.
_setObject
(
id
,
c
)
self
.
_setObject
(
id
,
c
)
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
return
self
.
manage_main
(
self
,
REQUEST
,
update_menu
=
1
)
return
self
.
manage_main
(
self
,
REQUEST
,
update_menu
=
1
)
class
ZCatalog
(
Folder
,
Persistent
,
Implicit
):
class
ZCatalog
(
Folder
,
Persistent
,
Implicit
):
...
@@ -88,12 +89,12 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -88,12 +89,12 @@ class ZCatalog(Folder, Persistent, Implicit):
implements
(
IZCatalog
)
implements
(
IZCatalog
)
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
security
.
setPermissionDefault
(
manage_zcatalog_entries
,
(
'Manager'
,))
security
.
setPermissionDefault
(
manage_zcatalog_entries
,
(
'Manager'
,
))
security
.
setPermissionDefault
(
manage_zcatalog_indexes
,
(
'Manager'
,))
security
.
setPermissionDefault
(
manage_zcatalog_indexes
,
(
'Manager'
,
))
security
.
setPermissionDefault
(
search_zcatalog
,
(
'Anonymous'
,
'Manager'
))
security
.
setPermissionDefault
(
search_zcatalog
,
(
'Anonymous'
,
'Manager'
))
meta_type
=
"ZCatalog"
meta_type
=
"ZCatalog"
icon
=
'misc_/ZCatalog/ZCatalog.gif'
icon
=
'misc_/ZCatalog/ZCatalog.gif'
manage_options
=
(
manage_options
=
(
{
'label'
:
'Contents'
,
# TAB: Contents
{
'label'
:
'Contents'
,
# TAB: Contents
...
@@ -118,7 +119,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -118,7 +119,7 @@ class ZCatalog(Folder, Persistent, Implicit):
{
'label'
:
'Security'
,
# TAB: Security
{
'label'
:
'Security'
,
# TAB: Security
'action'
:
'manage_access'
},
'action'
:
'manage_access'
},
{
'label'
:
'Ownership'
,
# TAB: Ownership
{
'label'
:
'Ownership'
,
# TAB: Ownership
'action'
:
'manage_owner'
}
'action'
:
'manage_owner'
}
,
)
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_main'
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_main'
)
...
@@ -128,10 +129,10 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -128,10 +129,10 @@ class ZCatalog(Folder, Persistent, Implicit):
manage_catalogAddRowForm
=
DTMLFile
(
'dtml/catalogAddRowForm'
,
globals
())
manage_catalogAddRowForm
=
DTMLFile
(
'dtml/catalogAddRowForm'
,
globals
())
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogView'
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogView'
)
manage_catalogView
=
DTMLFile
(
'dtml/catalogView'
,
globals
())
manage_catalogView
=
DTMLFile
(
'dtml/catalogView'
,
globals
())
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogFind'
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogFind'
)
manage_catalogFind
=
DTMLFile
(
'dtml/catalogFind'
,
globals
())
manage_catalogFind
=
DTMLFile
(
'dtml/catalogFind'
,
globals
())
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogSchema'
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogSchema'
)
manage_catalogSchema
=
DTMLFile
(
'dtml/catalogSchema'
,
globals
())
manage_catalogSchema
=
DTMLFile
(
'dtml/catalogSchema'
,
globals
())
...
@@ -145,8 +146,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -145,8 +146,7 @@ class ZCatalog(Folder, Persistent, Implicit):
security
.
declareProtected
(
manage_zcatalog_entries
,
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogReport'
)
'manage_catalogReport'
)
manage_catalogReport
=
DTMLFile
(
'dtml/catalogReport'
,
manage_catalogReport
=
DTMLFile
(
'dtml/catalogReport'
,
globals
())
globals
())
security
.
declareProtected
(
manage_zcatalog_entries
,
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_objectInformation'
)
'manage_objectInformation'
)
...
@@ -222,7 +222,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -222,7 +222,7 @@ class ZCatalog(Folder, Persistent, Implicit):
""" index Zope object(s) that 'urls' point to """
""" index Zope object(s) that 'urls' point to """
if
urls
:
if
urls
:
if
isinstance
(
urls
,
str
):
if
isinstance
(
urls
,
str
):
urls
=
(
urls
,
)
urls
=
(
urls
,
)
for
url
in
urls
:
for
url
in
urls
:
obj
=
self
.
resolve_path
(
url
)
obj
=
self
.
resolve_path
(
url
)
...
@@ -243,7 +243,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -243,7 +243,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
urls
:
if
urls
:
if
isinstance
(
urls
,
str
):
if
isinstance
(
urls
,
str
):
urls
=
(
urls
,
)
urls
=
(
urls
,
)
for
url
in
urls
:
for
url
in
urls
:
self
.
uncatalog_object
(
url
)
self
.
uncatalog_object
(
url
)
...
@@ -287,10 +287,12 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -287,10 +287,12 @@ class ZCatalog(Folder, Persistent, Implicit):
num_objects
=
len
(
paths
)
num_objects
=
len
(
paths
)
if
pghandler
:
if
pghandler
:
pghandler
.
init
(
'Refreshing catalog: %s'
%
self
.
absolute_url
(
1
),
num_objects
)
pghandler
.
init
(
'Refreshing catalog: %s'
%
self
.
absolute_url
(
1
),
num_objects
)
for
i
in
xrange
(
num_objects
):
for
i
in
xrange
(
num_objects
):
if
pghandler
:
pghandler
.
report
(
i
)
if
pghandler
:
pghandler
.
report
(
i
)
p
=
paths
[
i
]
p
=
paths
[
i
]
obj
=
self
.
resolve_path
(
p
)
obj
=
self
.
resolve_path
(
p
)
...
@@ -305,7 +307,8 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -305,7 +307,8 @@ class ZCatalog(Folder, Persistent, Implicit):
LOG
.
error
(
'Recataloging object at %s failed'
%
p
,
LOG
.
error
(
'Recataloging object at %s failed'
%
p
,
exc_info
=
sys
.
exc_info
())
exc_info
=
sys
.
exc_info
())
if
pghandler
:
pghandler
.
finish
()
if
pghandler
:
pghandler
.
finish
()
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogClear'
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogClear'
)
def
manage_catalogClear
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
def
manage_catalogClear
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
...
@@ -359,8 +362,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -359,8 +362,7 @@ class ZCatalog(Folder, Persistent, Implicit):
urllib
.
quote
(
'Catalog Updated
\
n
'
urllib
.
quote
(
'Catalog Updated
\
n
'
'Total time: %s
\
n
'
'Total time: %s
\
n
'
'Total CPU time: %s'
'Total CPU time: %s'
%
(
`elapse`
,
`c_elapse`
))
%
(
`elapse`
,
`c_elapse`
)))
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_addColumn'
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_addColumn'
)
...
@@ -378,7 +380,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -378,7 +380,7 @@ class ZCatalog(Folder, Persistent, Implicit):
def
manage_delColumn
(
self
,
names
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
def
manage_delColumn
(
self
,
names
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
""" delete a column or some columns """
""" delete a column or some columns """
if
isinstance
(
names
,
str
):
if
isinstance
(
names
,
str
):
names
=
(
names
,)
names
=
(
names
,
)
for
name
in
names
:
for
name
in
names
:
self
.
delColumn
(
name
)
self
.
delColumn
(
name
)
...
@@ -393,7 +395,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -393,7 +395,7 @@ class ZCatalog(Folder, Persistent, Implicit):
def
manage_addIndex
(
self
,
name
,
type
,
extra
=
None
,
def
manage_addIndex
(
self
,
name
,
type
,
extra
=
None
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
"""add an index """
"""add an index """
self
.
addIndex
(
name
,
type
,
extra
)
self
.
addIndex
(
name
,
type
,
extra
)
if
REQUEST
and
RESPONSE
:
if
REQUEST
and
RESPONSE
:
RESPONSE
.
redirect
(
RESPONSE
.
redirect
(
...
@@ -408,10 +410,10 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -408,10 +410,10 @@ class ZCatalog(Folder, Persistent, Implicit):
if
not
ids
:
if
not
ids
:
return
MessageDialog
(
title
=
'No items specified'
,
return
MessageDialog
(
title
=
'No items specified'
,
message
=
'No items were specified!'
,
message
=
'No items were specified!'
,
action
=
"./manage_catalogIndexes"
,
)
action
=
"./manage_catalogIndexes"
)
if
isinstance
(
ids
,
str
):
if
isinstance
(
ids
,
str
):
ids
=
(
ids
,)
ids
=
(
ids
,
)
for
name
in
ids
:
for
name
in
ids
:
self
.
delIndex
(
name
)
self
.
delIndex
(
name
)
...
@@ -429,10 +431,10 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -429,10 +431,10 @@ class ZCatalog(Folder, Persistent, Implicit):
if
not
ids
:
if
not
ids
:
return
MessageDialog
(
title
=
'No items specified'
,
return
MessageDialog
(
title
=
'No items specified'
,
message
=
'No items were specified!'
,
message
=
'No items were specified!'
,
action
=
"./manage_catalogIndexes"
,
)
action
=
"./manage_catalogIndexes"
)
if
isinstance
(
ids
,
str
):
if
isinstance
(
ids
,
str
):
ids
=
(
ids
,)
ids
=
(
ids
,
)
for
name
in
ids
:
for
name
in
ids
:
self
.
clearIndex
(
name
)
self
.
clearIndex
(
name
)
...
@@ -445,7 +447,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -445,7 +447,7 @@ class ZCatalog(Folder, Persistent, Implicit):
def
reindexIndex
(
self
,
name
,
REQUEST
,
pghandler
=
None
):
def
reindexIndex
(
self
,
name
,
REQUEST
,
pghandler
=
None
):
if
isinstance
(
name
,
str
):
if
isinstance
(
name
,
str
):
name
=
(
name
,)
name
=
(
name
,
)
paths
=
self
.
_catalog
.
uids
.
keys
()
paths
=
self
.
_catalog
.
uids
.
keys
()
...
@@ -454,8 +456,9 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -454,8 +456,9 @@ class ZCatalog(Folder, Persistent, Implicit):
pghandler
.
init
(
'reindexing %s'
%
name
,
len
(
paths
))
pghandler
.
init
(
'reindexing %s'
%
name
,
len
(
paths
))
for
p
in
paths
:
for
p
in
paths
:
i
+=
1
i
+=
1
if
pghandler
:
pghandler
.
report
(
i
)
if
pghandler
:
pghandler
.
report
(
i
)
obj
=
self
.
resolve_path
(
p
)
obj
=
self
.
resolve_path
(
p
)
if
obj
is
None
:
if
obj
is
None
:
...
@@ -479,7 +482,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -479,7 +482,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
not
ids
:
if
not
ids
:
return
MessageDialog
(
title
=
'No items specified'
,
return
MessageDialog
(
title
=
'No items specified'
,
message
=
'No items were specified!'
,
message
=
'No items were specified!'
,
action
=
"./manage_catalogIndexes"
,
)
action
=
"./manage_catalogIndexes"
)
pgthreshold
=
self
.
_getProgressThreshold
()
pgthreshold
=
self
.
_getProgressThreshold
()
handler
=
(
pgthreshold
>
0
)
and
ZLogHandler
(
pgthreshold
)
or
None
handler
=
(
pgthreshold
>
0
)
and
ZLogHandler
(
pgthreshold
)
or
None
...
@@ -493,18 +496,20 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -493,18 +496,20 @@ class ZCatalog(Folder, Persistent, Implicit):
security
.
declareProtected
(
manage_zcatalog_entries
,
'catalog_object'
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'catalog_object'
)
def
catalog_object
(
self
,
obj
,
uid
=
None
,
idxs
=
None
,
update_metadata
=
1
,
pghandler
=
None
):
def
catalog_object
(
self
,
obj
,
uid
=
None
,
idxs
=
None
,
update_metadata
=
1
,
pghandler
=
None
):
""" wrapper around catalog """
""" wrapper around catalog """
if
uid
is
None
:
if
uid
is
None
:
try
:
uid
=
obj
.
getPhysicalPath
try
:
uid
=
obj
.
getPhysicalPath
except
AttributeError
:
except
AttributeError
:
raise
CatalogError
(
raise
CatalogError
(
"A cataloged object must support the 'getPhysicalPath' "
"A cataloged object must support the 'getPhysicalPath' "
"method if no unique id is provided when cataloging"
"method if no unique id is provided when cataloging"
)
)
else
:
else
:
uid
=
'/'
.
join
(
uid
())
uid
=
'/'
.
join
(
uid
())
elif
not
isinstance
(
uid
,
str
):
elif
not
isinstance
(
uid
,
str
):
raise
CatalogError
(
'The object unique id must be a string.'
)
raise
CatalogError
(
'The object unique id must be a string.'
)
self
.
_catalog
.
catalogObject
(
obj
,
uid
,
None
,
idxs
,
self
.
_catalog
.
catalogObject
(
obj
,
uid
,
None
,
idxs
,
...
@@ -605,9 +610,9 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -605,9 +610,9 @@ class ZCatalog(Folder, Persistent, Implicit):
def
_searchable_arguments
(
self
):
def
_searchable_arguments
(
self
):
r
=
{}
r
=
{}
n
=
{
'optional'
:
1
}
n
=
{
'optional'
:
1
}
for
name
in
self
.
_catalog
.
indexes
.
keys
():
for
name
in
self
.
_catalog
.
indexes
.
keys
():
r
[
name
]
=
n
r
[
name
]
=
n
return
r
return
r
def
_searchable_result_columns
(
self
):
def
_searchable_result_columns
(
self
):
...
@@ -734,12 +739,14 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -734,12 +739,14 @@ class ZCatalog(Folder, Persistent, Implicit):
raise
AttributeError
(
repr
(
result
))
raise
AttributeError
(
repr
(
result
))
for
id
,
ob
in
items
:
for
id
,
ob
in
items
:
if
pre
:
p
=
"%s/%s"
%
(
pre
,
id
)
if
pre
:
else
:
p
=
id
p
=
"%s/%s"
%
(
pre
,
id
)
else
:
p
=
id
dflag
=
0
dflag
=
0
if
hasattr
(
ob
,
'_p_changed'
)
and
(
ob
.
_p_changed
==
None
):
if
hasattr
(
ob
,
'_p_changed'
)
and
(
ob
.
_p_changed
==
None
):
dflag
=
1
dflag
=
1
bs
=
aq_base
(
ob
)
bs
=
aq_base
(
ob
)
...
@@ -751,22 +758,20 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -751,22 +758,20 @@ class ZCatalog(Folder, Persistent, Implicit):
and
and
(
not
obj_searchterm
or
(
not
obj_searchterm
or
(
hasattr
(
ob
,
'PrincipiaSearchSource'
)
and
(
hasattr
(
ob
,
'PrincipiaSearchSource'
)
and
ob
.
PrincipiaSearchSource
().
find
(
obj_searchterm
)
>=
0
ob
.
PrincipiaSearchSource
().
find
(
obj_searchterm
)
>=
0
))
))
and
and
(
not
obj_expr
or
expr_match
(
ob
,
obj_expr
))
(
not
obj_expr
or
expr_match
(
ob
,
obj_expr
))
and
and
(
not
obj_mtime
or
mtime_match
(
ob
,
obj_mtime
,
obj_mspec
))
(
not
obj_mtime
or
mtime_match
(
ob
,
obj_mtime
,
obj_mspec
))
and
and
(
(
not
obj_permission
or
not
obj_roles
)
or
\
((
not
obj_permission
or
not
obj_roles
)
or
role_match
(
ob
,
obj_permission
,
obj_roles
)
role_match
(
ob
,
obj_permission
,
obj_roles
))
)
):
):
if
apply_func
:
if
apply_func
:
apply_func
(
ob
,
(
apply_path
+
'/'
+
p
))
apply_func
(
ob
,
(
apply_path
+
'/'
+
p
))
else
:
else
:
add_result
((
p
,
ob
))
add_result
((
p
,
ob
))
dflag
=
0
dflag
=
0
if
search_sub
and
hasattr
(
bs
,
'objectItems'
):
if
search_sub
and
hasattr
(
bs
,
'objectItems'
):
self
.
ZopeFindAndApply
(
ob
,
obj_ids
,
obj_metatypes
,
self
.
ZopeFindAndApply
(
ob
,
obj_ids
,
obj_metatypes
,
...
@@ -776,7 +781,8 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -776,7 +781,8 @@ class ZCatalog(Folder, Persistent, Implicit):
search_sub
,
search_sub
,
REQUEST
,
result
,
p
,
REQUEST
,
result
,
p
,
apply_func
,
apply_path
)
apply_func
,
apply_path
)
if
dflag
:
ob
.
_p_deactivate
()
if
dflag
:
ob
.
_p_deactivate
()
return
result
return
result
...
@@ -824,7 +830,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -824,7 +830,7 @@ class ZCatalog(Folder, Persistent, Implicit):
for
path
,
rid
in
uids
.
items
():
for
path
,
rid
in
uids
.
items
():
ob
=
None
ob
=
None
if
path
[:
1
]
==
'/'
:
if
path
[:
1
]
==
'/'
:
ob
=
self
.
resolve_url
(
path
[
1
:],
REQUEST
)
ob
=
self
.
resolve_url
(
path
[
1
:],
REQUEST
)
if
ob
is
None
:
if
ob
is
None
:
ob
=
self
.
resolve_url
(
path
,
REQUEST
)
ob
=
self
.
resolve_url
(
path
,
REQUEST
)
if
ob
is
None
:
if
ob
is
None
:
...
@@ -854,11 +860,10 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -854,11 +860,10 @@ class ZCatalog(Folder, Persistent, Implicit):
"""Set parameter to perform logging of reindexing operations very
"""Set parameter to perform logging of reindexing operations very
'pgthreshold' objects
'pgthreshold' objects
"""
"""
self
.
pgthreshold
=
pgthreshold
self
.
pgthreshold
=
pgthreshold
if
RESPONSE
:
if
RESPONSE
:
RESPONSE
.
redirect
(
RESPONSE
.
redirect
(
URL1
+
'/manage_catalogAdvanced?'
URL1
+
'/manage_catalogAdvanced?
manage_tabs_message=Catalog%20Changed'
)
'
manage_tabs_message=Catalog%20Changed'
)
def
_getProgressThreshold
(
self
):
def
_getProgressThreshold
(
self
):
if
not
hasattr
(
self
,
'pgthreshold'
):
if
not
hasattr
(
self
,
'pgthreshold'
):
...
@@ -867,10 +872,10 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -867,10 +872,10 @@ class ZCatalog(Folder, Persistent, Implicit):
def
manage_convertIndexes
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
def
manage_convertIndexes
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
"""Recreate indexes derived from UnIndex because the implementation of
"""Recreate indexes derived from UnIndex because the implementation of
__len__ changed in Zope 2.8. Pre-Zope 2.7 installation used to
implement
__len__ changed in Zope 2.8. Pre-Zope 2.7 installation used to
__len__ as persistent attribute of the index instance which is totally
implement __len__ as persistent attribute of the index instance
incompatible with the new extension class implementation based on new-style
which is totally incompatible with the new extension class
classes.
implementation based on new-style classes.
"""
"""
LOG
.
info
(
'Start migration of indexes for %s'
%
self
.
absolute_url
(
1
))
LOG
.
info
(
'Start migration of indexes for %s'
%
self
.
absolute_url
(
1
))
...
@@ -915,20 +920,19 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -915,20 +920,19 @@ class ZCatalog(Folder, Persistent, Implicit):
LOG
.
info
(
'Finished migration of indexes for %s'
%
self
.
absolute_url
(
1
))
LOG
.
info
(
'Finished migration of indexes for %s'
%
self
.
absolute_url
(
1
))
if
RESPONSE
:
if
RESPONSE
:
RESPONSE
.
redirect
(
URL1
+
RESPONSE
.
redirect
(
URL1
+
'/manage_main?manage_tabs_message='
'/manage_main?manage_tabs_message=Indexes%20converted%20and%20reindexed'
)
'Indexes%20converted%20and%20reindexed'
)
#
#
# Indexing methods
# Indexing methods
#
#
def
addIndex
(
self
,
name
,
type
,
extra
=
None
):
def
addIndex
(
self
,
name
,
type
,
extra
=
None
):
# Convert the type by finding an appropriate product which supports
# Convert the type by finding an appropriate product which supports
# this interface by that name. Bleah
# this interface by that name. Bleah
products
=
ObjectManager
.
all_meta_types
(
self
,
products
=
ObjectManager
.
all_meta_types
(
self
,
interfaces
=
(
IPluggableIndex
,))
interfaces
=
(
IPluggableIndex
,
))
p
=
None
p
=
None
...
@@ -938,12 +942,12 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -938,12 +942,12 @@ class ZCatalog(Folder, Persistent, Implicit):
break
break
if
p
is
None
:
if
p
is
None
:
raise
ValueError
,
"Index of type %s not found"
%
type
raise
ValueError
(
"Index of type %s not found"
%
type
)
base
=
p
[
'instance'
]
base
=
p
[
'instance'
]
if
base
is
None
:
if
base
is
None
:
raise
ValueError
,
"Index type %s does not support addIndex"
%
type
raise
ValueError
(
"Index type %s does not support addIndex"
%
type
)
# This code is *really* lame but every index type has its own
# This code is *really* lame but every index type has its own
# function signature *sigh* and there is no common way to pass
# function signature *sigh* and there is no common way to pass
...
@@ -957,16 +961,14 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -957,16 +961,14 @@ class ZCatalog(Folder, Persistent, Implicit):
else
:
else
:
index
=
base
(
name
)
index
=
base
(
name
)
self
.
_catalog
.
addIndex
(
name
,
index
)
self
.
_catalog
.
addIndex
(
name
,
index
)
def
delIndex
(
self
,
name
):
def
delIndex
(
self
,
name
):
self
.
_catalog
.
delIndex
(
name
)
self
.
_catalog
.
delIndex
(
name
)
def
clearIndex
(
self
,
name
):
def
clearIndex
(
self
,
name
):
self
.
_catalog
.
getIndex
(
name
).
clear
()
self
.
_catalog
.
getIndex
(
name
).
clear
()
def
addColumn
(
self
,
name
,
default_value
=
None
):
def
addColumn
(
self
,
name
,
default_value
=
None
):
return
self
.
_catalog
.
addColumn
(
name
,
default_value
)
return
self
.
_catalog
.
addColumn
(
name
,
default_value
)
...
@@ -1014,30 +1016,36 @@ InitializeClass(ZCatalog)
...
@@ -1014,30 +1016,36 @@ InitializeClass(ZCatalog)
def
p_name
(
name
):
def
p_name
(
name
):
return
'_'
+
string
.
translate
(
name
,
name_trans
)
+
'_Permission'
return
'_'
+
string
.
translate
(
name
,
name_trans
)
+
'_Permission'
def
absattr
(
attr
):
def
absattr
(
attr
):
if
callable
(
attr
):
return
attr
()
if
callable
(
attr
):
return
attr
()
return
attr
return
attr
class
td
(
RestrictedDTML
,
TemplateDict
):
class
td
(
RestrictedDTML
,
TemplateDict
):
pass
pass
def
expr_match
(
ob
,
ed
,
c
=
InstanceDict
,
r
=
0
):
def
expr_match
(
ob
,
ed
,
c
=
InstanceDict
,
r
=
0
):
e
,
md
,
push
,
pop
=
ed
e
,
md
,
push
,
pop
=
ed
push
(
c
(
ob
,
md
))
push
(
c
(
ob
,
md
))
try
:
r
=
e
.
eval
(
md
)
try
:
r
=
e
.
eval
(
md
)
finally
:
finally
:
pop
()
pop
()
return
r
return
r
def
mtime_match
(
ob
,
t
,
q
,
fn
=
hasattr
):
def
mtime_match
(
ob
,
t
,
q
,
fn
=
hasattr
):
if
not
fn
(
ob
,
'_p_mtime'
):
if
not
fn
(
ob
,
'_p_mtime'
):
return
0
return
0
return
q
==
'<'
and
(
ob
.
_p_mtime
<
t
)
or
(
ob
.
_p_mtime
>
t
)
return
q
==
'<'
and
(
ob
.
_p_mtime
<
t
)
or
(
ob
.
_p_mtime
>
t
)
def
role_match
(
ob
,
permission
,
roles
,
lt
=
type
([]),
tt
=
type
(())):
def
role_match
(
ob
,
permission
,
roles
,
lt
=
type
([]),
tt
=
type
(())):
pr
=
[]
pr
=
[]
fn
=
pr
.
append
fn
=
pr
.
append
while
1
:
while
1
:
if
hasattr
(
ob
,
permission
):
if
hasattr
(
ob
,
permission
):
...
...
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