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
Carlos Ramos Carreño
erp5
Commits
0d21e66d
Commit
0d21e66d
authored
Sep 15, 2017
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZSQLCatalog: Drop commented-out code and unhelpful comments.
parent
fe83821b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
47 deletions
+18
-47
product/ZSQLCatalog/SQLCatalog.py
product/ZSQLCatalog/SQLCatalog.py
+18
-47
No files found.
product/ZSQLCatalog/SQLCatalog.py
View file @
0d21e66d
...
@@ -72,11 +72,6 @@ try:
...
@@ -72,11 +72,6 @@ try:
except
ImportError
:
except
ImportError
:
withCMF
=
0
withCMF
=
0
try
:
import
psyco
except
ImportError
:
psyco
=
None
@
contextmanager
@
contextmanager
def
noReadOnlyTransactionCache
():
def
noReadOnlyTransactionCache
():
yield
yield
...
@@ -1367,22 +1362,14 @@ class Catalog(Folder,
...
@@ -1367,22 +1362,14 @@ class Catalog(Folder,
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
):
"""This is the real method to catalog objects.
"""This is the real method to catalog objects."""
XXX: For now newUid is used to allocated UIDs. Is this good?
Is it better to INSERT then SELECT?"""
LOG
(
'SQLCatalog'
,
TRACE
,
'catalogging %d objects'
%
len
(
object_list
))
LOG
(
'SQLCatalog'
,
TRACE
,
'catalogging %d objects'
%
len
(
object_list
))
#LOG('catalogObjectList', 0, 'called with %r' % (object_list,))
if
idxs
not
in
(
None
,
[]):
if
idxs
not
in
(
None
,
[]):
LOG
(
'ZSLQCatalog.SQLCatalog:catalogObjectList'
,
WARNING
,
LOG
(
'ZSLQCatalog.SQLCatalog:catalogObjectList'
,
WARNING
,
'idxs is ignored in this function and is only provided to be compatible with CMFCatalogAware.reindexObject.'
)
'idxs is ignored in this function and is only provided to be compatible with CMFCatalogAware.reindexObject.'
)
if
not
self
.
getPortalObject
().
isIndexable
():
if
not
self
.
getPortalObject
().
isIndexable
():
return
return
# Reminder about optimization: It might be possible to issue just one
# query to get enought results to check uid & path consistency.
path_uid_dict
=
{}
path_uid_dict
=
{}
uid_path_dict
=
{}
uid_path_dict
=
{}
...
@@ -1411,7 +1398,6 @@ class Catalog(Folder,
...
@@ -1411,7 +1398,6 @@ class Catalog(Folder,
uid
=
aq_base
(
object
).
uid
uid
=
aq_base
(
object
).
uid
except
AttributeError
:
except
AttributeError
:
uid
=
None
uid
=
None
# Generate unique uid for object having 0 or None as uid
if
uid
is
None
or
uid
==
0
:
if
uid
is
None
or
uid
==
0
:
try
:
try
:
object
.
uid
=
self
.
newUid
()
object
.
uid
=
self
.
newUid
()
...
@@ -1435,7 +1421,6 @@ class Catalog(Folder,
...
@@ -1435,7 +1421,6 @@ class Catalog(Folder,
if
index
<
0
:
if
index
<
0
:
raise
CatalogError
,
'A negative uid %d is used for %s. Your catalog is broken. Recreate your catalog.'
%
(
index
,
path
)
raise
CatalogError
,
'A negative uid %d is used for %s. Your catalog is broken. Recreate your catalog.'
%
(
index
,
path
)
if
uid
!=
index
or
isinstance
(
uid
,
int
):
if
uid
!=
index
or
isinstance
(
uid
,
int
):
# We want to make sure that uid becomes long if it is an int
error_message
=
'uid of %r changed from %r (property) to %r '
\
error_message
=
'uid of %r changed from %r (property) to %r '
\
'(catalog, by path) !!! This can be fatal'
%
(
object
,
uid
,
index
)
'(catalog, by path) !!! This can be fatal'
%
(
object
,
uid
,
index
)
if
not
self
.
sql_catalog_raise_error_on_uid_check
:
if
not
self
.
sql_catalog_raise_error_on_uid_check
:
...
@@ -1443,16 +1428,11 @@ class Catalog(Folder,
...
@@ -1443,16 +1428,11 @@ class Catalog(Folder,
else
:
else
:
raise
ValueError
(
error_message
)
raise
ValueError
(
error_message
)
else
:
else
:
# Make sure no duplicates - ie. if an object with different path has same uid, we need a new uid
# This can be very dangerous with relations stored in a category table (CMFCategory)
# This is why we recommend completely reindexing subobjects after any change of id
if
uid
in
uid_path_dict
:
if
uid
in
uid_path_dict
:
catalog_path
=
uid_path_dict
.
get
(
uid
)
catalog_path
=
uid_path_dict
.
get
(
uid
)
else
:
else
:
catalog_path
=
self
.
getPathForUid
(
uid
)
catalog_path
=
self
.
getPathForUid
(
uid
)
#LOG('catalogObject', 0, 'uid = %r, catalog_path = %r' % (uid, catalog_path))
if
catalog_path
==
"reserved"
:
if
catalog_path
==
"reserved"
:
# Reserved line in catalog table
with
global_reserved_uid_lock
:
with
global_reserved_uid_lock
:
uid_buffer
=
self
.
getUIDBuffer
()
uid_buffer
=
self
.
getUIDBuffer
()
if
uid_buffer
is
not
None
:
if
uid_buffer
is
not
None
:
...
@@ -1491,11 +1471,6 @@ class Catalog(Folder,
...
@@ -1491,11 +1471,6 @@ class Catalog(Folder,
if
len
(
path
)
>
MAX_PATH_LEN
:
if
len
(
path
)
>
MAX_PATH_LEN
:
LOG
(
'SQLCatalog'
,
ERROR
,
'path of object %r is too long for catalog. You should use a shorter path.'
%
(
object
,))
LOG
(
'SQLCatalog'
,
ERROR
,
'path of object %r is too long for catalog. You should use a shorter path.'
%
(
object
,))
LOG
(
'SQLCatalog'
,
ERROR
,
'uid of %r changed from %r to %r as old one is assigned'
' to %s in catalog !!! This can be fatal.'
%
(
object
,
uid
,
object
.
uid
,
catalog_path
))
error_message
=
'uid of %r is %r and '
\
error_message
=
'uid of %r is %r and '
\
'is already assigned to %s in catalog !!! This can be fatal.'
\
'is already assigned to %s in catalog !!! This can be fatal.'
\
%
(
object
,
uid
,
catalog_path
)
%
(
object
,
uid
,
catalog_path
)
...
@@ -1584,35 +1559,31 @@ class Catalog(Folder,
...
@@ -1584,35 +1559,31 @@ class Catalog(Folder,
if
not
catalogged_object_list
:
if
not
catalogged_object_list
:
continue
continue
#LOG('catalogObjectList', 0, 'method_name = %s' % (method_name,))
method
=
self
.
_getCatalogMethod
(
method_name
)
method
=
self
.
_getCatalogMethod
(
method_name
)
kw
=
{
x
:
LazyIndexationParameterList
(
catalogged_object_list
,
kw
=
{
x
,
argument_cache
)
x
:
LazyIndexationParameterList
(
for
x
in
self
.
_getCatalogMethodArgumentList
(
method
)}
catalogged_object_list
,
x
,
# Alter/Create row
argument_cache
,
)
for
x
in
self
.
_getCatalogMethodArgumentList
(
method
)
}
try
:
try
:
#start_time = DateTime()
#LOG('catalogObjectList', DEBUG, 'kw = %r, method_name = %r' % (kw, method_name))
method
(
**
kw
)
method
(
**
kw
)
#end_time = DateTime()
#if method_name not in profile_dict:
# profile_dict[method_name] = end_time.timeTime() - start_time.timeTime()
#else:
# profile_dict[method_name] += end_time.timeTime() - start_time.timeTime()
#LOG('catalogObjectList', 0, '%s: %f seconds' % (method_name, profile_dict[method_name]))
except
ConflictError
:
except
ConflictError
:
raise
raise
except
:
except
:
LOG
(
'SQLCatalog'
,
WARNING
,
'could not catalog objects %s with method %s'
%
(
object_list
,
method_name
),
LOG
(
error
=
sys
.
exc_info
())
'SQLCatalog._catalogObjectList'
,
ERROR
,
'could not catalog objects %s with method %s'
%
(
object_list
,
method_name
,
),
error
=
sys
.
exc_info
(),
)
raise
raise
if
psyco
is
not
None
:
psyco
.
bind
(
_catalogObjectList
)
def
_getCatalogMethodArgumentList
(
self
,
method
):
def
_getCatalogMethodArgumentList
(
self
,
method
):
if
method
.
meta_type
in
(
"Z SQL Method"
,
"LDIF Method"
):
if
method
.
meta_type
in
(
"Z SQL Method"
,
"LDIF Method"
):
# Build the dictionnary of values
# Build the dictionnary of values
...
...
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