Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5_fork
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_fork
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
Hide 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):
...
@@ -1523,7 +1523,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
be created.
be created.
"""
"""
try
:
try
:
module
=
self
.
getDefaultModuleValue
(
portal_type
,
only_visible
=
Fals
e
)
module
=
self
.
getDefaultModuleValue
(
portal_type
,
only_visible
=
only_visibl
e
)
except
ValueError
:
except
ValueError
:
if
default
is
MARKER
:
if
default
is
MARKER
:
raise
ValueError
(
'Unable to find module for portal_type: '
+
portal_type
)
raise
ValueError
(
'Unable to find module for portal_type: '
+
portal_type
)
...
@@ -1556,9 +1556,10 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
...
@@ -1556,9 +1556,10 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
portal_type
in
x
.
getVisibleAllowedContentTypeList
()
portal_type
in
x
.
getVisibleAllowedContentTypeList
()
)
)
else
:
else
:
getTypeInfo
=
self
.
portal_types
.
getTypeInfo
allowed
=
lambda
x
:
(
allowed
=
lambda
x
:
(
x
is
not
None
and
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'
expected_module_id
+=
'_module'
module
=
self
.
_getOb
(
expected_module_id
,
None
)
module
=
self
.
_getOb
(
expected_module_id
,
None
)
...
@@ -1583,12 +1584,9 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
...
@@ -1583,12 +1584,9 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
For backward-compatibility.
For backward-compatibility.
Use getDefaultModuleValue (beware of slight "default" semantic change !).
Use getDefaultModuleValue (beware of slight "default" semantic change !).
"""
"""
try
:
module_id
=
self
.
getDefaultModuleId
(
portal_type
,
default
)
return
self
.
getDefaultModuleValue
(
portal_type
)
if
module_id
:
except
ValueError
:
return
getattr
(
self
,
module_id
,
None
)
if
default
is
MARKER
:
raise
ValueError
(
'Unable to find module for portal_type: '
+
portal_type
)
return
self
.
_getOb
(
default
)
security
.
declareProtected
(
Permissions
.
AddPortalContent
,
'newContent'
)
security
.
declareProtected
(
Permissions
.
AddPortalContent
,
'newContent'
)
def
newContent
(
self
,
id
=
None
,
portal_type
=
None
,
**
kw
):
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):
...
@@ -403,6 +403,11 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
module
,
module
,
portal
.
getDefaultModule
(
portal_type
,
default
=
module_id
)
portal
.
getDefaultModule
(
portal_type
,
default
=
module_id
)
)
)
self
.
assertIs
(
None
,
portal
.
getDefaultModule
(
portal_type
,
default
=
None
)
)
self
.
assertIs
(
self
.
assertIs
(
default
,
default
,
portal
.
getDefaultModuleValue
(
portal_type
,
default
=
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