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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
erp5
Commits
9b022399
Commit
9b022399
authored
Jan 15, 2013
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CategoryTool: optimize getCategoryList and getAcquiredCategoryList
parent
dd5ffa73
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
13 deletions
+7
-13
product/CMFCategory/CategoryTool.py
product/CMFCategory/CategoryTool.py
+7
-13
No files found.
product/CMFCategory/CategoryTool.py
View file @
9b022399
...
@@ -1152,21 +1152,17 @@ class CategoryTool( UniqueObject, Folder, Base ):
...
@@ -1152,21 +1152,17 @@ class CategoryTool( UniqueObject, Folder, Base ):
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getCategoryList'
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getCategoryList'
)
def
getCategoryList
(
self
,
context
):
def
getCategoryList
(
self
,
context
):
if
getattr
(
aq_base
(
context
),
'categories'
,
_marker
)
is
not
_marker
:
result
=
getattr
(
aq_base
(
context
),
'categories'
,
None
)
if
isinstance
(
context
.
categories
,
tuple
):
if
result
is
not
None
:
result
=
list
(
context
.
categories
)
result
=
list
(
result
)
elif
isinstance
(
context
.
categories
,
list
):
result
=
context
.
categories
else
:
result
=
[]
elif
isinstance
(
context
,
dict
):
elif
isinstance
(
context
,
dict
):
re
sult
=
list
(
context
.
get
(
'categories'
,
[]
))
re
turn
list
(
context
.
get
(
'categories'
,
()
))
else
:
else
:
result
=
[]
result
=
[]
if
getattr
(
context
,
'isCategory'
,
0
):
if
getattr
(
context
,
'isCategory'
,
0
):
category_url
=
context
.
getRelativeUrl
()
category_url
=
context
.
getRelativeUrl
()
if
category_url
not
in
result
:
if
category_url
not
in
result
:
result
.
append
(
c
ontext
.
getRelativeUrl
()
)
# Pure category is member of itself
result
.
append
(
c
ategory_url
)
# Pure category is member of itself
return
result
return
result
_getCategoryList
=
getCategoryList
_getCategoryList
=
getCategoryList
...
@@ -1184,12 +1180,10 @@ class CategoryTool( UniqueObject, Folder, Base ):
...
@@ -1184,12 +1180,10 @@ class CategoryTool( UniqueObject, Folder, Base ):
def
getAcquiredCategoryList
(
self
,
context
):
def
getAcquiredCategoryList
(
self
,
context
):
result
=
self
.
getAcquiredCategoryMembershipList
(
context
,
result
=
self
.
getAcquiredCategoryMembershipList
(
context
,
base_category
=
self
.
getBaseCategoryList
(
context
=
context
))
base_category
=
self
.
getBaseCategoryList
(
context
=
context
))
append
=
result
.
append
for
c
in
self
.
_getCategoryList
(
context
):
non_acquired
=
self
.
_getCategoryList
(
context
)
for
c
in
non_acquired
:
# Make sure all local categories are considered
# Make sure all local categories are considered
if
c
not
in
result
:
if
c
not
in
result
:
append
(
c
)
result
.
append
(
c
)
return
result
return
result
# Catalog related methods
# Catalog related methods
...
...
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