Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lukas Niegsch
erp5
Commits
0aa35a8c
Commit
0aa35a8c
authored
Sep 18, 2013
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set permissions in all methods in ZSQLCatalog and SQLCatalog.
parent
2fc28650
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
170 additions
and
25 deletions
+170
-25
product/ERP5Catalog/tests/testERP5Catalog.py
product/ERP5Catalog/tests/testERP5Catalog.py
+2
-2
product/ZSQLCatalog/SQLCatalog.py
product/ZSQLCatalog/SQLCatalog.py
+94
-6
product/ZSQLCatalog/ZSQLCatalog.py
product/ZSQLCatalog/ZSQLCatalog.py
+74
-17
No files found.
product/ERP5Catalog/tests/testERP5Catalog.py
View file @
0aa35a8c
...
@@ -1250,7 +1250,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
...
@@ -1250,7 +1250,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
for
i
in
range
(
0
,
100
):
for
i
in
range
(
0
,
100
):
message_list
=
portal_activities
.
getMessageList
()
message_list
=
portal_activities
.
getMessageList
()
for
message
in
message_list
:
for
message
in
message_list
:
#if message.method_id=='setHotReindexingState':
#if message.method_id=='
_
setHotReindexingState':
# import pdb;pdb.set_trace()
# import pdb;pdb.set_trace()
if
message
.
method_id
in
method_id_list
:
if
message
.
method_id
in
method_id_list
:
try
:
try
:
...
@@ -1383,7 +1383,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
...
@@ -1383,7 +1383,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
'recursiveImmediateReindexObject'
,
'recursiveImmediateReindexObject'
,
'playBackRecordedObjectList'
,
'playBackRecordedObjectList'
,
'getId'
,
'getId'
,
'setHotReindexingState'
))
'
_
setHotReindexingState'
))
self
.
assertEqual
(
portal_catalog
.
getHotReindexingState
(),
self
.
assertEqual
(
portal_catalog
.
getHotReindexingState
(),
HOT_REINDEXING_DOUBLE_INDEXING_STATE
)
HOT_REINDEXING_DOUBLE_INDEXING_STATE
)
# Now we have started an double indexing
# Now we have started an double indexing
...
...
product/ZSQLCatalog/SQLCatalog.py
View file @
0aa35a8c
...
@@ -22,6 +22,8 @@ from App.special_dtml import DTMLFile
...
@@ -22,6 +22,8 @@ from App.special_dtml import DTMLFile
from
thread
import
allocate_lock
,
get_ident
from
thread
import
allocate_lock
,
get_ident
from
OFS.Folder
import
Folder
from
OFS.Folder
import
Folder
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
AccessControl.Permissions
import
access_contents_information
,
\
manage_zcatalog_entries
from
AccessControl.SimpleObjectPolicies
import
ContainerAssertions
from
AccessControl.SimpleObjectPolicies
import
ContainerAssertions
from
BTrees.OIBTree
import
OIBTree
from
BTrees.OIBTree
import
OIBTree
from
App.config
import
getConfiguration
from
App.config
import
getConfiguration
...
@@ -670,12 +672,14 @@ class Catalog(Folder,
...
@@ -670,12 +672,14 @@ class Catalog(Folder,
pass
pass
super
(
Catalog
,
self
).
manage_afterClone
(
item
)
super
(
Catalog
,
self
).
manage_afterClone
(
item
)
security
.
declarePrivate
(
'getCacheSequenceNumber'
)
def
getCacheSequenceNumber
(
self
):
def
getCacheSequenceNumber
(
self
):
return
self
.
_cache_sequence_number
return
self
.
_cache_sequence_number
def
_clearCaches
(
self
):
def
_clearCaches
(
self
):
self
.
_cache_sequence_number
+=
1
self
.
_cache_sequence_number
+=
1
security
.
declarePrivate
(
'getSQLCatalogRoleKeysList'
)
def
getSQLCatalogRoleKeysList
(
self
):
def
getSQLCatalogRoleKeysList
(
self
):
"""
"""
Return the list of role keys.
Return the list of role keys.
...
@@ -686,6 +690,7 @@ class Catalog(Folder,
...
@@ -686,6 +690,7 @@ class Catalog(Folder,
role_key_dict
[
role
.
strip
()]
=
column
.
strip
()
role_key_dict
[
role
.
strip
()]
=
column
.
strip
()
return
role_key_dict
.
items
()
return
role_key_dict
.
items
()
security
.
declarePrivate
(
'getSQLCatalogSecurityUidGroupsColumnsDict'
)
def
getSQLCatalogSecurityUidGroupsColumnsDict
(
self
):
def
getSQLCatalogSecurityUidGroupsColumnsDict
(
self
):
"""
"""
Return a mapping of local_roles_group_id name to the name of the column
Return a mapping of local_roles_group_id name to the name of the column
...
@@ -698,6 +703,7 @@ class Catalog(Folder,
...
@@ -698,6 +703,7 @@ class Catalog(Folder,
local_roles_group_id_dict
[
local_roles_group_id
.
strip
()]
=
column
.
strip
()
local_roles_group_id_dict
[
local_roles_group_id
.
strip
()]
=
column
.
strip
()
return
local_roles_group_id_dict
return
local_roles_group_id_dict
security
.
declarePrivate
(
'getSQLCatalogLocalRoleKeysList'
)
def
getSQLCatalogLocalRoleKeysList
(
self
):
def
getSQLCatalogLocalRoleKeysList
(
self
):
"""
"""
Return the list of local role keys.
Return the list of local role keys.
...
@@ -708,6 +714,7 @@ class Catalog(Folder,
...
@@ -708,6 +714,7 @@ class Catalog(Folder,
local_role_key_dict
[
role
.
strip
()]
=
column
.
strip
()
local_role_key_dict
[
role
.
strip
()]
=
column
.
strip
()
return
local_role_key_dict
.
items
()
return
local_role_key_dict
.
items
()
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_exportProperties'
)
def
manage_exportProperties
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
):
def
manage_exportProperties
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
):
"""
"""
Export properties to an XML file.
Export properties to an XML file.
...
@@ -767,6 +774,7 @@ class Catalog(Folder,
...
@@ -767,6 +774,7 @@ class Catalog(Folder,
'inline;filename=properties.xml'
)
'inline;filename=properties.xml'
)
return
f
.
getvalue
()
return
f
.
getvalue
()
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_importProperties'
)
def
manage_importProperties
(
self
,
file
):
def
manage_importProperties
(
self
,
file
):
"""
"""
Import properties from an XML file.
Import properties from an XML file.
...
@@ -821,6 +829,7 @@ class Catalog(Folder,
...
@@ -821,6 +829,7 @@ class Catalog(Folder,
finally
:
finally
:
doc
.
unlink
()
doc
.
unlink
()
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_historyCompare'
)
def
manage_historyCompare
(
self
,
rev1
,
rev2
,
REQUEST
,
def
manage_historyCompare
(
self
,
rev1
,
rev2
,
REQUEST
,
historyComparisonResults
=
''
):
historyComparisonResults
=
''
):
return
Catalog
.
inheritedAttribute
(
'manage_historyCompare'
)(
return
Catalog
.
inheritedAttribute
(
'manage_historyCompare'
)(
...
@@ -898,6 +907,7 @@ class Catalog(Folder,
...
@@ -898,6 +907,7 @@ class Catalog(Folder,
return
(
local_roles_group_id_to_security_uid_mapping
,
optimised_roles_and_users
)
return
(
local_roles_group_id_to_security_uid_mapping
,
optimised_roles_and_users
)
security
.
declarePrivate
(
'getRoleAndSecurityUidList'
)
def
getRoleAndSecurityUidList
(
self
):
def
getRoleAndSecurityUidList
(
self
):
"""
"""
Return a list of 3-tuples, suitable for direct use in a zsqlmethod.
Return a list of 3-tuples, suitable for direct use in a zsqlmethod.
...
@@ -958,7 +968,7 @@ class Catalog(Folder,
...
@@ -958,7 +968,7 @@ class Catalog(Folder,
self
.
subject_set_uid_dict
[
subject_list
]
=
subject_set_uid
self
.
subject_set_uid_dict
[
subject_list
]
=
subject_set_uid
return
(
subject_set_uid
,
subject_list
)
return
(
subject_set_uid
,
subject_list
)
def
clear
(
self
):
def
_
clear
(
self
):
"""
"""
Clears the catalog by calling a list of methods
Clears the catalog by calling a list of methods
"""
"""
...
@@ -975,7 +985,7 @@ class Catalog(Folder,
...
@@ -975,7 +985,7 @@ class Catalog(Folder,
raise
raise
# Reserved uids have been removed.
# Reserved uids have been removed.
self
.
clearReserved
()
self
.
_
clearReserved
()
id_tool
=
getattr
(
self
.
getPortalObject
(),
'portal_ids'
,
None
)
id_tool
=
getattr
(
self
.
getPortalObject
(),
'portal_ids'
,
None
)
if
id_tool
is
None
:
if
id_tool
is
None
:
...
@@ -986,6 +996,7 @@ class Catalog(Folder,
...
@@ -986,6 +996,7 @@ class Catalog(Folder,
self
.
_clearSubjectCache
()
self
.
_clearSubjectCache
()
self
.
_clearCaches
()
self
.
_clearCaches
()
security
.
declarePrivate
(
'insertMaxUid'
)
def
insertMaxUid
(
self
):
def
insertMaxUid
(
self
):
"""
"""
Add a dummy item so that SQLCatalog will not use existing uids again.
Add a dummy item so that SQLCatalog will not use existing uids again.
...
@@ -996,7 +1007,7 @@ class Catalog(Folder,
...
@@ -996,7 +1007,7 @@ class Catalog(Folder,
self
.
_max_uid
.
change
(
1
)
self
.
_max_uid
.
change
(
1
)
method
(
uid
=
[
self
.
_max_uid
()])
method
(
uid
=
[
self
.
_max_uid
()])
def
clearReserved
(
self
):
def
_
clearReserved
(
self
):
"""
"""
Clears reserved uids
Clears reserved uids
"""
"""
...
@@ -1013,6 +1024,7 @@ class Catalog(Folder,
...
@@ -1013,6 +1024,7 @@ class Catalog(Folder,
raise
raise
self
.
_last_clear_reserved_time
+=
1
self
.
_last_clear_reserved_time
+=
1
security
.
declarePrivate
(
'getRecordForUid'
)
def
getRecordForUid
(
self
,
uid
):
def
getRecordForUid
(
self
,
uid
):
"""
"""
Get an object by UID
Get an object by UID
...
@@ -1032,6 +1044,7 @@ class Catalog(Folder,
...
@@ -1032,6 +1044,7 @@ class Catalog(Folder,
return
search_result
[
0
]
return
search_result
[
0
]
raise
KeyError
,
uid
raise
KeyError
,
uid
security
.
declarePrivate
(
'editSchema'
)
def
editSchema
(
self
,
names_list
):
def
editSchema
(
self
,
names_list
):
"""
"""
Builds a schema from a list of strings
Builds a schema from a list of strings
...
@@ -1051,6 +1064,7 @@ class Catalog(Folder,
...
@@ -1051,6 +1064,7 @@ class Catalog(Folder,
self
.
schema
=
schema
self
.
schema
=
schema
self
.
names
=
names
self
.
names
=
names
security
.
declarePrivate
(
'getCatalogSearchTableIds'
)
def
getCatalogSearchTableIds
(
self
):
def
getCatalogSearchTableIds
(
self
):
"""Return selected tables of catalog which are used in JOIN.
"""Return selected tables of catalog which are used in JOIN.
catalaog is always first
catalaog is always first
...
@@ -1108,6 +1122,7 @@ class Catalog(Folder,
...
@@ -1108,6 +1122,7 @@ class Catalog(Folder,
add_key
(
scriptable_tuple
[
0
].
strip
())
add_key
(
scriptable_tuple
[
0
].
strip
())
return
sorted
(
keys
)
return
sorted
(
keys
)
security
.
declarePrivate
(
'getColumnIds'
)
def
getColumnIds
(
self
):
def
getColumnIds
(
self
):
"""
"""
Calls the show column method and returns dictionnary of
Calls the show column method and returns dictionnary of
...
@@ -1115,6 +1130,7 @@ class Catalog(Folder,
...
@@ -1115,6 +1130,7 @@ class Catalog(Folder,
"""
"""
return
self
.
_getColumnIds
()[:]
return
self
.
_getColumnIds
()[:]
security
.
declarePrivate
(
'getColumnMap'
)
@
transactional_cache_decorator
(
'SQLCatalog.getColumnMap'
)
@
transactional_cache_decorator
(
'SQLCatalog.getColumnMap'
)
@
caching_instance_method
(
id
=
'SQLCatalog.getColumnMap'
,
@
caching_instance_method
(
id
=
'SQLCatalog.getColumnMap'
,
cache_factory
=
'erp5_content_long'
,
cache_factory
=
'erp5_content_long'
,
...
@@ -1132,6 +1148,7 @@ class Catalog(Folder,
...
@@ -1132,6 +1148,7 @@ class Catalog(Folder,
result
.
setdefault
(
'%s.%s'
%
(
table
,
field
),
[]).
append
(
table
)
# Is this inconsistent ?
result
.
setdefault
(
'%s.%s'
%
(
table
,
field
),
[]).
append
(
table
)
# Is this inconsistent ?
return
result
return
result
security
.
declarePrivate
(
'getResultColumnIds'
)
@
transactional_cache_decorator
(
'SQLCatalog.getResultColumnIds'
)
@
transactional_cache_decorator
(
'SQLCatalog.getResultColumnIds'
)
@
caching_instance_method
(
id
=
'SQLCatalog.getResultColumnIds'
,
@
caching_instance_method
(
id
=
'SQLCatalog.getResultColumnIds'
,
cache_factory
=
'erp5_content_long'
,
cache_factory
=
'erp5_content_long'
,
...
@@ -1148,6 +1165,7 @@ class Catalog(Folder,
...
@@ -1148,6 +1165,7 @@ class Catalog(Folder,
keys
.
add
(
'%s.%s'
%
(
table
,
field
))
keys
.
add
(
'%s.%s'
%
(
table
,
field
))
return
sorted
(
keys
)
return
sorted
(
keys
)
security
.
declarePrivate
(
'getSortColumnIds'
)
@
transactional_cache_decorator
(
'SQLCatalog.getSortColumnIds'
)
@
transactional_cache_decorator
(
'SQLCatalog.getSortColumnIds'
)
@
caching_instance_method
(
id
=
'SQLCatalog.getSortColumnIds'
,
@
caching_instance_method
(
id
=
'SQLCatalog.getSortColumnIds'
,
cache_factory
=
'erp5_content_long'
,
cache_factory
=
'erp5_content_long'
,
...
@@ -1164,6 +1182,7 @@ class Catalog(Folder,
...
@@ -1164,6 +1182,7 @@ class Catalog(Folder,
keys
.
add
(
'%s.%s'
%
(
table
,
field
))
keys
.
add
(
'%s.%s'
%
(
table
,
field
))
return
sorted
(
keys
)
return
sorted
(
keys
)
security
.
declarePrivate
(
'getTableIds'
)
def
getTableIds
(
self
):
def
getTableIds
(
self
):
"""
"""
Calls the show table method and returns dictionnary of
Calls the show table method and returns dictionnary of
...
@@ -1182,6 +1201,7 @@ class Catalog(Folder,
...
@@ -1182,6 +1201,7 @@ class Catalog(Folder,
pass
pass
return
keys
return
keys
security
.
declarePrivate
(
'getUIDBuffer'
)
def
getUIDBuffer
(
self
,
force_new_buffer
=
False
):
def
getUIDBuffer
(
self
,
force_new_buffer
=
False
):
global
global_uid_buffer_dict
global
global_uid_buffer_dict
klass
=
self
.
__class__
klass
=
self
.
__class__
...
@@ -1197,6 +1217,7 @@ class Catalog(Folder,
...
@@ -1197,6 +1217,7 @@ class Catalog(Folder,
return
uid_buffer_dict
[
thread_key
]
return
uid_buffer_dict
[
thread_key
]
# the cataloging API
# the cataloging API
security
.
declarePrivate
(
'produceUid'
)
def
produceUid
(
self
):
def
produceUid
(
self
):
"""
"""
Produces reserved uids in advance
Produces reserved uids in advance
...
@@ -1233,6 +1254,7 @@ class Catalog(Folder,
...
@@ -1233,6 +1254,7 @@ class Catalog(Folder,
uid_list
=
[
x
.
uid
for
x
in
method
(
count
=
UID_BUFFER_SIZE
,
instance_id
=
instance_id
)
if
x
.
uid
!=
0
]
uid_list
=
[
x
.
uid
for
x
in
method
(
count
=
UID_BUFFER_SIZE
,
instance_id
=
instance_id
)
if
x
.
uid
!=
0
]
uid_buffer
.
extend
(
uid_list
)
uid_buffer
.
extend
(
uid_list
)
security
.
declarePrivate
(
'isIndexable'
)
def
isIndexable
(
self
):
def
isIndexable
(
self
):
"""
"""
This is required to check in many methods that
This is required to check in many methods that
...
@@ -1247,6 +1269,7 @@ class Catalog(Folder,
...
@@ -1247,6 +1269,7 @@ class Catalog(Folder,
return
False
return
False
return
True
return
True
security
.
declarePrivate
(
'getSiteRoot'
)
def
getSiteRoot
(
self
):
def
getSiteRoot
(
self
):
"""
"""
Returns the root of the site
Returns the root of the site
...
@@ -1257,6 +1280,7 @@ class Catalog(Folder,
...
@@ -1257,6 +1280,7 @@ class Catalog(Folder,
site_root
=
self
.
aq_parent
site_root
=
self
.
aq_parent
return
site_root
return
site_root
security
.
declarePrivate
(
'getZopeRoot'
)
def
getZopeRoot
(
self
):
def
getZopeRoot
(
self
):
"""
"""
Returns the root of the zope
Returns the root of the zope
...
@@ -1267,6 +1291,7 @@ class Catalog(Folder,
...
@@ -1267,6 +1291,7 @@ class Catalog(Folder,
zope_root
=
self
.
getPhysicalRoot
()
zope_root
=
self
.
getPhysicalRoot
()
return
zope_root
return
zope_root
security
.
declarePrivate
(
'newUid'
)
def
newUid
(
self
):
def
newUid
(
self
):
"""
"""
This is where uid generation takes place. We should consider a multi-threaded environment
This is where uid generation takes place. We should consider a multi-threaded environment
...
@@ -1306,6 +1331,7 @@ class Catalog(Folder,
...
@@ -1306,6 +1331,7 @@ class Catalog(Folder,
finally
:
finally
:
klass
.
_reserved_uid_lock
.
release
()
klass
.
_reserved_uid_lock
.
release
()
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogObject'
)
def
manage_catalogObject
(
self
,
REQUEST
,
RESPONSE
,
URL1
,
urls
=
None
):
def
manage_catalogObject
(
self
,
REQUEST
,
RESPONSE
,
URL1
,
urls
=
None
):
""" index Zope object(s) that 'urls' point to """
""" index Zope object(s) that 'urls' point to """
if
urls
:
if
urls
:
...
@@ -1321,6 +1347,7 @@ class Catalog(Folder,
...
@@ -1321,6 +1347,7 @@ class Catalog(Folder,
RESPONSE
.
redirect
(
URL1
+
'/manage_catalogView?manage_tabs_message=Object%20Cataloged'
)
RESPONSE
.
redirect
(
URL1
+
'/manage_catalogView?manage_tabs_message=Object%20Cataloged'
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_uncatalogObject'
)
def
manage_uncatalogObject
(
self
,
REQUEST
,
RESPONSE
,
URL1
,
urls
=
None
):
def
manage_uncatalogObject
(
self
,
REQUEST
,
RESPONSE
,
URL1
,
urls
=
None
):
""" removes Zope object(s) 'urls' from catalog """
""" removes Zope object(s) 'urls' from catalog """
...
@@ -1333,6 +1360,7 @@ class Catalog(Folder,
...
@@ -1333,6 +1360,7 @@ class Catalog(Folder,
RESPONSE
.
redirect
(
URL1
+
'/manage_catalogView?manage_tabs_message=Object%20Uncataloged'
)
RESPONSE
.
redirect
(
URL1
+
'/manage_catalogView?manage_tabs_message=Object%20Uncataloged'
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogReindex'
)
def
manage_catalogReindex
(
self
,
REQUEST
,
RESPONSE
,
URL1
,
urls
=
None
):
def
manage_catalogReindex
(
self
,
REQUEST
,
RESPONSE
,
URL1
,
urls
=
None
):
""" clear the catalog, then re-index everything """
""" clear the catalog, then re-index everything """
elapse
=
time
.
time
()
elapse
=
time
.
time
()
...
@@ -1349,25 +1377,28 @@ class Catalog(Folder,
...
@@ -1349,25 +1377,28 @@ class Catalog(Folder,
'Total time: %s<br>'
'Total time: %s<br>'
'Total CPU time: %s'
%
(
`elapse`
,
`c_elapse`
)))
'Total CPU time: %s'
%
(
`elapse`
,
`c_elapse`
)))
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogClear'
)
def
manage_catalogClear
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
def
manage_catalogClear
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
,
sql_catalog_id
=
None
):
URL1
=
None
,
sql_catalog_id
=
None
):
""" clears the whole enchilada """
""" clears the whole enchilada """
self
.
beforeCatalogClear
()
self
.
beforeCatalogClear
()
self
.
clear
()
self
.
_
clear
()
if
RESPONSE
and
URL1
:
if
RESPONSE
and
URL1
:
RESPONSE
.
redirect
(
'%s/manage_catalogAdvanced?'
\
RESPONSE
.
redirect
(
'%s/manage_catalogAdvanced?'
\
'manage_tabs_message=Catalog%%20Cleared'
%
URL1
)
'manage_tabs_message=Catalog%%20Cleared'
%
URL1
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogClearReserved'
)
def
manage_catalogClearReserved
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
def
manage_catalogClearReserved
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
""" clears reserved uids """
""" clears reserved uids """
self
.
clearReserved
()
self
.
_
clearReserved
()
if
RESPONSE
and
URL1
:
if
RESPONSE
and
URL1
:
RESPONSE
.
redirect
(
'%s/manage_catalogAdvanced?'
\
RESPONSE
.
redirect
(
'%s/manage_catalogAdvanced?'
\
'manage_tabs_message=Catalog%%20Cleared'
%
URL1
)
'manage_tabs_message=Catalog%%20Cleared'
%
URL1
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogFoundItems'
)
def
manage_catalogFoundItems
(
self
,
REQUEST
,
RESPONSE
,
URL2
,
URL1
,
def
manage_catalogFoundItems
(
self
,
REQUEST
,
RESPONSE
,
URL2
,
URL1
,
obj_metatypes
=
None
,
obj_metatypes
=
None
,
obj_ids
=
None
,
obj_searchterm
=
None
,
obj_ids
=
None
,
obj_searchterm
=
None
,
...
@@ -1404,6 +1435,7 @@ class Catalog(Folder,
...
@@ -1404,6 +1435,7 @@ class Catalog(Folder,
RESPONSE
.
redirect
(
URL1
+
'/manage_catalogView?manage_tabs_message='
+
RESPONSE
.
redirect
(
URL1
+
'/manage_catalogView?manage_tabs_message='
+
urllib
.
quote
(
'Catalog Updated<br>Total time: %s<br>Total CPU time: %s'
%
(
`elapse`
,
`c_elapse`
)))
urllib
.
quote
(
'Catalog Updated<br>Total time: %s<br>Total CPU time: %s'
%
(
`elapse`
,
`c_elapse`
)))
security
.
declarePrivate
(
'catalogObject'
)
def
catalogObject
(
self
,
object
,
path
,
is_object_moved
=
0
):
def
catalogObject
(
self
,
object
,
path
,
is_object_moved
=
0
):
"""Add an object to the Catalog by calling all SQL methods and
"""Add an object to the Catalog by calling all SQL methods and
providing needed arguments.
providing needed arguments.
...
@@ -1411,6 +1443,7 @@ class Catalog(Folder,
...
@@ -1411,6 +1443,7 @@ class Catalog(Folder,
'object' is the object to be catalogged."""
'object' is the object to be catalogged."""
self
.
_catalogObjectList
([
object
])
self
.
_catalogObjectList
([
object
])
security
.
declarePrivate
(
'catalogObjectList'
)
def
catalogObjectList
(
self
,
object_list
,
method_id_list
=
None
,
def
catalogObjectList
(
self
,
object_list
,
method_id_list
=
None
,
disable_cache
=
0
,
check_uid
=
1
,
idxs
=
None
):
disable_cache
=
0
,
check_uid
=
1
,
idxs
=
None
):
"""Add objects to the Catalog by calling all SQL methods and
"""Add objects to the Catalog by calling all SQL methods and
...
@@ -1696,6 +1729,7 @@ class Catalog(Folder,
...
@@ -1696,6 +1729,7 @@ class Catalog(Folder,
if
psyco
is
not
None
:
if
psyco
is
not
None
:
psyco
.
bind
(
_catalogObjectList
)
psyco
.
bind
(
_catalogObjectList
)
security
.
declarePrivate
(
'beforeUncatalogObject'
)
def
beforeUncatalogObject
(
self
,
path
=
None
,
uid
=
None
):
def
beforeUncatalogObject
(
self
,
path
=
None
,
uid
=
None
):
"""
"""
Set the path as deleted
Set the path as deleted
...
@@ -1716,6 +1750,7 @@ class Catalog(Folder,
...
@@ -1716,6 +1750,7 @@ class Catalog(Folder,
method
=
getattr
(
self
,
method_name
)
method
=
getattr
(
self
,
method_name
)
method
(
uid
=
uid
)
method
(
uid
=
uid
)
security
.
declarePrivate
(
'uncatalogObject'
)
def
uncatalogObject
(
self
,
path
=
None
,
uid
=
None
):
def
uncatalogObject
(
self
,
path
=
None
,
uid
=
None
):
"""
"""
Uncatalog and object from the Catalog.
Uncatalog and object from the Catalog.
...
@@ -1743,6 +1778,7 @@ class Catalog(Folder,
...
@@ -1743,6 +1778,7 @@ class Catalog(Folder,
method
=
getattr
(
self
,
method_name
)
method
=
getattr
(
self
,
method_name
)
method
(
uid
=
uid
)
method
(
uid
=
uid
)
security
.
declarePrivate
(
'catalogTranslationList'
)
def
catalogTranslationList
(
self
,
object_list
):
def
catalogTranslationList
(
self
,
object_list
):
"""Catalog translations.
"""Catalog translations.
"""
"""
...
@@ -1750,6 +1786,7 @@ class Catalog(Folder,
...
@@ -1750,6 +1786,7 @@ class Catalog(Folder,
return
self
.
catalogObjectList
(
object_list
,
method_id_list
=
(
method_name
,),
return
self
.
catalogObjectList
(
object_list
,
method_id_list
=
(
method_name
,),
check_uid
=
0
)
check_uid
=
0
)
security
.
declarePrivate
(
'deleteTranslationList'
)
def
deleteTranslationList
(
self
):
def
deleteTranslationList
(
self
):
"""Delete translations.
"""Delete translations.
"""
"""
...
@@ -1762,16 +1799,19 @@ class Catalog(Folder,
...
@@ -1762,16 +1799,19 @@ class Catalog(Folder,
except
:
except
:
LOG
(
'SQLCatalog'
,
WARNING
,
'could not delete translations'
,
error
=
sys
.
exc_info
())
LOG
(
'SQLCatalog'
,
WARNING
,
'could not delete translations'
,
error
=
sys
.
exc_info
())
security
.
declarePrivate
(
'uniqueValuesFor'
)
def
uniqueValuesFor
(
self
,
name
):
def
uniqueValuesFor
(
self
,
name
):
""" return unique values for FieldIndex name """
""" return unique values for FieldIndex name """
method
=
getattr
(
self
,
self
.
sql_unique_values
)
method
=
getattr
(
self
,
self
.
sql_unique_values
)
return
method
(
column
=
name
)
return
method
(
column
=
name
)
security
.
declarePrivate
(
'getPaths'
)
def
getPaths
(
self
):
def
getPaths
(
self
):
""" Returns all object paths stored inside catalog """
""" Returns all object paths stored inside catalog """
method
=
getattr
(
self
,
self
.
sql_catalog_paths
)
method
=
getattr
(
self
,
self
.
sql_catalog_paths
)
return
method
()
return
method
()
security
.
declarePrivate
(
'getUidForPath'
)
def
getUidForPath
(
self
,
path
):
def
getUidForPath
(
self
,
path
):
""" Looks up into catalog table to convert path into uid """
""" Looks up into catalog table to convert path into uid """
#try:
#try:
...
@@ -1786,6 +1826,7 @@ class Catalog(Folder,
...
@@ -1786,6 +1826,7 @@ class Catalog(Folder,
else
:
else
:
return
None
return
None
security
.
declarePrivate
(
'getUidDictForPathList'
)
def
getUidDictForPathList
(
self
,
path_list
):
def
getUidDictForPathList
(
self
,
path_list
):
""" Looks up into catalog table to convert path into uid """
""" Looks up into catalog table to convert path into uid """
# Get the appropriate SQL Method
# Get the appropriate SQL Method
...
@@ -1807,6 +1848,7 @@ class Catalog(Folder,
...
@@ -1807,6 +1848,7 @@ class Catalog(Folder,
path_uid_dict
[
path
]
=
search_result
[
0
].
uid
path_uid_dict
[
path
]
=
search_result
[
0
].
uid
return
path_uid_dict
return
path_uid_dict
security
.
declarePrivate
(
'getPathDictForUidList'
)
def
getPathDictForUidList
(
self
,
uid_list
):
def
getPathDictForUidList
(
self
,
uid_list
):
""" Looks up into catalog table to convert uid into path """
""" Looks up into catalog table to convert uid into path """
# Get the appropriate SQL Method
# Get the appropriate SQL Method
...
@@ -1828,10 +1870,12 @@ class Catalog(Folder,
...
@@ -1828,10 +1870,12 @@ class Catalog(Folder,
uid_path_dict
[
uid
]
=
search_result
[
0
].
path
uid_path_dict
[
uid
]
=
search_result
[
0
].
path
return
uid_path_dict
return
uid_path_dict
security
.
declarePrivate
(
'hasPath'
)
def
hasPath
(
self
,
path
):
def
hasPath
(
self
,
path
):
""" Checks if path is catalogued """
""" Checks if path is catalogued """
return
self
.
getUidForPath
(
path
)
is
not
None
return
self
.
getUidForPath
(
path
)
is
not
None
security
.
declarePrivate
(
'getPathForUid'
)
def
getPathForUid
(
self
,
uid
):
def
getPathForUid
(
self
,
uid
):
""" Looks up into catalog table to convert uid into path """
""" Looks up into catalog table to convert uid into path """
try
:
try
:
...
@@ -1857,6 +1901,7 @@ class Catalog(Folder,
...
@@ -1857,6 +1901,7 @@ class Catalog(Folder,
LOG
(
'SQLCatalog'
,
WARNING
,
"could not find path from uid %s"
%
(
uid
,))
LOG
(
'SQLCatalog'
,
WARNING
,
"could not find path from uid %s"
%
(
uid
,))
return
None
return
None
security
.
declarePrivate
(
'getMetadataForUid'
)
def
getMetadataForUid
(
self
,
uid
):
def
getMetadataForUid
(
self
,
uid
):
""" Accesses a single record for a given uid """
""" Accesses a single record for a given uid """
if
uid
is
None
:
if
uid
is
None
:
...
@@ -1869,10 +1914,12 @@ class Catalog(Folder,
...
@@ -1869,10 +1914,12 @@ class Catalog(Folder,
result
[
k
]
=
getattr
(
brain
,
k
)
result
[
k
]
=
getattr
(
brain
,
k
)
return
result
return
result
security
.
declarePrivate
(
'getIndexDataForUid'
)
def
getIndexDataForUid
(
self
,
uid
):
def
getIndexDataForUid
(
self
,
uid
):
""" Accesses a single record for a given uid """
""" Accesses a single record for a given uid """
return
self
.
getMetadataForUid
(
uid
)
return
self
.
getMetadataForUid
(
uid
)
security
.
declarePrivate
(
'getMetadataForPath'
)
def
getMetadataForPath
(
self
,
path
):
def
getMetadataForPath
(
self
,
path
):
""" Accesses a single record for a given path """
""" Accesses a single record for a given path """
try
:
try
:
...
@@ -1892,10 +1939,12 @@ class Catalog(Folder,
...
@@ -1892,10 +1939,12 @@ class Catalog(Folder,
"could not find metadata from path %s"
%
(
path
,))
"could not find metadata from path %s"
%
(
path
,))
return
None
return
None
security
.
declarePrivate
(
'getIndexDataForPath'
)
def
getIndexDataForPath
(
self
,
path
):
def
getIndexDataForPath
(
self
,
path
):
""" Accesses a single record for a given path """
""" Accesses a single record for a given path """
return
self
.
getMetadataForPath
(
path
)
return
self
.
getMetadataForPath
(
path
)
security
.
declarePrivate
(
'getCatalogMethodIds'
)
def
getCatalogMethodIds
(
self
,
def
getCatalogMethodIds
(
self
,
valid_method_meta_type_list
=
valid_method_meta_type_list
):
valid_method_meta_type_list
=
valid_method_meta_type_list
):
"""Find Z SQL methods in the current folder and above
"""Find Z SQL methods in the current folder and above
...
@@ -1922,6 +1971,7 @@ class Catalog(Folder,
...
@@ -1922,6 +1971,7 @@ class Catalog(Folder,
ids
.
sort
()
ids
.
sort
()
return
ids
return
ids
security
.
declarePrivate
(
'getPythonMethodIds'
)
def
getPythonMethodIds
(
self
):
def
getPythonMethodIds
(
self
):
"""
"""
Returns a list of all python scripts available in
Returns a list of all python scripts available in
...
@@ -1949,6 +1999,7 @@ class Catalog(Folder,
...
@@ -1949,6 +1999,7 @@ class Catalog(Folder,
column_set
.
add
(
related_key_id
)
column_set
.
add
(
related_key_id
)
return
column_set
return
column_set
security
.
declarePrivate
(
'getSQLCatalogRelatedKeyList'
)
def
getSQLCatalogRelatedKeyList
(
self
,
key_list
=
None
):
def
getSQLCatalogRelatedKeyList
(
self
,
key_list
=
None
):
"""
"""
Return the list of related keys.
Return the list of related keys.
...
@@ -1966,6 +2017,7 @@ class Catalog(Folder,
...
@@ -1966,6 +2017,7 @@ class Catalog(Folder,
# Compatibililty SQL Sql
# Compatibililty SQL Sql
getSqlCatalogRelatedKeyList
=
getSQLCatalogRelatedKeyList
getSqlCatalogRelatedKeyList
=
getSQLCatalogRelatedKeyList
security
.
declarePrivate
(
'getSQLCatalogScriptableKeyList'
)
def
getSQLCatalogScriptableKeyList
(
self
):
def
getSQLCatalogScriptableKeyList
(
self
):
"""
"""
Return the list of scriptable keys.
Return the list of scriptable keys.
...
@@ -1989,12 +2041,14 @@ class Catalog(Folder,
...
@@ -1989,12 +2041,14 @@ class Catalog(Folder,
table_index
[
line
.
KEY_NAME
]
=
[
line
.
COLUMN_NAME
,]
table_index
[
line
.
KEY_NAME
]
=
[
line
.
COLUMN_NAME
,]
return
table_index
return
table_index
security
.
declarePrivate
(
'getTableIndex'
)
def
getTableIndex
(
self
,
table
):
def
getTableIndex
(
self
,
table
):
"""
"""
Return a map between index and column for a given table
Return a map between index and column for a given table
"""
"""
return
self
.
_getTableIndex
(
table
).
copy
()
return
self
.
_getTableIndex
(
table
).
copy
()
security
.
declareProtected
(
access_contents_information
,
'isValidColumn'
)
def
isValidColumn
(
self
,
column_id
):
def
isValidColumn
(
self
,
column_id
):
"""
"""
Tells wether given name is or not an existing column.
Tells wether given name is or not an existing column.
...
@@ -2009,6 +2063,7 @@ class Catalog(Folder,
...
@@ -2009,6 +2063,7 @@ class Catalog(Folder,
result
=
self
.
getRelatedKeyDefinition
(
column_id
)
is
not
None
result
=
self
.
getRelatedKeyDefinition
(
column_id
)
is
not
None
return
result
return
result
security
.
declarePrivate
(
'getRelatedKeyDefinition'
)
def
getRelatedKeyDefinition
(
self
,
key
):
def
getRelatedKeyDefinition
(
self
,
key
):
"""
"""
Returns the definition of given related key name if found, None
Returns the definition of given related key name if found, None
...
@@ -2049,9 +2104,11 @@ class Catalog(Folder,
...
@@ -2049,9 +2104,11 @@ class Catalog(Folder,
result
[
key
]
=
script
result
[
key
]
=
script
return
result
return
result
security
.
declarePrivate
(
'getScriptableKeyScript'
)
def
getScriptableKeyScript
(
self
,
key
):
def
getScriptableKeyScript
(
self
,
key
):
return
self
.
_getgetScriptableKeyDict
().
get
(
key
)
return
self
.
_getgetScriptableKeyDict
().
get
(
key
)
security
.
declarePrivate
(
'getColumnSearchKey'
)
def
getColumnSearchKey
(
self
,
key
,
search_key_name
=
None
):
def
getColumnSearchKey
(
self
,
key
,
search_key_name
=
None
):
"""
"""
Return a SearchKey instance for given key, using search_key_name
Return a SearchKey instance for given key, using search_key_name
...
@@ -2077,9 +2134,11 @@ class Catalog(Folder,
...
@@ -2077,9 +2134,11 @@ class Catalog(Folder,
search_key
=
self
.
getSearchKey
(
key
,
'RelatedKey'
)
search_key
=
self
.
getSearchKey
(
key
,
'RelatedKey'
)
return
search_key
,
related_key_definition
return
search_key
,
related_key_definition
security
.
declarePrivate
(
'hasColumn'
)
def
hasColumn
(
self
,
column
):
def
hasColumn
(
self
,
column
):
return
self
.
getColumnSearchKey
(
column
)[
0
]
is
not
None
return
self
.
getColumnSearchKey
(
column
)[
0
]
is
not
None
security
.
declarePrivate
(
'getColumnDefaultSearchKey'
)
def
getColumnDefaultSearchKey
(
self
,
key
,
search_key_name
=
None
):
def
getColumnDefaultSearchKey
(
self
,
key
,
search_key_name
=
None
):
"""
"""
Return a SearchKey instance which would ultimately receive the value
Return a SearchKey instance which would ultimately receive the value
...
@@ -2095,6 +2154,7 @@ class Catalog(Folder,
...
@@ -2095,6 +2154,7 @@ class Catalog(Folder,
related_key_definition
=
related_key_definition
)
related_key_definition
=
related_key_definition
)
return
search_key
return
search_key
security
.
declareProtected
(
access_contents_information
,
'buildSingleQuery'
)
def
buildSingleQuery
(
self
,
key
,
value
,
search_key_name
=
None
,
logical_operator
=
None
,
comparison_operator
=
None
):
def
buildSingleQuery
(
self
,
key
,
value
,
search_key_name
=
None
,
logical_operator
=
None
,
comparison_operator
=
None
):
"""
"""
From key and value, determine the SearchKey to use and generate a Query
From key and value, determine the SearchKey to use and generate a Query
...
@@ -2178,6 +2238,7 @@ class Catalog(Folder,
...
@@ -2178,6 +2238,7 @@ class Catalog(Folder,
result
=
None
result
=
None
return
result
return
result
security
.
declareProtected
(
access_contents_information
,
'buildQueryFromAbstractSyntaxTreeNode'
)
def
buildQueryFromAbstractSyntaxTreeNode
(
self
,
node
,
key
,
wrap
=
lambda
x
:
x
,
ignore_unknown_columns
=
False
):
def
buildQueryFromAbstractSyntaxTreeNode
(
self
,
node
,
key
,
wrap
=
lambda
x
:
x
,
ignore_unknown_columns
=
False
):
"""
"""
Build a query from given Abstract Syntax Tree (AST) node by recursing in
Build a query from given Abstract Syntax Tree (AST) node by recursing in
...
@@ -2223,6 +2284,7 @@ class Catalog(Folder,
...
@@ -2223,6 +2284,7 @@ class Catalog(Folder,
is_valid
=
self
.
isValidColumn
is_valid
=
self
.
isValidColumn
return
search_key
.
parseSearchText
(
search_text
,
is_valid
)
return
search_key
.
parseSearchText
(
search_text
,
is_valid
)
security
.
declareProtected
(
access_contents_information
,
'parseSearchText'
)
def
parseSearchText
(
self
,
search_text
,
column
=
None
,
search_key
=
None
,
def
parseSearchText
(
self
,
search_text
,
column
=
None
,
search_key
=
None
,
is_valid
=
None
):
is_valid
=
None
):
if
column
is
None
and
search_key
is
None
:
if
column
is
None
and
search_key
is
None
:
...
@@ -2231,6 +2293,7 @@ class Catalog(Folder,
...
@@ -2231,6 +2293,7 @@ class Catalog(Folder,
return
self
.
_parseSearchText
(
self
.
getSearchKey
(
return
self
.
_parseSearchText
(
self
.
getSearchKey
(
column
,
search_key
=
search_key
),
search_text
,
is_valid
=
is_valid
)
column
,
search_key
=
search_key
),
search_text
,
is_valid
=
is_valid
)
security
.
declareProtected
(
access_contents_information
,
'buildQuery'
)
def
buildQuery
(
self
,
kw
,
ignore_empty_string
=
True
,
operator
=
'and'
,
ignore_unknown_columns
=
False
):
def
buildQuery
(
self
,
kw
,
ignore_empty_string
=
True
,
operator
=
'and'
,
ignore_unknown_columns
=
False
):
query_list
=
[]
query_list
=
[]
append
=
query_list
.
append
append
=
query_list
.
append
...
@@ -2324,6 +2387,7 @@ class Catalog(Folder,
...
@@ -2324,6 +2387,7 @@ class Catalog(Folder,
return
ComplexQuery
(
query_list
,
logical_operator
=
operator
,
return
ComplexQuery
(
query_list
,
logical_operator
=
operator
,
unknown_column_dict
=
unknown_column_dict
)
unknown_column_dict
=
unknown_column_dict
)
security
.
declarePrivate
(
'buildOrderByList'
)
def
buildOrderByList
(
self
,
sort_on
=
None
,
sort_order
=
None
,
order_by_expression
=
None
):
def
buildOrderByList
(
self
,
sort_on
=
None
,
sort_order
=
None
,
order_by_expression
=
None
):
"""
"""
Internal method. Should not be used by code outside buildSQLQuery.
Internal method. Should not be used by code outside buildSQLQuery.
...
@@ -2373,6 +2437,7 @@ class Catalog(Folder,
...
@@ -2373,6 +2437,7 @@ class Catalog(Folder,
append
([
x
])
append
([
x
])
return
order_by_list
return
order_by_list
security
.
declarePrivate
(
'buildEntireQuery'
)
def
buildEntireQuery
(
self
,
kw
,
query_table
=
'catalog'
,
ignore_empty_string
=
1
,
def
buildEntireQuery
(
self
,
kw
,
query_table
=
'catalog'
,
ignore_empty_string
=
1
,
limit
=
None
,
extra_column_list
=
(),
limit
=
None
,
extra_column_list
=
(),
ignore_unknown_columns
=
False
):
ignore_unknown_columns
=
False
):
...
@@ -2414,6 +2479,7 @@ class Catalog(Folder,
...
@@ -2414,6 +2479,7 @@ class Catalog(Folder,
extra_column_list
=
extra_column_list
,
extra_column_list
=
extra_column_list
,
from_expression
=
from_expression
)
from_expression
=
from_expression
)
security
.
declarePrivate
(
'buildSQLQuery'
)
def
buildSQLQuery
(
self
,
query_table
=
'catalog'
,
REQUEST
=
None
,
def
buildSQLQuery
(
self
,
query_table
=
'catalog'
,
REQUEST
=
None
,
ignore_empty_string
=
1
,
only_group_columns
=
False
,
ignore_empty_string
=
1
,
only_group_columns
=
False
,
limit
=
None
,
extra_column_list
=
(),
limit
=
None
,
extra_column_list
=
(),
...
@@ -2434,7 +2500,7 @@ class Catalog(Folder,
...
@@ -2434,7 +2500,7 @@ class Catalog(Folder,
# Compatibililty SQL Sql
# Compatibililty SQL Sql
buildSqlQuery
=
buildSQLQuery
buildSqlQuery
=
buildSQLQuery
security
.
declareP
ublic
(
'getCannonicalArgumentDict'
)
security
.
declareP
rotected
(
access_contents_information
,
'getCannonicalArgumentDict'
)
def
getCannonicalArgumentDict
(
self
,
kw
):
def
getCannonicalArgumentDict
(
self
,
kw
):
"""
"""
Convert some catalog arguments to generic arguments.
Convert some catalog arguments to generic arguments.
...
@@ -2518,6 +2584,7 @@ class Catalog(Folder,
...
@@ -2518,6 +2584,7 @@ class Catalog(Folder,
LOG
(
'SQLCatalog'
,
WARNING
,
'Wrong configuration for sql_catalog_search_keys: %r'
%
line
)
LOG
(
'SQLCatalog'
,
WARNING
,
'Wrong configuration for sql_catalog_search_keys: %r'
%
line
)
return
result
return
result
security
.
declarePrivate
(
'getSearchKey'
)
def
getSearchKey
(
self
,
column
,
search_key
=
None
):
def
getSearchKey
(
self
,
column
,
search_key
=
None
):
"""
"""
Return an instance of a SearchKey class.
Return an instance of a SearchKey class.
...
@@ -2533,6 +2600,7 @@ class Catalog(Folder,
...
@@ -2533,6 +2600,7 @@ class Catalog(Folder,
search_key
=
self
.
_getSearchKeyDict
().
get
(
column
,
'DefaultKey'
)
search_key
=
self
.
_getSearchKeyDict
().
get
(
column
,
'DefaultKey'
)
return
getSearchKeyInstance
(
search_key
,
column
)
return
getSearchKeyInstance
(
search_key
,
column
)
security
.
declarePrivate
(
'getComparisonOperator'
)
def
getComparisonOperator
(
self
,
operator
):
def
getComparisonOperator
(
self
,
operator
):
"""
"""
Return an instance of an Operator class.
Return an instance of an Operator class.
...
@@ -2544,6 +2612,7 @@ class Catalog(Folder,
...
@@ -2544,6 +2612,7 @@ class Catalog(Folder,
return
getComparisonOperatorInstance
(
operator
)
return
getComparisonOperatorInstance
(
operator
)
security
.
declarePrivate
(
'queryResults'
)
def
queryResults
(
def
queryResults
(
self
,
self
,
sql_method
,
sql_method
,
...
@@ -2578,9 +2647,11 @@ class Catalog(Folder,
...
@@ -2578,9 +2647,11 @@ class Catalog(Folder,
limit_expression
=
query
[
'limit_expression'
],
limit_expression
=
query
[
'limit_expression'
],
)
)
security
.
declarePrivate
(
'getSearchResultsMethod'
)
def
getSearchResultsMethod
(
self
):
def
getSearchResultsMethod
(
self
):
return
getattr
(
self
,
self
.
sql_search_results
)
return
getattr
(
self
,
self
.
sql_search_results
)
security
.
declarePrivate
(
'searchResults'
)
def
searchResults
(
self
,
REQUEST
=
None
,
**
kw
):
def
searchResults
(
self
,
REQUEST
=
None
,
**
kw
):
""" Returns a list of brains from a set of constraints on variables """
""" Returns a list of brains from a set of constraints on variables """
if
'only_group_columns'
in
kw
:
if
'only_group_columns'
in
kw
:
...
@@ -2596,9 +2667,11 @@ class Catalog(Folder,
...
@@ -2596,9 +2667,11 @@ class Catalog(Folder,
__call__
=
searchResults
__call__
=
searchResults
security
.
declarePrivate
(
'getCountResultsMethod'
)
def
getCountResultsMethod
(
self
):
def
getCountResultsMethod
(
self
):
return
getattr
(
self
,
self
.
sql_count_results
)
return
getattr
(
self
,
self
.
sql_count_results
)
security
.
declarePrivate
(
'countResults'
)
def
countResults
(
self
,
REQUEST
=
None
,
**
kw
):
def
countResults
(
self
,
REQUEST
=
None
,
**
kw
):
""" Returns the number of items which satisfy the where_expression """
""" Returns the number of items which satisfy the where_expression """
return
self
.
queryResults
(
return
self
.
queryResults
(
...
@@ -2609,9 +2682,11 @@ class Catalog(Folder,
...
@@ -2609,9 +2682,11 @@ class Catalog(Folder,
**
kw
**
kw
)
)
security
.
declarePrivate
(
'isAdvancedSearchText'
)
def
isAdvancedSearchText
(
self
,
search_text
):
def
isAdvancedSearchText
(
self
,
search_text
):
return
isAdvancedSearchText
(
search_text
,
self
.
isValidColumn
)
return
isAdvancedSearchText
(
search_text
,
self
.
isValidColumn
)
security
.
declarePrivate
(
'recordObjectList'
)
def
recordObjectList
(
self
,
path_list
,
catalog
=
1
):
def
recordObjectList
(
self
,
path_list
,
catalog
=
1
):
"""
"""
Record the path of an object being catalogged or uncatalogged.
Record the path of an object being catalogged or uncatalogged.
...
@@ -2619,6 +2694,7 @@ class Catalog(Folder,
...
@@ -2619,6 +2694,7 @@ class Catalog(Folder,
method
=
getattr
(
self
,
self
.
sql_record_object_list
)
method
=
getattr
(
self
,
self
.
sql_record_object_list
)
method
(
path_list
=
path_list
,
catalog
=
catalog
)
method
(
path_list
=
path_list
,
catalog
=
catalog
)
security
.
declarePrivate
(
'deleteRecordedObjectList'
)
def
deleteRecordedObjectList
(
self
,
uid_list
=
()):
def
deleteRecordedObjectList
(
self
,
uid_list
=
()):
"""
"""
Delete all objects which contain any path.
Delete all objects which contain any path.
...
@@ -2626,6 +2702,7 @@ class Catalog(Folder,
...
@@ -2626,6 +2702,7 @@ class Catalog(Folder,
method
=
getattr
(
self
,
self
.
sql_delete_recorded_object_list
)
method
=
getattr
(
self
,
self
.
sql_delete_recorded_object_list
)
method
(
uid_list
=
uid_list
)
method
(
uid_list
=
uid_list
)
security
.
declarePrivate
(
'readRecordedObjectList'
)
def
readRecordedObjectList
(
self
,
catalog
=
1
):
def
readRecordedObjectList
(
self
,
catalog
=
1
):
"""
"""
Read objects. Note that this might not return all objects since ZMySQLDA limits the max rows.
Read objects. Note that this might not return all objects since ZMySQLDA limits the max rows.
...
@@ -2634,6 +2711,7 @@ class Catalog(Folder,
...
@@ -2634,6 +2711,7 @@ class Catalog(Folder,
return
method
(
catalog
=
catalog
)
return
method
(
catalog
=
catalog
)
# Filtering
# Filtering
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_editFilter'
)
def
manage_editFilter
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
def
manage_editFilter
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
):
"""
"""
This methods allows to set a filter on each zsql method called,
This methods allows to set a filter on each zsql method called,
...
@@ -2679,6 +2757,7 @@ class Catalog(Folder,
...
@@ -2679,6 +2757,7 @@ class Catalog(Folder,
if
RESPONSE
and
URL1
:
if
RESPONSE
and
URL1
:
RESPONSE
.
redirect
(
URL1
+
'/manage_catalogFilter?manage_tabs_message=Filter%20Changed'
)
RESPONSE
.
redirect
(
URL1
+
'/manage_catalogFilter?manage_tabs_message=Filter%20Changed'
)
security
.
declarePrivate
(
'isMethodFiltered'
)
def
isMethodFiltered
(
self
,
method_name
):
def
isMethodFiltered
(
self
,
method_name
):
"""
"""
Returns 1 if the method is already filtered,
Returns 1 if the method is already filtered,
...
@@ -2695,6 +2774,7 @@ class Catalog(Folder,
...
@@ -2695,6 +2774,7 @@ class Catalog(Folder,
return
0
return
0
return
0
return
0
security
.
declarePrivate
(
'getExpression'
)
def
getExpression
(
self
,
method_name
):
def
getExpression
(
self
,
method_name
):
""" Get the filter expression text for this method.
""" Get the filter expression text for this method.
"""
"""
...
@@ -2708,6 +2788,7 @@ class Catalog(Folder,
...
@@ -2708,6 +2788,7 @@ class Catalog(Folder,
return
""
return
""
return
""
return
""
security
.
declarePrivate
(
'getExpressionCacheKey'
)
def
getExpressionCacheKey
(
self
,
method_name
):
def
getExpressionCacheKey
(
self
,
method_name
):
""" Get the key string which is used to cache results
""" Get the key string which is used to cache results
for the given expression.
for the given expression.
...
@@ -2722,6 +2803,7 @@ class Catalog(Folder,
...
@@ -2722,6 +2803,7 @@ class Catalog(Folder,
return
""
return
""
return
""
return
""
security
.
declarePrivate
(
'getExpressionInstance'
)
def
getExpressionInstance
(
self
,
method_name
):
def
getExpressionInstance
(
self
,
method_name
):
""" Get the filter expression instance for this method.
""" Get the filter expression instance for this method.
"""
"""
...
@@ -2735,6 +2817,7 @@ class Catalog(Folder,
...
@@ -2735,6 +2817,7 @@ class Catalog(Folder,
return
None
return
None
return
None
return
None
security
.
declarePrivate
(
'setFilterExpression'
)
def
setFilterExpression
(
self
,
method_name
,
expression
):
def
setFilterExpression
(
self
,
method_name
,
expression
):
""" Set the Expression for a certain method name. This allow set
""" Set the Expression for a certain method name. This allow set
expressions by scripts.
expressions by scripts.
...
@@ -2749,6 +2832,7 @@ class Catalog(Folder,
...
@@ -2749,6 +2832,7 @@ class Catalog(Folder,
else
:
else
:
self
.
filter_dict
[
method_name
][
'expression_instance'
]
=
None
self
.
filter_dict
[
method_name
][
'expression_instance'
]
=
None
security
.
declarePrivate
(
'isPortalTypeSelected'
)
def
isPortalTypeSelected
(
self
,
method_name
,
portal_type
):
def
isPortalTypeSelected
(
self
,
method_name
,
portal_type
):
""" Returns true if the portal type is selected for this method.
""" Returns true if the portal type is selected for this method.
XXX deprecated
XXX deprecated
...
@@ -2763,6 +2847,7 @@ class Catalog(Folder,
...
@@ -2763,6 +2847,7 @@ class Catalog(Folder,
return
0
return
0
return
0
return
0
security
.
declarePrivate
(
'getFilteredPortalTypeList'
)
def
getFilteredPortalTypeList
(
self
,
method_name
):
def
getFilteredPortalTypeList
(
self
,
method_name
):
""" Returns the list of portal types which define
""" Returns the list of portal types which define
the filter.
the filter.
...
@@ -2778,6 +2863,7 @@ class Catalog(Folder,
...
@@ -2778,6 +2863,7 @@ class Catalog(Folder,
return
[]
return
[]
return
[]
return
[]
security
.
declarePrivate
(
'getFilterDict'
)
def
getFilterDict
(
self
):
def
getFilterDict
(
self
):
"""
"""
Utility Method.
Utility Method.
...
@@ -2797,6 +2883,7 @@ class Catalog(Folder,
...
@@ -2797,6 +2883,7 @@ class Catalog(Folder,
return
filter_dict
return
filter_dict
return
None
return
None
security
.
declarePrivate
(
'getFilterableMethodList'
)
def
getFilterableMethodList
(
self
):
def
getFilterableMethodList
(
self
):
"""
"""
Returns only zsql methods wich catalog or uncatalog objets
Returns only zsql methods wich catalog or uncatalog objets
...
@@ -2812,6 +2899,7 @@ class Catalog(Folder,
...
@@ -2812,6 +2899,7 @@ class Catalog(Folder,
method_list
=
map
(
lambda
method_id
:
getattr
(
self
,
method_id
,
None
),
method_dict
.
keys
())
method_list
=
map
(
lambda
method_id
:
getattr
(
self
,
method_id
,
None
),
method_dict
.
keys
())
return
filter
(
lambda
method
:
method
is
not
None
,
method_list
)
return
filter
(
lambda
method
:
method
is
not
None
,
method_list
)
security
.
declarePrivate
(
'getExpressionContext'
)
def
getExpressionContext
(
self
,
ob
):
def
getExpressionContext
(
self
,
ob
):
'''
'''
An expression context provides names for TALES expressions.
An expression context provides names for TALES expressions.
...
...
product/ZSQLCatalog/ZSQLCatalog.py
View file @
0aa35a8c
...
@@ -24,6 +24,7 @@ from Persistence import Persistent
...
@@ -24,6 +24,7 @@ from Persistence import Persistent
from
DocumentTemplate.DT_Util
import
InstanceDict
,
TemplateDict
from
DocumentTemplate.DT_Util
import
InstanceDict
,
TemplateDict
from
DocumentTemplate.DT_Util
import
Eval
from
DocumentTemplate.DT_Util
import
Eval
from
AccessControl.Permission
import
name_trans
from
AccessControl.Permission
import
name_trans
from
AccessControl.Permissions
import
manage_zcatalog_entries
from
SQLCatalog
import
CatalogError
from
SQLCatalog
import
CatalogError
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
DocumentTemplate.security
import
RestrictedDTML
from
DocumentTemplate.security
import
RestrictedDTML
...
@@ -206,9 +207,11 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -206,9 +207,11 @@ class ZCatalog(Folder, Persistent, Implicit):
self
.
id
=
id
self
.
id
=
id
self
.
title
=
title
self
.
title
=
title
security
.
declarePrivate
(
'getSQLCatalogIdList'
)
def
getSQLCatalogIdList
(
self
):
def
getSQLCatalogIdList
(
self
):
return
self
.
objectIds
(
spec
=
(
'SQLCatalog'
,))
return
self
.
objectIds
(
spec
=
(
'SQLCatalog'
,))
security
.
declarePublic
(
'getSQLCatalog'
)
def
getSQLCatalog
(
self
,
id
=
None
,
default_value
=
None
):
def
getSQLCatalog
(
self
,
id
=
None
,
default_value
=
None
):
"""
"""
Get the default SQL Catalog.
Get the default SQL Catalog.
...
@@ -224,6 +227,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -224,6 +227,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return
self
.
_getOb
(
id
,
default_value
)
return
self
.
_getOb
(
id
,
default_value
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogExportProperties'
)
def
manage_catalogExportProperties
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
sql_catalog_id
=
None
):
def
manage_catalogExportProperties
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
sql_catalog_id
=
None
):
"""
"""
Export properties to an XML file.
Export properties to an XML file.
...
@@ -232,6 +236,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -232,6 +236,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
catalog
is
not
None
:
if
catalog
is
not
None
:
return
catalog
.
manage_exportProperties
(
REQUEST
=
REQUEST
,
RESPONSE
=
RESPONSE
)
return
catalog
.
manage_exportProperties
(
REQUEST
=
REQUEST
,
RESPONSE
=
RESPONSE
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogImportProperties'
)
def
manage_catalogImportProperties
(
self
,
file
,
sql_catalog_id
=
None
):
def
manage_catalogImportProperties
(
self
,
file
,
sql_catalog_id
=
None
):
"""
"""
Import properties from an XML file.
Import properties from an XML file.
...
@@ -246,6 +251,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -246,6 +251,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return
0
return
0
return
len
(
catalog
)
return
len
(
catalog
)
security
.
declarePrivate
(
'getHotReindexingState'
)
def
getHotReindexingState
(
self
):
def
getHotReindexingState
(
self
):
"""
"""
Return the current hot reindexing state.
Return the current hot reindexing state.
...
@@ -255,14 +261,14 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -255,14 +261,14 @@ class ZCatalog(Folder, Persistent, Implicit):
return
HOT_REINDEXING_FINISHED_STATE
return
HOT_REINDEXING_FINISHED_STATE
return
value
return
value
def
setHotReindexingState
(
self
,
state
=
''
,
source_sql_catalog_id
=
None
,
destination_sql_catalog_id
=
None
,
archive_path
=
None
):
def
_
setHotReindexingState
(
self
,
state
=
''
,
source_sql_catalog_id
=
None
,
destination_sql_catalog_id
=
None
,
archive_path
=
None
):
"""
"""
Set the state of hot reindexing.
Set the state of hot reindexing.
Do not use setProperty because the state should not modified from the ZMI directly.
Do not use setProperty because the state should not modified from the ZMI directly.
It must be maintained very carefully.
It must be maintained very carefully.
"""
"""
#LOG("setHotReindexingState call", 300, state)
#LOG("
_
setHotReindexingState call", 300, state)
if
source_sql_catalog_id
is
None
:
if
source_sql_catalog_id
is
None
:
source_sql_catalog_id
=
self
.
default_sql_catalog_id
source_sql_catalog_id
=
self
.
default_sql_catalog_id
...
@@ -280,7 +286,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -280,7 +286,7 @@ class ZCatalog(Folder, Persistent, Implicit):
else
:
else
:
raise
CatalogError
,
'unknown hot reindexing state %s'
%
state
raise
CatalogError
,
'unknown hot reindexing state %s'
%
state
def
finishHotReindexing
(
self
,
source_sql_catalog_id
,
def
_
finishHotReindexing
(
self
,
source_sql_catalog_id
,
destination_sql_catalog_id
,
skin_selection_dict
,
destination_sql_catalog_id
,
skin_selection_dict
,
sql_connection_id_dict
):
sql_connection_id_dict
):
"""
"""
...
@@ -292,16 +298,17 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -292,16 +298,17 @@ class ZCatalog(Folder, Persistent, Implicit):
else
:
else
:
current_archive
=
None
current_archive
=
None
default_catalog_id
=
self
.
default_sql_catalog_id
default_catalog_id
=
self
.
default_sql_catalog_id
self
.
exchangeDatabases
(
source_sql_catalog_id
=
source_sql_catalog_id
,
self
.
_
exchangeDatabases
(
source_sql_catalog_id
=
source_sql_catalog_id
,
destination_sql_catalog_id
=
destination_sql_catalog_id
,
destination_sql_catalog_id
=
destination_sql_catalog_id
,
skin_selection_dict
=
skin_selection_dict
,
skin_selection_dict
=
skin_selection_dict
,
sql_connection_id_dict
=
sql_connection_id_dict
)
sql_connection_id_dict
=
sql_connection_id_dict
)
# cancel archive use as current catalog before archiving
# cancel archive use as current catalog before archiving
if
current_archive
is
not
None
:
if
current_archive
is
not
None
:
current_archive
.
cancel
()
current_archive
.
cancel
()
self
.
setHotReindexingState
(
state
=
HOT_REINDEXING_FINISHED_STATE
)
self
.
_
setHotReindexingState
(
state
=
HOT_REINDEXING_FINISHED_STATE
)
clearCache
(
cache_factory_list
=
(
'erp5_content_short'
,))
clearCache
(
cache_factory_list
=
(
'erp5_content_short'
,))
security
.
declarePrivate
(
'cancelHotReindexing'
)
def
cancelHotReindexing
(
self
):
def
cancelHotReindexing
(
self
):
"""
"""
Cancel a hot reindexing.
Cancel a hot reindexing.
...
@@ -314,18 +321,19 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -314,18 +321,19 @@ class ZCatalog(Folder, Persistent, Implicit):
raise
Exception
,
'cancelHotReindexing called while no Hot Reindexing '
\
raise
Exception
,
'cancelHotReindexing called while no Hot Reindexing '
\
'was runing. Nothing done.'
'was runing. Nothing done.'
# Remove hot reindexing state
# Remove hot reindexing state
self
.
setHotReindexingState
(
HOT_REINDEXING_FINISHED_STATE
)
self
.
_
setHotReindexingState
(
HOT_REINDEXING_FINISHED_STATE
)
portal_activities
=
getToolByName
(
self
,
'portal_activities'
)
portal_activities
=
getToolByName
(
self
,
'portal_activities'
)
if
portal_activities
is
not
None
:
if
portal_activities
is
not
None
:
object_path
=
self
.
getPhysicalPath
()
object_path
=
self
.
getPhysicalPath
()
# Activities must be removed in the reverse order they were inserted
# Activities must be removed in the reverse order they were inserted
# to make sure removing one does not accidntaly trigger the next one.
# to make sure removing one does not accidntaly trigger the next one.
method_id_list
=
(
'finishHotReindexing'
,
'runInventoryMethod'
,
method_id_list
=
(
'
_
finishHotReindexing'
,
'runInventoryMethod'
,
'playBackRecordedObjectList'
,
'InventoryModule_reindexMovementList'
'playBackRecordedObjectList'
,
'InventoryModule_reindexMovementList'
'setHotReindexingState'
)
'
_
setHotReindexingState'
)
for
method_id
in
method_id_list
:
for
method_id
in
method_id_list
:
portal_activities
.
flush
(
object_path
,
method_id
=
method_id
)
portal_activities
.
flush
(
object_path
,
method_id
=
method_id
)
security
.
declarePrivate
(
'playBackRecordedObjectList'
)
def
playBackRecordedObjectList
(
self
,
sql_catalog_id
,
catalog
=
0
):
def
playBackRecordedObjectList
(
self
,
sql_catalog_id
,
catalog
=
0
):
"""
"""
Play back the actions scheduled while hot reindexing was in "record"
Play back the actions scheduled while hot reindexing was in "record"
...
@@ -371,6 +379,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -371,6 +379,7 @@ class ZCatalog(Folder, Persistent, Implicit):
catalog
=
1
)
catalog
=
1
)
# If we were replaying index actions, there is nothing else to do.
# If we were replaying index actions, there is nothing else to do.
security
.
declarePrivate
(
'changeSQLConnectionIds'
)
def
changeSQLConnectionIds
(
self
,
folder
,
sql_connection_id_dict
):
def
changeSQLConnectionIds
(
self
,
folder
,
sql_connection_id_dict
):
if
sql_connection_id_dict
is
not
None
:
if
sql_connection_id_dict
is
not
None
:
if
folder
.
meta_type
==
'Z SQL Method'
:
if
folder
.
meta_type
==
'Z SQL Method'
:
...
@@ -381,7 +390,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -381,7 +390,7 @@ class ZCatalog(Folder, Persistent, Implicit):
for
object
in
folder
.
objectValues
():
for
object
in
folder
.
objectValues
():
self
.
changeSQLConnectionIds
(
object
,
sql_connection_id_dict
)
self
.
changeSQLConnectionIds
(
object
,
sql_connection_id_dict
)
def
exchangeDatabases
(
self
,
source_sql_catalog_id
,
destination_sql_catalog_id
,
def
_
exchangeDatabases
(
self
,
source_sql_catalog_id
,
destination_sql_catalog_id
,
skin_selection_dict
,
sql_connection_id_dict
):
skin_selection_dict
,
sql_connection_id_dict
):
"""
"""
Exchange two databases.
Exchange two databases.
...
@@ -395,18 +404,19 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -395,18 +404,19 @@ class ZCatalog(Folder, Persistent, Implicit):
# generated uids since destination catalog was created.
# generated uids since destination catalog was created.
self
[
destination_sql_catalog_id
].
insertMaxUid
()
self
[
destination_sql_catalog_id
].
insertMaxUid
()
LOG
(
'exchangeDatabases skin_selection_dict:'
,
0
,
skin_selection_dict
)
LOG
(
'
_
exchangeDatabases skin_selection_dict:'
,
0
,
skin_selection_dict
)
if
skin_selection_dict
is
not
None
:
if
skin_selection_dict
is
not
None
:
#LOG('exchangeDatabases skin_selection_dict:',0,'we will do manage_skinLayers')
#LOG('
_
exchangeDatabases skin_selection_dict:',0,'we will do manage_skinLayers')
for
skin_name
,
selection
in
self
.
portal_skins
.
getSkinPaths
():
for
skin_name
,
selection
in
self
.
portal_skins
.
getSkinPaths
():
if
skin_name
in
skin_selection_dict
:
if
skin_name
in
skin_selection_dict
:
new_selection
=
tuple
(
skin_selection_dict
[
skin_name
])
new_selection
=
tuple
(
skin_selection_dict
[
skin_name
])
self
.
portal_skins
.
manage_skinLayers
(
skinpath
=
new_selection
,
skinname
=
skin_name
,
add_skin
=
1
)
self
.
portal_skins
.
manage_skinLayers
(
skinpath
=
new_selection
,
skinname
=
skin_name
,
add_skin
=
1
)
LOG
(
'exchangeDatabases sql_connection_id_dict :'
,
0
,
sql_connection_id_dict
)
LOG
(
'
_
exchangeDatabases sql_connection_id_dict :'
,
0
,
sql_connection_id_dict
)
if
sql_connection_id_dict
is
not
None
:
if
sql_connection_id_dict
is
not
None
:
self
.
changeSQLConnectionIds
(
self
.
portal_skins
,
sql_connection_id_dict
)
self
.
changeSQLConnectionIds
(
self
.
portal_skins
,
sql_connection_id_dict
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_hotReindexAll'
)
def
manage_hotReindexAll
(
self
,
source_sql_catalog_id
,
def
manage_hotReindexAll
(
self
,
source_sql_catalog_id
,
destination_sql_catalog_id
,
destination_sql_catalog_id
,
archive_path
=
None
,
archive_path
=
None
,
...
@@ -505,7 +515,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -505,7 +515,7 @@ class ZCatalog(Folder, Persistent, Implicit):
# Mark the hot reindex as begun. Each object indexed in the still-current
# Mark the hot reindex as begun. Each object indexed in the still-current
# catalog will be scheduled for reindex in the future catalog.
# catalog will be scheduled for reindex in the future catalog.
LOG
(
'hotReindexObjectList'
,
0
,
'Starting recording'
)
LOG
(
'hotReindexObjectList'
,
0
,
'Starting recording'
)
self
.
setHotReindexingState
(
HOT_REINDEXING_RECORDING_STATE
,
self
.
_
setHotReindexingState
(
HOT_REINDEXING_RECORDING_STATE
,
source_sql_catalog_id
=
source_sql_catalog_id
,
source_sql_catalog_id
=
source_sql_catalog_id
,
destination_sql_catalog_id
=
destination_sql_catalog_id
,
destination_sql_catalog_id
=
destination_sql_catalog_id
,
archive_path
=
archive_path
)
archive_path
=
archive_path
)
...
@@ -518,12 +528,12 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -518,12 +528,12 @@ class ZCatalog(Folder, Persistent, Implicit):
# Once reindexing is finished, change the hot reindexing state so that
# Once reindexing is finished, change the hot reindexing state so that
# new catalog changes are applied in both catalogs.
# new catalog changes are applied in both catalogs.
self
.
activate
(
after_tag
=
final_activity_tag
,
self
.
activate
(
after_tag
=
final_activity_tag
,
priority
=
base_priority
).
setHotReindexingState
(
HOT_REINDEXING_DOUBLE_INDEXING_STATE
,
priority
=
base_priority
).
_
setHotReindexingState
(
HOT_REINDEXING_DOUBLE_INDEXING_STATE
,
source_sql_catalog_id
=
source_sql_catalog_id
,
source_sql_catalog_id
=
source_sql_catalog_id
,
destination_sql_catalog_id
=
destination_sql_catalog_id
,
destination_sql_catalog_id
=
destination_sql_catalog_id
,
archive_path
=
archive_path
)
archive_path
=
archive_path
)
# Once in double-indexing mode, planned reindex can be replayed.
# Once in double-indexing mode, planned reindex can be replayed.
self
.
activate
(
after_method_id
=
'setHotReindexingState'
,
self
.
activate
(
after_method_id
=
'
_
setHotReindexingState'
,
priority
=
base_priority
).
playBackRecordedObjectList
(
priority
=
base_priority
).
playBackRecordedObjectList
(
sql_catalog_id
=
destination_sql_catalog_id
)
sql_catalog_id
=
destination_sql_catalog_id
)
# Once there is nothing to replay, databases are sync'ed, so the new
# Once there is nothing to replay, databases are sync'ed, so the new
...
@@ -531,7 +541,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -531,7 +541,7 @@ class ZCatalog(Folder, Persistent, Implicit):
self
.
activate
(
after_method_id
=
(
'playBackRecordedObjectList'
,
self
.
activate
(
after_method_id
=
(
'playBackRecordedObjectList'
,
'InventoryModule_reindexMovementList'
),
'InventoryModule_reindexMovementList'
),
after_tag
=
'InventoryModule_reindexMovementList'
,
after_tag
=
'InventoryModule_reindexMovementList'
,
priority
=
base_priority
).
finishHotReindexing
(
priority
=
base_priority
).
_
finishHotReindexing
(
source_sql_catalog_id
=
source_sql_catalog_id
,
source_sql_catalog_id
=
source_sql_catalog_id
,
destination_sql_catalog_id
=
destination_sql_catalog_id
,
destination_sql_catalog_id
=
destination_sql_catalog_id
,
skin_selection_dict
=
skin_selection_dict
,
skin_selection_dict
=
skin_selection_dict
,
...
@@ -540,6 +550,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -540,6 +550,7 @@ class ZCatalog(Folder, Persistent, Implicit):
URL1
=
REQUEST
.
get
(
'URL1'
)
URL1
=
REQUEST
.
get
(
'URL1'
)
RESPONSE
.
redirect
(
URL1
+
'/manage_catalogHotReindexing?manage_tabs_message=HotReindexing%20Started'
)
RESPONSE
.
redirect
(
URL1
+
'/manage_catalogHotReindexing?manage_tabs_message=HotReindexing%20Started'
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_edit'
)
def
manage_edit
(
self
,
RESPONSE
,
URL1
,
threshold
=
1000
,
REQUEST
=
None
):
def
manage_edit
(
self
,
RESPONSE
,
URL1
,
threshold
=
1000
,
REQUEST
=
None
):
""" edit the catalog """
""" edit the catalog """
if
type
(
threshold
)
is
not
type
(
1
):
if
type
(
threshold
)
is
not
type
(
1
):
...
@@ -549,6 +560,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -549,6 +560,7 @@ class ZCatalog(Folder, Persistent, Implicit):
RESPONSE
.
redirect
(
URL1
+
'/manage_main?manage_tabs_message=Catalog%20Changed'
)
RESPONSE
.
redirect
(
URL1
+
'/manage_main?manage_tabs_message=Catalog%20Changed'
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogObject'
)
def
manage_catalogObject
(
self
,
REQUEST
,
RESPONSE
,
URL1
,
urls
=
None
,
sql_catalog_id
=
None
):
def
manage_catalogObject
(
self
,
REQUEST
,
RESPONSE
,
URL1
,
urls
=
None
,
sql_catalog_id
=
None
):
""" index Zope object(s) that 'urls' point to """
""" index Zope object(s) that 'urls' point to """
if
sql_catalog_id
is
None
:
if
sql_catalog_id
is
None
:
...
@@ -559,6 +571,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -559,6 +571,7 @@ class ZCatalog(Folder, Persistent, Implicit):
catalog
.
manage_catalogObject
(
REQUEST
,
RESPONSE
,
URL1
,
urls
=
urls
)
catalog
.
manage_catalogObject
(
REQUEST
,
RESPONSE
,
URL1
,
urls
=
urls
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_uncatalogObject'
)
def
manage_uncatalogObject
(
self
,
REQUEST
,
RESPONSE
,
URL1
,
urls
=
None
,
sql_catalog_id
=
None
):
def
manage_uncatalogObject
(
self
,
REQUEST
,
RESPONSE
,
URL1
,
urls
=
None
,
sql_catalog_id
=
None
):
""" removes Zope object(s) 'urls' from catalog """
""" removes Zope object(s) 'urls' from catalog """
if
sql_catalog_id
is
None
:
if
sql_catalog_id
is
None
:
...
@@ -569,6 +582,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -569,6 +582,7 @@ class ZCatalog(Folder, Persistent, Implicit):
catalog
.
manage_uncatalogObject
(
REQUEST
,
RESPONSE
,
URL1
,
urls
=
urls
)
catalog
.
manage_uncatalogObject
(
REQUEST
,
RESPONSE
,
URL1
,
urls
=
urls
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogReindex'
)
def
manage_catalogReindex
(
self
,
REQUEST
,
RESPONSE
,
URL1
,
urls
=
None
,
sql_catalog_id
=
None
):
def
manage_catalogReindex
(
self
,
REQUEST
,
RESPONSE
,
URL1
,
urls
=
None
,
sql_catalog_id
=
None
):
""" clear the catalog, then re-index everything """
""" clear the catalog, then re-index everything """
if
sql_catalog_id
is
None
:
if
sql_catalog_id
is
None
:
...
@@ -578,6 +592,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -578,6 +592,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
catalog
is
not
None
:
if
catalog
is
not
None
:
catalog
.
manage_catalogReindex
(
REQUEST
,
RESPONSE
,
URL1
,
urls
=
urls
)
catalog
.
manage_catalogReindex
(
REQUEST
,
RESPONSE
,
URL1
,
urls
=
urls
)
security
.
declarePrivate
(
'refreshCatalog'
)
def
refreshCatalog
(
self
,
clear
=
0
,
sql_catalog_id
=
None
):
def
refreshCatalog
(
self
,
clear
=
0
,
sql_catalog_id
=
None
):
""" re-index everything we can find """
""" re-index everything we can find """
...
@@ -585,7 +600,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -585,7 +600,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
catalog
is
not
None
:
if
catalog
is
not
None
:
paths
=
catalog
.
getPaths
()
paths
=
catalog
.
getPaths
()
if
clear
:
if
clear
:
catalog
.
clear
()
catalog
.
_
clear
()
for
p
in
paths
:
for
p
in
paths
:
obj
=
self
.
resolve_path
(
p
.
path
)
obj
=
self
.
resolve_path
(
p
.
path
)
...
@@ -594,6 +609,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -594,6 +609,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
obj
is
not
None
:
if
obj
is
not
None
:
self
.
catalog_object
(
obj
,
p
.
path
,
sql_catalog_id
=
sql_catalog_id
)
self
.
catalog_object
(
obj
,
p
.
path
,
sql_catalog_id
=
sql_catalog_id
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogClear'
)
def
manage_catalogClear
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
,
sql_catalog_id
=
None
):
def
manage_catalogClear
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
,
sql_catalog_id
=
None
):
""" clears the whole enchilada """
""" clears the whole enchilada """
if
REQUEST
is
not
None
and
sql_catalog_id
is
None
:
if
REQUEST
is
not
None
and
sql_catalog_id
is
None
:
...
@@ -603,6 +619,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -603,6 +619,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
catalog
is
not
None
:
if
catalog
is
not
None
:
catalog
.
manage_catalogClear
(
REQUEST
=
REQUEST
,
RESPONSE
=
RESPONSE
,
URL1
=
URL1
)
catalog
.
manage_catalogClear
(
REQUEST
=
REQUEST
,
RESPONSE
=
RESPONSE
,
URL1
=
URL1
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogClearReserved'
)
def
manage_catalogClearReserved
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
,
sql_catalog_id
=
None
):
def
manage_catalogClearReserved
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
,
sql_catalog_id
=
None
):
""" clears the whole enchilada """
""" clears the whole enchilada """
if
REQUEST
is
not
None
and
sql_catalog_id
is
None
:
if
REQUEST
is
not
None
and
sql_catalog_id
is
None
:
...
@@ -612,6 +629,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -612,6 +629,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
catalog
is
not
None
:
if
catalog
is
not
None
:
catalog
.
manage_catalogClearReserved
(
REQUEST
=
REQUEST
,
RESPONSE
=
RESPONSE
,
URL1
=
URL1
)
catalog
.
manage_catalogClearReserved
(
REQUEST
=
REQUEST
,
RESPONSE
=
RESPONSE
,
URL1
=
URL1
)
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_catalogFoundItems'
)
def
manage_catalogFoundItems
(
self
,
REQUEST
,
RESPONSE
,
URL2
,
URL1
,
def
manage_catalogFoundItems
(
self
,
REQUEST
,
RESPONSE
,
URL2
,
URL1
,
obj_metatypes
=
None
,
obj_metatypes
=
None
,
obj_ids
=
None
,
obj_searchterm
=
None
,
obj_ids
=
None
,
obj_searchterm
=
None
,
...
@@ -661,6 +679,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -661,6 +679,7 @@ class ZCatalog(Folder, Persistent, Implicit):
RESPONSE
.
redirect
(
URL1
+
'/manage_catalogView?manage_tabs_message='
+
RESPONSE
.
redirect
(
URL1
+
'/manage_catalogView?manage_tabs_message='
+
urllib
.
quote
(
'Catalog Updated<br>Total time: %s<br>Total CPU time: %s'
%
(
`elapse`
,
`c_elapse`
)))
urllib
.
quote
(
'Catalog Updated<br>Total time: %s<br>Total CPU time: %s'
%
(
`elapse`
,
`c_elapse`
)))
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_editSchema'
)
def
manage_editSchema
(
self
,
names
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
,
sql_catalog_id
=
None
):
def
manage_editSchema
(
self
,
names
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
,
sql_catalog_id
=
None
):
""" add a column """
""" add a column """
if
REQUEST
is
not
None
and
sql_catalog_id
is
None
:
if
REQUEST
is
not
None
and
sql_catalog_id
is
None
:
...
@@ -671,6 +690,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -671,6 +690,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
REQUEST
and
RESPONSE
:
if
REQUEST
and
RESPONSE
:
RESPONSE
.
redirect
(
URL1
+
'/manage_catalogSchema?manage_tabs_message=Schema%20Saved'
)
RESPONSE
.
redirect
(
URL1
+
'/manage_catalogSchema?manage_tabs_message=Schema%20Saved'
)
security
.
declarePrivate
(
'newUid'
)
def
newUid
(
self
,
sql_catalog_id
=
None
):
def
newUid
(
self
,
sql_catalog_id
=
None
):
"""
"""
Allocates a new uid value.
Allocates a new uid value.
...
@@ -679,12 +699,14 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -679,12 +699,14 @@ class ZCatalog(Folder, Persistent, Implicit):
if
catalog
is
not
None
:
if
catalog
is
not
None
:
return
catalog
.
newUid
()
return
catalog
.
newUid
()
security
.
declarePrivate
(
'getDynamicRelatedKeyList'
)
def
getDynamicRelatedKeyList
(
self
,
sql_catalog_id
=
None
,
**
kw
):
def
getDynamicRelatedKeyList
(
self
,
sql_catalog_id
=
None
,
**
kw
):
"""
"""
Return the list of dynamic related keys.
Return the list of dynamic related keys.
"""
"""
return
[]
return
[]
security
.
declarePrivate
(
'wrapObject'
)
def
wrapObject
(
self
,
object
,
**
kw
):
def
wrapObject
(
self
,
object
,
**
kw
):
"""
"""
Return a wrapped object for reindexing.
Return a wrapped object for reindexing.
...
@@ -694,10 +716,12 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -694,10 +716,12 @@ class ZCatalog(Folder, Persistent, Implicit):
#LOG('ZSQLCatalog wrapObject', 0, 'object = %r, kw = %r' % (object, kw))
#LOG('ZSQLCatalog wrapObject', 0, 'object = %r, kw = %r' % (object, kw))
return
object
return
object
security
.
declarePrivate
(
'catalog_object'
)
def
catalog_object
(
self
,
obj
,
url
=
None
,
idxs
=
[],
is_object_moved
=
0
,
sql_catalog_id
=
None
,
**
kw
):
def
catalog_object
(
self
,
obj
,
url
=
None
,
idxs
=
[],
is_object_moved
=
0
,
sql_catalog_id
=
None
,
**
kw
):
""" wrapper around catalog """
""" wrapper around catalog """
self
.
catalogObjectList
([
obj
],
sql_catalog_id
=
sql_catalog_id
)
self
.
catalogObjectList
([
obj
],
sql_catalog_id
=
sql_catalog_id
)
security
.
declarePrivate
(
'catalogObjectList'
)
def
catalogObjectList
(
self
,
object_list
,
sql_catalog_id
=
None
,
disable_archive
=
0
,
def
catalogObjectList
(
self
,
object_list
,
sql_catalog_id
=
None
,
disable_archive
=
0
,
immediate_reindex_archive
=
1
,
**
kw
):
immediate_reindex_archive
=
1
,
**
kw
):
"""Catalog a list of objects.
"""Catalog a list of objects.
...
@@ -842,6 +866,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -842,6 +866,7 @@ class ZCatalog(Folder, Persistent, Implicit):
object_list
[:]
=
failed_object_list
object_list
[:]
=
failed_object_list
security
.
declarePrivate
(
'uncatalog_object'
)
def
uncatalog_object
(
self
,
uid
=
None
,
path
=
None
,
sql_catalog_id
=
None
):
def
uncatalog_object
(
self
,
uid
=
None
,
path
=
None
,
sql_catalog_id
=
None
):
""" wrapper around catalog """
""" wrapper around catalog """
if
uid
is
None
:
if
uid
is
None
:
...
@@ -879,16 +904,19 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -879,16 +904,19 @@ class ZCatalog(Folder, Persistent, Implicit):
destination_catalog
.
uncatalogObject
(
uid
=
uid
)
destination_catalog
.
uncatalogObject
(
uid
=
uid
)
security
.
declarePrivate
(
'beforeUncatalogObject'
)
def
beforeUncatalogObject
(
self
,
uid
=
None
,
path
=
None
,
sql_catalog_id
=
None
):
def
beforeUncatalogObject
(
self
,
uid
=
None
,
path
=
None
,
sql_catalog_id
=
None
):
""" wrapper around catalog """
""" wrapper around catalog """
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
if
catalog
is
not
None
:
if
catalog
is
not
None
:
catalog
.
beforeUncatalogObject
(
uid
=
uid
,
path
=
path
)
catalog
.
beforeUncatalogObject
(
uid
=
uid
,
path
=
path
)
security
.
declarePrivate
(
'beforeCatalogClear'
)
def
beforeCatalogClear
(
self
):
def
beforeCatalogClear
(
self
):
""" allow to override this method """
""" allow to override this method """
pass
pass
security
.
declarePrivate
(
'catalogTranslationList'
)
def
catalogTranslationList
(
self
,
object_list
,
sql_catalog_id
=
None
):
def
catalogTranslationList
(
self
,
object_list
,
sql_catalog_id
=
None
):
"""Catalog translations.
"""Catalog translations.
"""
"""
...
@@ -896,6 +924,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -896,6 +924,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
catalog
is
not
None
:
if
catalog
is
not
None
:
catalog
.
catalogTranslationList
(
object_list
)
catalog
.
catalogTranslationList
(
object_list
)
security
.
declarePrivate
(
'deleteTranslationList'
)
def
deleteTranslationList
(
self
,
sql_catalog_id
=
None
):
def
deleteTranslationList
(
self
,
sql_catalog_id
=
None
):
"""Delete translations.
"""Delete translations.
"""
"""
...
@@ -903,6 +932,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -903,6 +932,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
catalog
is
not
None
:
if
catalog
is
not
None
:
catalog
.
deleteTranslationList
()
catalog
.
deleteTranslationList
()
security
.
declarePrivate
(
'uniqueValuesFor'
)
def
uniqueValuesFor
(
self
,
name
,
sql_catalog_id
=
None
):
def
uniqueValuesFor
(
self
,
name
,
sql_catalog_id
=
None
):
""" returns the unique values for a given FieldIndex """
""" returns the unique values for a given FieldIndex """
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
...
@@ -911,6 +941,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -911,6 +941,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return
()
return
()
security
.
declarePrivate
(
'getpath'
)
def
getpath
(
self
,
uid
,
sql_catalog_id
=
None
):
def
getpath
(
self
,
uid
,
sql_catalog_id
=
None
):
"""
"""
Return the path to a cataloged object given its uid
Return the path to a cataloged object given its uid
...
@@ -924,6 +955,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -924,6 +955,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return
None
return
None
getPath
=
getpath
getPath
=
getpath
security
.
declarePrivate
(
'hasPath'
)
def
hasPath
(
self
,
path
,
sql_catalog_id
=
None
):
def
hasPath
(
self
,
path
,
sql_catalog_id
=
None
):
"""
"""
Checks if path is catalogued
Checks if path is catalogued
...
@@ -932,6 +964,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -932,6 +964,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
catalog
is
not
None
:
if
catalog
is
not
None
:
return
catalog
.
hasPath
(
path
)
return
catalog
.
hasPath
(
path
)
security
.
declarePrivate
(
'getobject'
)
def
getobject
(
self
,
uid
,
REQUEST
=
None
,
sql_catalog_id
=
None
):
def
getobject
(
self
,
uid
,
REQUEST
=
None
,
sql_catalog_id
=
None
):
"""
"""
Return a cataloged object given its uid
Return a cataloged object given its uid
...
@@ -948,6 +981,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -948,6 +981,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return
obj
return
obj
getObject
=
getobject
getObject
=
getobject
security
.
declarePrivate
(
'getObjectList'
)
def
getObjectList
(
self
,
uid_list
,
REQUEST
=
None
,
sql_catalog_id
=
None
):
def
getObjectList
(
self
,
uid_list
,
REQUEST
=
None
,
sql_catalog_id
=
None
):
"""
"""
Return a cataloged object given its uid
Return a cataloged object given its uid
...
@@ -957,6 +991,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -957,6 +991,7 @@ class ZCatalog(Folder, Persistent, Implicit):
obj_list
.
append
(
self
.
getObject
(
uid
,
REQUEST
,
sql_catalog_id
=
sql_catalog_id
))
obj_list
.
append
(
self
.
getObject
(
uid
,
REQUEST
,
sql_catalog_id
=
sql_catalog_id
))
return
obj_list
return
obj_list
security
.
declarePrivate
(
'getMetadataForUid'
)
def
getMetadataForUid
(
self
,
rid
,
sql_catalog_id
=
None
):
def
getMetadataForUid
(
self
,
rid
,
sql_catalog_id
=
None
):
# !!! do not use docstring here (CVE-2011-0720).
# !!! do not use docstring here (CVE-2011-0720).
# return the correct metadata for the cataloged uid
# return the correct metadata for the cataloged uid
...
@@ -965,6 +1000,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -965,6 +1000,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return
catalog
.
getMetadataForUid
(
int
(
rid
))
return
catalog
.
getMetadataForUid
(
int
(
rid
))
return
{}
return
{}
security
.
declarePrivate
(
'getIndexDataForUid'
)
def
getIndexDataForUid
(
self
,
rid
,
sql_catalog_id
=
None
):
def
getIndexDataForUid
(
self
,
rid
,
sql_catalog_id
=
None
):
# !!! do not use docstring here (CVE-2011-0720).
# !!! do not use docstring here (CVE-2011-0720).
# return the current index contents for the specific uid
# return the current index contents for the specific uid
...
@@ -977,30 +1013,36 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -977,30 +1013,36 @@ class ZCatalog(Folder, Persistent, Implicit):
getMetadataForRID
=
getMetadataForUid
getMetadataForRID
=
getMetadataForUid
getIndexDataForRID
=
getIndexDataForUid
getIndexDataForRID
=
getIndexDataForUid
security
.
declarePrivate
(
'schema'
)
def
schema
(
self
,
sql_catalog_id
=
None
):
def
schema
(
self
,
sql_catalog_id
=
None
):
return
self
.
getColumnIds
(
sql_catalog_id
=
sql_catalog_id
)
return
self
.
getColumnIds
(
sql_catalog_id
=
sql_catalog_id
)
security
.
declarePrivate
(
'indexes'
)
def
indexes
(
self
,
sql_catalog_id
=
None
):
def
indexes
(
self
,
sql_catalog_id
=
None
):
return
self
.
getColumnIds
(
sql_catalog_id
=
sql_catalog_id
)
return
self
.
getColumnIds
(
sql_catalog_id
=
sql_catalog_id
)
security
.
declarePrivate
(
'names'
)
def
names
(
self
,
sql_catalog_id
=
None
):
def
names
(
self
,
sql_catalog_id
=
None
):
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
if
catalog
is
not
None
:
if
catalog
is
not
None
:
return
catalog
.
names
return
catalog
.
names
return
{}
return
{}
security
.
declarePrivate
(
'getColumnIds'
)
def
getColumnIds
(
self
,
sql_catalog_id
=
None
):
def
getColumnIds
(
self
,
sql_catalog_id
=
None
):
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
if
catalog
is
not
None
:
if
catalog
is
not
None
:
return
catalog
.
getColumnIds
()
return
catalog
.
getColumnIds
()
return
[]
return
[]
security
.
declarePublic
(
'hasColumn'
)
def
hasColumn
(
self
,
column
,
sql_catalog_id
=
None
):
def
hasColumn
(
self
,
column
,
sql_catalog_id
=
None
):
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
if
catalog
is
not
None
:
if
catalog
is
not
None
:
return
catalog
.
hasColumn
(
column
)
return
catalog
.
hasColumn
(
column
)
return
False
return
False
security
.
declarePrivate
(
'getAttributesForColumn'
)
def
getAttributesForColumn
(
self
,
column
,
sql_catalog_id
=
None
):
def
getAttributesForColumn
(
self
,
column
,
sql_catalog_id
=
None
):
"""
"""
Return the attribute names as a single string
Return the attribute names as a single string
...
@@ -1013,6 +1055,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -1013,6 +1055,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return
catalog
.
getColumnIds
(
sql_catalog_id
=
sql_catalog_id
)
return
catalog
.
getColumnIds
(
sql_catalog_id
=
sql_catalog_id
)
return
[]
return
[]
security
.
declarePrivate
(
'editSchema'
)
def
editSchema
(
self
,
names
,
sql_catalog_id
=
None
):
def
editSchema
(
self
,
names
,
sql_catalog_id
=
None
):
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
if
catalog
is
not
None
:
if
catalog
is
not
None
:
...
@@ -1050,6 +1093,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -1050,6 +1093,7 @@ class ZCatalog(Folder, Persistent, Implicit):
security
.
declarePublic
(
'buildSqlQuery'
)
security
.
declarePublic
(
'buildSqlQuery'
)
buildSqlQuery
=
buildSQLQuery
buildSqlQuery
=
buildSQLQuery
security
.
declarePublic
(
'searchResults'
)
def
searchResults
(
self
,
REQUEST
=
None
,
sql_catalog_id
=
None
,
**
kw
):
def
searchResults
(
self
,
REQUEST
=
None
,
sql_catalog_id
=
None
,
**
kw
):
"""
"""
Search the catalog according to the ZTables search interface.
Search the catalog according to the ZTables search interface.
...
@@ -1063,6 +1107,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -1063,6 +1107,7 @@ class ZCatalog(Folder, Persistent, Implicit):
__call__
=
searchResults
__call__
=
searchResults
security
.
declarePublic
(
'countResults'
)
def
countResults
(
self
,
REQUEST
=
None
,
sql_catalog_id
=
None
,
**
kw
):
def
countResults
(
self
,
REQUEST
=
None
,
sql_catalog_id
=
None
,
**
kw
):
"""
"""
Counts the number of items which satisfy the query defined in kw.
Counts the number of items which satisfy the query defined in kw.
...
@@ -1076,6 +1121,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -1076,6 +1121,7 @@ class ZCatalog(Folder, Persistent, Implicit):
meta_types
=
()
# Sub-object types that are specific to this object
meta_types
=
()
# Sub-object types that are specific to this object
security
.
declarePrivate
(
'valid_roles'
)
def
valid_roles
(
self
):
def
valid_roles
(
self
):
"Return list of valid roles"
"Return list of valid roles"
obj
=
self
obj
=
self
...
@@ -1096,6 +1142,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -1096,6 +1142,7 @@ class ZCatalog(Folder, Persistent, Implicit):
roles
.
sort
()
roles
.
sort
()
return
roles
return
roles
security
.
declarePrivate
(
'ZopeFindAndApply'
)
def
ZopeFindAndApply
(
self
,
obj
,
obj_ids
=
None
,
obj_metatypes
=
None
,
def
ZopeFindAndApply
(
self
,
obj
,
obj_ids
=
None
,
obj_metatypes
=
None
,
obj_searchterm
=
None
,
obj_expr
=
None
,
obj_searchterm
=
None
,
obj_expr
=
None
,
obj_mtime
=
None
,
obj_mspec
=
None
,
obj_mtime
=
None
,
obj_mspec
=
None
,
...
@@ -1196,6 +1243,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -1196,6 +1243,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return
result
return
result
security
.
declarePrivate
(
'resolve_url'
)
def
resolve_url
(
self
,
path
,
REQUEST
):
def
resolve_url
(
self
,
path
,
REQUEST
):
"""
"""
Attempt to resolve a url into an object in the Zope
Attempt to resolve a url into an object in the Zope
...
@@ -1213,6 +1261,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -1213,6 +1261,7 @@ class ZCatalog(Folder, Persistent, Implicit):
except
:
except
:
pass
pass
security
.
declarePrivate
(
'resolve_path'
)
def
resolve_path
(
self
,
path
):
def
resolve_path
(
self
,
path
):
# !!! do not use docstring here (CVE-2011-0720).
# !!! do not use docstring here (CVE-2011-0720).
# Attempt to resolve a url into an object in the Zope
# Attempt to resolve a url into an object in the Zope
...
@@ -1226,6 +1275,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -1226,6 +1275,7 @@ class ZCatalog(Folder, Persistent, Implicit):
except
:
except
:
pass
pass
security
.
declarePrivate
(
'manage_normalize_paths'
)
def
manage_normalize_paths
(
self
,
REQUEST
,
sql_catalog_id
=
None
):
def
manage_normalize_paths
(
self
,
REQUEST
,
sql_catalog_id
=
None
):
"""Ensure that all catalog paths are full physical paths
"""Ensure that all catalog paths are full physical paths
...
@@ -1271,6 +1321,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -1271,6 +1321,7 @@ class ZCatalog(Folder, Persistent, Implicit):
'%s unchanged.'
%
(
len
(
fixed
),
len
(
removed
),
unchanged
),
'%s unchanged.'
%
(
len
(
fixed
),
len
(
removed
),
unchanged
),
action
=
'./manage_main'
)
action
=
'./manage_main'
)
security
.
declarePrivate
(
'getTableIds'
)
def
getTableIds
(
self
,
sql_catalog_id
=
None
):
def
getTableIds
(
self
,
sql_catalog_id
=
None
):
"""Returns all tables of this catalog
"""Returns all tables of this catalog
"""
"""
...
@@ -1279,6 +1330,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -1279,6 +1330,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return
catalog
.
getTableIds
()
return
catalog
.
getTableIds
()
return
[]
return
[]
security
.
declarePrivate
(
'getCatalogSearchResultKeys'
)
def
getCatalogSearchResultKeys
(
self
,
sql_catalog_id
=
None
):
def
getCatalogSearchResultKeys
(
self
,
sql_catalog_id
=
None
):
"""Return selected tables of catalog which are used in JOIN.
"""Return selected tables of catalog which are used in JOIN.
catalaog is always first
catalaog is always first
...
@@ -1288,6 +1340,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -1288,6 +1340,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return
catalog
.
sql_search_result_keys
return
catalog
.
sql_search_result_keys
return
[]
return
[]
security
.
declarePrivate
(
'getCatalogSearchTableIds'
)
def
getCatalogSearchTableIds
(
self
,
sql_catalog_id
=
None
):
def
getCatalogSearchTableIds
(
self
,
sql_catalog_id
=
None
):
"""Return selected tables of catalog which are used in JOIN.
"""Return selected tables of catalog which are used in JOIN.
catalaog is always first
catalaog is always first
...
@@ -1297,6 +1350,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -1297,6 +1350,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return
catalog
.
getCatalogSearchTableIds
()
return
catalog
.
getCatalogSearchTableIds
()
return
[]
return
[]
security
.
declarePrivate
(
'getResultColumnIds'
)
def
getResultColumnIds
(
self
,
sql_catalog_id
=
None
):
def
getResultColumnIds
(
self
,
sql_catalog_id
=
None
):
"""Return selected tables of catalog which are used
"""Return selected tables of catalog which are used
as metadata
as metadata
...
@@ -1306,6 +1360,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -1306,6 +1360,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return
catalog
.
getResultColumnIds
()
return
catalog
.
getResultColumnIds
()
return
[]
return
[]
security
.
declarePrivate
(
'getCatalogMethodIds'
)
def
getCatalogMethodIds
(
self
,
sql_catalog_id
=
None
):
def
getCatalogMethodIds
(
self
,
sql_catalog_id
=
None
):
"""Find Z SQL methods in the current folder and above
"""Find Z SQL methods in the current folder and above
This function return a list of ids.
This function return a list of ids.
...
@@ -1315,6 +1370,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -1315,6 +1370,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return
catalog
.
getCatalogMethodIds
()
return
catalog
.
getCatalogMethodIds
()
return
{}
return
{}
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_editFilter'
)
def
manage_editFilter
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
,
sql_catalog_id
=
None
):
def
manage_editFilter
(
self
,
REQUEST
=
None
,
RESPONSE
=
None
,
URL1
=
None
,
sql_catalog_id
=
None
):
"""
"""
This methods allows to set a filter on each zsql method called,
This methods allows to set a filter on each zsql method called,
...
@@ -1328,6 +1384,7 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -1328,6 +1384,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if
catalog
is
not
None
:
if
catalog
is
not
None
:
catalog
.
manage_editFilter
(
REQUEST
=
REQUEST
,
RESPONSE
=
RESPONSE
,
URL1
=
URL1
)
catalog
.
manage_editFilter
(
REQUEST
=
REQUEST
,
RESPONSE
=
RESPONSE
,
URL1
=
URL1
)
security
.
declarePrivate
(
'getFilterableMethodList'
)
def
getFilterableMethodList
(
self
,
sql_catalog_id
=
None
):
def
getFilterableMethodList
(
self
,
sql_catalog_id
=
None
):
"""
"""
Returns only zsql methods wich catalog or uncatalog objets
Returns only zsql methods wich catalog or uncatalog objets
...
...
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