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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eteri
erp5
Commits
b156b14b
Commit
b156b14b
authored
Dec 20, 2016
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZSQLCatalog.SQLCatalog: Factorise access to sql_getitem_by_{uid,path}.
parent
7f2b9d84
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
56 deletions
+12
-56
product/ZSQLCatalog/SQLCatalog.py
product/ZSQLCatalog/SQLCatalog.py
+12
-56
No files found.
product/ZSQLCatalog/SQLCatalog.py
View file @
b156b14b
...
@@ -1796,17 +1796,7 @@ class Catalog(Folder,
...
@@ -1796,17 +1796,7 @@ class Catalog(Folder,
security
.
declarePrivate
(
'getUidForPath'
)
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:
return
self
.
getUidDictForPathList
([
path
]).
get
(
path
)
if
path
is
None
:
return
None
# Get the appropriate SQL Method
method
=
getattr
(
self
,
self
.
sql_getitem_by_path
)
search_result
=
method
(
path
=
path
,
uid_only
=
1
)
# If not empty, return first record
if
len
(
search_result
)
>
0
:
return
long
(
search_result
[
0
].
uid
)
else
:
return
None
security
.
declarePrivate
(
'getUidDictForPathList'
)
security
.
declarePrivate
(
'getUidDictForPathList'
)
def
getUidDictForPathList
(
self
,
path_list
):
def
getUidDictForPathList
(
self
,
path_list
):
...
@@ -1860,40 +1850,16 @@ class Catalog(Folder,
...
@@ -1860,40 +1850,16 @@ class Catalog(Folder,
security
.
declarePrivate
(
'getPathForUid'
)
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
:
return
self
.
getPathDictForUidList
([
uid
]).
get
(
uid
)
if
uid
is
None
:
return
None
try
:
int
(
uid
)
except
ValueError
:
return
None
# Get the appropriate SQL Method
method
=
getattr
(
self
,
self
.
sql_getitem_by_uid
)
search_result
=
method
(
uid
=
uid
)
# If not empty return first record
if
len
(
search_result
)
>
0
:
return
search_result
[
0
].
path
else
:
return
None
except
ConflictError
:
raise
except
:
# This is a real LOG message
# which is required in order to be able to import .zexp files
LOG
(
'SQLCatalog'
,
WARNING
,
"could not find path from uid %s"
%
(
uid
,))
return
None
security
.
declarePrivate
(
'getMetadataForUid'
)
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
:
return
None
# Get the appropriate SQL Method
method
=
getattr
(
self
,
self
.
sql_getitem_by_uid
)
brain
=
method
(
uid
=
uid
)[
0
]
result
=
{}
result
=
{}
for
k
in
brain
.
__record_schema__
.
keys
():
path
=
self
.
getPathForUid
(
uid
)
result
[
k
]
=
getattr
(
brain
,
k
)
if
uid
is
not
None
:
result
[
'path'
]
=
path
result
[
'uid'
]
=
uid
return
result
return
result
security
.
declarePrivate
(
'getIndexDataForUid'
)
security
.
declarePrivate
(
'getIndexDataForUid'
)
...
@@ -1904,22 +1870,12 @@ class Catalog(Folder,
...
@@ -1904,22 +1870,12 @@ class Catalog(Folder,
security
.
declarePrivate
(
'getMetadataForPath'
)
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
:
result
=
{}
# Get the appropriate SQL Method
uid
=
self
.
getUidForPath
(
path
)
method
=
getattr
(
self
,
self
.
sql_getitem_by_path
)
if
uid
is
not
None
:
brain
=
method
(
path
=
path
)[
0
]
result
[
'path'
]
=
path
result
=
{}
result
[
'uid'
]
=
uid
for
k
in
brain
.
__record_schema__
.
keys
():
return
result
result
[
k
]
=
getattr
(
brain
,
k
)
return
result
except
ConflictError
:
raise
except
:
# This is a real LOG message
# which is required in order to be able to import .zexp files
LOG
(
'SQLCatalog'
,
WARNING
,
"could not find metadata from path %s"
%
(
path
,))
return
None
security
.
declarePrivate
(
'getIndexDataForPath'
)
security
.
declarePrivate
(
'getIndexDataForPath'
)
def
getIndexDataForPath
(
self
,
path
):
def
getIndexDataForPath
(
self
,
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