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
Kristopher Ruzic
erp5
Commits
def6774e
Commit
def6774e
authored
Aug 19, 2015
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! ERP5Site: Improve getDefaultModule*.
parent
afb722a0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
8 deletions
+11
-8
product/ERP5/ERP5Site.py
product/ERP5/ERP5Site.py
+6
-8
product/ERP5/tests/testERP5Core.py
product/ERP5/tests/testERP5Core.py
+5
-0
No files found.
product/ERP5/ERP5Site.py
View file @
def6774e
...
...
@@ -1523,7 +1523,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
be created.
"""
try
:
module
=
self
.
getDefaultModuleValue
(
portal_type
,
only_visible
=
Fals
e
)
module
=
self
.
getDefaultModuleValue
(
portal_type
,
only_visible
=
only_visibl
e
)
except
ValueError
:
if
default
is
MARKER
:
raise
ValueError
(
'Unable to find module for portal_type: '
+
portal_type
)
...
...
@@ -1556,9 +1556,10 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
portal_type
in
x
.
getVisibleAllowedContentTypeList
()
)
else
:
getTypeInfo
=
self
.
portal_types
.
getTypeInfo
allowed
=
lambda
x
:
(
x
is
not
None
and
portal_type
in
(
y
.
id
for
y
in
x
.
allowedContentTypes
()
)
portal_type
in
getTypeInfo
(
x
).
getTypeAllowedContentTypeList
(
)
)
expected_module_id
+=
'_module'
module
=
self
.
_getOb
(
expected_module_id
,
None
)
...
...
@@ -1583,12 +1584,9 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
For backward-compatibility.
Use getDefaultModuleValue (beware of slight "default" semantic change !).
"""
try
:
return
self
.
getDefaultModuleValue
(
portal_type
)
except
ValueError
:
if
default
is
MARKER
:
raise
ValueError
(
'Unable to find module for portal_type: '
+
portal_type
)
return
self
.
_getOb
(
default
)
module_id
=
self
.
getDefaultModuleId
(
portal_type
,
default
)
if
module_id
:
return
getattr
(
self
,
module_id
,
None
)
security
.
declareProtected
(
Permissions
.
AddPortalContent
,
'newContent'
)
def
newContent
(
self
,
id
=
None
,
portal_type
=
None
,
**
kw
):
...
...
product/ERP5/tests/testERP5Core.py
View file @
def6774e
...
...
@@ -403,6 +403,11 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
module
,
portal
.
getDefaultModule
(
portal_type
,
default
=
module_id
)
)
self
.
assertIs
(
None
,
portal
.
getDefaultModule
(
portal_type
,
default
=
None
)
)
self
.
assertIs
(
default
,
portal
.
getDefaultModuleValue
(
portal_type
,
default
=
default
),
...
...
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