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
1
Issues
1
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
Roque
erp5
Commits
dd2505f5
Commit
dd2505f5
authored
Feb 04, 2019
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: Fix testDynamicClassGeneration failures.
parent
cf937f3e
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
312 additions
and
131 deletions
+312
-131
product/ERP5Type/Core/DocumentComponent.py
product/ERP5Type/Core/DocumentComponent.py
+22
-0
product/ERP5Type/Core/InterfaceComponent.py
product/ERP5Type/Core/InterfaceComponent.py
+18
-0
product/ERP5Type/Core/MixinComponent.py
product/ERP5Type/Core/MixinComponent.py
+17
-0
product/ERP5Type/tests/testDynamicClassGeneration.py
product/ERP5Type/tests/testDynamicClassGeneration.py
+255
-131
No files found.
product/ERP5Type/Core/DocumentComponent.py
View file @
dd2505f5
...
@@ -31,6 +31,7 @@ from Products.ERP5Type.mixin.component import ComponentMixin
...
@@ -31,6 +31,7 @@ from Products.ERP5Type.mixin.component import ComponentMixin
from
Products.ERP5Type.mixin.text_content_history
import
TextContentHistoryMixin
from
Products.ERP5Type.mixin.text_content_history
import
TextContentHistoryMixin
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type.ConsistencyMessage
import
ConsistencyMessage
import
zope.interface
import
zope.interface
from
Products.ERP5Type.interfaces.component
import
IComponent
from
Products.ERP5Type.interfaces.component
import
IComponent
...
@@ -62,3 +63,24 @@ class DocumentComponent(ComponentMixin, TextContentHistoryMixin):
...
@@ -62,3 +63,24 @@ class DocumentComponent(ComponentMixin, TextContentHistoryMixin):
@
staticmethod
@
staticmethod
def
getIdPrefix
():
def
getIdPrefix
():
return
'document'
return
'document'
_message_reference_class_not_defined
=
"Class ${reference} must be defined"
def
checkConsistency
(
self
,
*
args
,
**
kw
):
"""
Per convention, a Document Component must have at least a class whose name
is the same as the Reference so that it can be assigned to Portal Types.
XXX: Very basic check for now.
"""
error_list
=
super
(
DocumentComponent
,
self
).
checkConsistency
(
*
args
,
**
kw
)
reference
=
self
.
getReference
()
text_content
=
self
.
getTextContent
()
if
(
reference
and
text_content
and
# Already checked in the parent class
'class %s('
%
reference
not
in
text_content
):
error_list
.
append
(
ConsistencyMessage
(
self
,
self
.
getRelativeUrl
(),
message
=
self
.
_message_reference_class_not_defined
,
mapping
=
{
'reference'
:
reference
}))
return
error_list
product/ERP5Type/Core/InterfaceComponent.py
View file @
dd2505f5
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
##############################################################################
##############################################################################
from
Products.ERP5Type.Core.DocumentComponent
import
DocumentComponent
from
Products.ERP5Type.Core.DocumentComponent
import
DocumentComponent
from
Products.ERP5Type.ConsistencyMessage
import
ConsistencyMessage
class
InterfaceComponent
(
DocumentComponent
):
class
InterfaceComponent
(
DocumentComponent
):
"""
"""
...
@@ -43,3 +44,20 @@ class InterfaceComponent(DocumentComponent):
...
@@ -43,3 +44,20 @@ class InterfaceComponent(DocumentComponent):
@
staticmethod
@
staticmethod
def
getIdPrefix
():
def
getIdPrefix
():
return
'interface'
return
'interface'
_message_reference_wrong_naming
=
"Interface Reference must start with 'I'"
def
checkConsistency
(
self
,
*
args
,
**
kw
):
"""
Per convention, an Interface class must start with 'I'
"""
error_list
=
super
(
InterfaceComponent
,
self
).
checkConsistency
(
*
args
,
**
kw
)
reference
=
self
.
getReference
()
if
(
reference
and
# Already checked in the parent class
not
reference
.
startswith
(
'I'
)):
error_list
.
append
(
ConsistencyMessage
(
self
,
self
.
getRelativeUrl
(),
message
=
self
.
_message_reference_wrong_naming
,
mapping
=
{}))
return
error_list
product/ERP5Type/Core/MixinComponent.py
View file @
dd2505f5
...
@@ -43,3 +43,20 @@ class MixinComponent(DocumentComponent):
...
@@ -43,3 +43,20 @@ class MixinComponent(DocumentComponent):
@
staticmethod
@
staticmethod
def
getIdPrefix
():
def
getIdPrefix
():
return
'mixin'
return
'mixin'
_message_reference_wrong_naming
=
"Mixin Reference must end with 'Mixin'"
def
checkConsistency
(
self
,
*
args
,
**
kw
):
"""
Per convention, a Mixin class must end with 'Mixin'
"""
error_list
=
super
(
MixinComponent
,
self
).
checkConsistency
(
*
args
,
**
kw
)
reference
=
self
.
getReference
()
if
(
reference
and
# Already checked in the parent class
not
reference
.
endswith
(
'Mixin'
)):
error_list
.
append
(
ConsistencyMessage
(
self
,
self
.
getRelativeUrl
(),
message
=
self
.
_message_reference_wrong_naming
,
mapping
=
{}))
return
error_list
product/ERP5Type/tests/testDynamicClassGeneration.py
View file @
dd2505f5
This diff is collapsed.
Click to expand it.
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