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
Labels
Merge Requests
139
Merge Requests
139
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
272b0be4
Commit
272b0be4
authored
Nov 16, 2016
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multiple_catalog: Index in all the catalogs available
parent
9c809286
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
151 additions
and
149 deletions
+151
-149
product/ZSQLCatalog/ZSQLCatalog.py
product/ZSQLCatalog/ZSQLCatalog.py
+151
-149
No files found.
product/ZSQLCatalog/ZSQLCatalog.py
View file @
272b0be4
...
@@ -716,11 +716,14 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -716,11 +716,14 @@ class ZCatalog(Folder, Persistent, Implicit):
immediate_reindex_archive
=
1
,
**
kw
):
immediate_reindex_archive
=
1
,
**
kw
):
"""Catalog a list of objects.
"""Catalog a list of objects.
"""
"""
catalog_id_list
=
self
.
getERP5CatalogIdList
()
for
sql_catalog_id
in
catalog_id_list
:
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
hot_reindexing
=
(
self
.
hot_reindexing_state
is
not
None
)
and
\
hot_reindexing
=
(
self
.
hot_reindexing_state
is
not
None
)
and
\
(
catalog
is
not
None
)
and
\
(
catalog
is
not
None
)
and
\
(
self
.
source_sql_catalog_id
==
catalog
.
id
)
(
self
.
source_sql_catalog_id
==
catalog
.
id
)
archiving
=
self
.
archive_path
is
not
None
archiving
=
self
.
archive_path
is
not
None
wrapped_object_list
=
[]
failed_object_list
=
[]
failed_object_list
=
[]
url_list
=
[]
url_list
=
[]
archive_list
=
[]
archive_list
=
[]
...
@@ -760,7 +763,6 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -760,7 +763,6 @@ class ZCatalog(Folder, Persistent, Implicit):
default_catalog
=
self
.
getSQLCatalog
()
default_catalog
=
self
.
getSQLCatalog
()
# Construct list of object to catalogged
# Construct list of object to catalogged
current_catalog_object_list
=
[]
for
obj
in
object_list
:
for
obj
in
object_list
:
if
hot_reindexing
:
if
hot_reindexing
:
try
:
try
:
...
@@ -798,7 +800,10 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -798,7 +800,10 @@ class ZCatalog(Folder, Persistent, Implicit):
goto_current_catalog
=
1
goto_current_catalog
=
1
if
goto_current_catalog
:
if
goto_current_catalog
:
current_catalog_object_list
.
append
(
obj
)
# wrap object only when sure it will be reindex now
# thus security uid is also reindex
wrap_obj
=
self
.
wrapObject
(
obj
,
sql_catalog_id
=
sql_catalog_id
)
wrapped_object_list
.
append
(
wrap_obj
)
# run activity or execute for each archive depending on priority
# run activity or execute for each archive depending on priority
if
catalog_dict
:
if
catalog_dict
:
...
@@ -807,56 +812,49 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -807,56 +812,49 @@ class ZCatalog(Folder, Persistent, Implicit):
# if we reindex in current catalog, do not relaunch an activity for this
# if we reindex in current catalog, do not relaunch an activity for this
continue
continue
d
=
catalog_dict
[
catalog_id
]
d
=
catalog_dict
[
catalog_id
]
# build the wrapped object list
wrapped_object_list_2
=
[]
for
obj
in
d
[
'obj'
]:
try
:
wrap_obj
=
self
.
wrapObject
(
obj
,
sql_catalog_id
=
catalog_id
)
wrapped_object_list_2
.
append
(
wrap_obj
)
except
ConflictError
:
raise
except
:
LOG
(
'WARNING ZSQLCatalog'
,
0
,
'wrapObject failed on the object %r'
%
(
obj
,),
error
=
sys
.
exc_info
())
failed_object_list
.
append
(
obj
)
# hot_reindexing is True when creating an object during a hot reindex, in this case, we don't want
# hot_reindexing is True when creating an object during a hot reindex, in this case, we don't want
# to reindex it in destination catalog, it will be recorded an play only once
# to reindex it in destination catalog, it will be recorded an play only once
if
not
hot_reindexing
and
self
.
hot_reindexing_state
!=
HOT_REINDEXING_DOUBLE_INDEXING_STATE
and
\
if
not
hot_reindexing
and
self
.
hot_reindexing_state
!=
HOT_REINDEXING_DOUBLE_INDEXING_STATE
and
\
self
.
destination_sql_catalog_id
==
catalog_id
:
self
.
destination_sql_catalog_id
==
catalog_id
:
destination_catalog
=
self
.
getSQLCatalog
(
self
.
destination_sql_catalog_id
)
destination_catalog
=
self
.
getSQLCatalog
(
self
.
destination_sql_catalog_id
)
# reindex objects in destination catalog
# reindex objects in destination catalog
destination_catalog
.
catalogObjectList
(
destination_catalog
.
catalogObjectList
(
wrapped_object_list_2
,
**
kw
)
self
.
wrapObjectList
(
object_value_list
=
d
[
'obj'
],
catalog_value
=
destination_catalog
,
),
**
kw
)
else
:
else
:
archive_catalog
=
self
.
getSQLCatalog
(
catalog_id
)
archive_catalog
=
self
.
getSQLCatalog
(
catalog_id
)
if
immediate_reindex_archive
:
if
immediate_reindex_archive
:
archive_catalog
.
catalogObjectList
(
archive_catalog
.
catalogObjectList
(
wrapped_object_list_2
,
**
kw
)
self
.
wrapObjectList
(
object_value_list
=
d
[
'obj'
],
catalog_value
=
archive_catalog
,
),
**
kw
)
else
:
else
:
for
obj
in
d
[
'obj'
]:
for
obj
in
d
[
'obj'
]:
obj
.
_reindexObject
(
sql_catalog_id
=
catalog_id
,
activate_kw
=
\
obj
.
_reindexObject
(
sql_catalog_id
=
catalog_id
,
activate_kw
=
\
{
'priority'
:
d
[
'priority'
]},
disable_archive
=
1
,
**
kw
)
{
'priority'
:
d
[
'priority'
]},
disable_archive
=
1
,
**
kw
)
if
catalog
is
not
None
:
if
catalog
is
not
None
:
if
current_catalog_object_list
:
if
wrapped_object_list
:
catalog
.
catalogObjectList
(
catalog
.
catalogObjectList
(
wrapped_object_list
,
**
kw
)
self
.
wrapObjectList
(
object_value_list
=
current_catalog_object_list
,
catalog_value
=
catalog
,
),
**
kw
)
if
hot_reindexing
:
if
hot_reindexing
:
destination_catalog
=
self
.
getSQLCatalog
(
self
.
destination_sql_catalog_id
)
destination_catalog
=
self
.
getSQLCatalog
(
self
.
destination_sql_catalog_id
)
if
destination_catalog
.
id
!=
catalog
.
id
:
if
destination_catalog
.
id
!=
catalog
.
id
:
if
self
.
hot_reindexing_state
==
HOT_REINDEXING_RECORDING_STATE
:
if
self
.
hot_reindexing_state
==
HOT_REINDEXING_RECORDING_STATE
:
destination_catalog
.
recordObjectList
(
url_list
,
1
)
destination_catalog
.
recordObjectList
(
url_list
,
1
)
elif
object_list
:
else
:
destination_catalog
.
catalogObjectList
(
wrapped_destination_object_list
=
[]
self
.
wrapObjectList
(
for
obj
in
object_list
:
object_value_list
=
object_list
,
wrap_obj
=
self
.
wrapObject
(
obj
,
sql_catalog_id
=
self
.
destination_sql_catalog_id
)
catalog_value
=
destination_catalog
,
wrapped_destination_object_list
.
append
(
wrap_obj
)
),
if
wrapped_destination_object_list
:
**
kw
destination_catalog
.
catalogObjectList
(
wrapped_destination_object_list
,
**
kw
)
)
object_list
[:]
=
failed_object_list
object_list
[:]
=
failed_object_list
...
@@ -886,6 +884,8 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -886,6 +884,8 @@ class ZCatalog(Folder, Persistent, Implicit):
priority
=
archive
.
getPriority
()).
uncatalog_object
(
uid
=
uid
,
path
=
path
,
priority
=
archive
.
getPriority
()).
uncatalog_object
(
uid
=
uid
,
path
=
path
,
sql_catalog_id
=
catalog_id
)
sql_catalog_id
=
catalog_id
)
catalog_id_list
=
self
.
getERP5CatalogIdList
()
for
sql_catalog_id
in
catalog_id_list
:
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
if
catalog
is
not
None
:
if
catalog
is
not
None
:
catalog
.
uncatalogObject
(
uid
=
uid
,
path
=
path
)
catalog
.
uncatalogObject
(
uid
=
uid
,
path
=
path
)
...
@@ -901,6 +901,8 @@ class ZCatalog(Folder, Persistent, Implicit):
...
@@ -901,6 +901,8 @@ class ZCatalog(Folder, Persistent, Implicit):
security
.
declarePrivate
(
'beforeUncatalogObject'
)
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_id_list
=
self
.
getERP5CatalogIdList
()
for
sql_catalog_id
in
catalog_id_list
:
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
)
...
...
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