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
Labels
Merge Requests
144
Merge Requests
144
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
ae8009b5
Commit
ae8009b5
authored
Oct 23, 2021
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
140db4f9
Pipeline
#18010
failed with stage
in 0 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
49 deletions
+45
-49
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testProxyField.py
...emplateItem/portal_components/test.erp5.testProxyField.py
+10
-5
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_checkFieldExternalValidator.py
..._skins/erp5_core/SkinsTool_checkFieldExternalValidator.py
+0
-5
product/ERP5Form/ProxyField.py
product/ERP5Form/ProxyField.py
+35
-39
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testProxyField.py
View file @
ae8009b5
...
...
@@ -28,12 +28,14 @@
import
re
from
functools
import
partial
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCas
e
from
Products.Formulator.XMLToForm
import
XMLToForm
from
unittest
import
expectedFailur
e
from
lxml
import
etree
from
Products.Formulator.FormToXML
import
formToXML
from
Products.Formulator.TALESField
import
TALESMethod
from
lxml
import
etree
from
unittest
import
expectedFailure
from
Products.Formulator.XMLToForm
import
XMLToForm
from
Products.ERP5Form.ProxyField
import
BrokenProxyField
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
class
TestProxyField
(
ERP5TypeTestCase
):
"""
...
...
@@ -400,6 +402,9 @@ return printed
field
=
form
.
my_title
self
.
assertFalse
(
form
.
get_fields
())
self
.
assertEqual
([
field
],
form
.
get_fields
(
include_disabled
=
True
))
self
.
assertIsNone
(
field
.
getTemplateField
())
self
.
assertEqual
(
''
,
field
.
get_tales
(
'default'
))
...
...
@@ -410,4 +415,4 @@ return printed
,
partial
(
field
.
get_value
,
'default'
)
,
partial
(
field
.
get_recursive_tales
,
'default'
)
):
self
.
assertRaisesRegexp
(
ValueError
,
regexp
,
func
)
self
.
assertRaisesRegexp
(
BrokenProxyField
,
regexp
,
func
)
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_checkFieldExternalValidator.py
View file @
ae8009b5
...
...
@@ -14,11 +14,6 @@ for skin_name, skin_path_list in skins_tool.getSkinPaths():
):
for
field
in
form
.
get_fields
():
if
field
.
meta_type
==
'ProxyField'
:
if
form
.
getId
()
==
'Base_viewRelatedObjectList'
and
\
field
.
getId
()
==
'listbox'
:
# This field has tales expressions for form_id & field_id
# and needs to be used in appropriate context.
continue
if
field
.
get_recursive_tales
(
'external_validator'
):
continue
try
:
...
...
product/ERP5Form/ProxyField.py
View file @
ae8009b5
...
...
@@ -28,38 +28,28 @@
#
##############################################################################
from
thread
import
get_ident
from
AccessControl
import
allow_class
,
ClassSecurityInfo
from
Acquisition
import
aq_base
from
MethodObject
import
Method
from
zLOG
import
LOG
,
WARNING
from
Products.CMFCore.Skinnable
import
SKINDATA
from
Products.Formulator
import
Widget
,
Validator
from
Products.Formulator.Field
import
ZMIField
from
Products.Formulator.DummyField
import
fields
from
Products.Formulator.Errors
import
ValidationError
from
Products.Formulator
import
MethodField
from
Products.ERP5Type.Utils
import
convertToUpperCase
from
Products.Formulator.TALESField
import
TALESMethod
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
from
Products.ERP5Type.ObjectMessage
import
ObjectMessage
from
Products.PageTemplates.PageTemplateFile
import
PageTemplateFile
from
Products.ERP5Type.Globals
import
get_request
from
Products.PythonScripts.Utility
import
allow_class
from
Products.PythonScripts.standard
import
url_quote_plus
from
AccessControl
import
ClassSecurityInfo
from
MethodObject
import
Method
from
zLOG
import
LOG
,
WARNING
,
DEBUG
,
PROBLEM
from
Acquisition
import
aq_base
,
aq_inner
,
aq_acquire
,
aq_chain
from
Products.ERP5Type.Globals
import
DTMLFile
from
Products.Formulator.TALESField
import
TALESMethod
from
Products.ERP5Form.Form
import
StaticValue
,
TALESValue
,
OverrideValue
,
\
DefaultValue
,
EditableValue
,
DefaultCheckBoxValue
from
Products.ERP5Form.Form
import
copyMethod
,
isCacheable
from
Products.CMFCore.Skinnable
import
SKINDATA
from
thread
import
get_ident
_USE_ORIGINAL_GET_VALUE_MARKER
=
[]
class
BrokenProxyField
(
Exception
):
pass
allow_class
(
BrokenProxyField
)
class
WidgetDelegatedMethod
(
Method
):
"""Method delegated to the proxied field's widget.
...
...
@@ -506,7 +496,7 @@ class ProxyField(ZMIField):
seen
.
append
(
field
)
else
:
return
self
raise
ValueError
(
error
%
self
)
raise
BrokenProxyField
(
error
%
self
)
def
_get_sub_form
(
self
,
field
=
None
):
if
field
is
None
:
...
...
@@ -633,21 +623,27 @@ class ProxyField(ZMIField):
def
get_value
(
self
,
id
,
**
kw
):
if
id
in
self
.
widget
.
property_names
:
return
ZMIField
.
get_value
(
self
,
id
,
**
kw
)
field
=
self
.
getRecursiveTemplateField
(
id
)
if
isinstance
(
field
,
ProxyField
):
cls
=
field
.
getRecursiveTemplateField
().
__class__
try
:
_ProxyField
=
cls
.
__ProxyField
except
AttributeError
:
class
_ProxyField
(
cls
):
def
__init__
(
self
):
pass
cls
.
__ProxyField
=
_ProxyField
tmp_field
=
_ProxyField
()
for
attr
in
'values'
,
'tales'
,
'overrides'
:
setattr
(
tmp_field
,
attr
,
getattr
(
field
,
attr
).
copy
())
field
=
tmp_field
return
field
.
get_value
(
id
,
field
=
self
,
**
kw
)
try
:
field
=
self
.
getRecursiveTemplateField
(
id
)
if
isinstance
(
field
,
ProxyField
):
cls
=
field
.
getRecursiveTemplateField
().
__class__
try
:
_ProxyField
=
cls
.
__ProxyField
except
AttributeError
:
class
_ProxyField
(
cls
):
def
__init__
(
self
):
pass
cls
.
__ProxyField
=
_ProxyField
tmp_field
=
_ProxyField
()
for
attr
in
'values'
,
'tales'
,
'overrides'
:
setattr
(
tmp_field
,
attr
,
getattr
(
field
,
attr
).
copy
())
field
=
tmp_field
except
BrokenProxyField
:
# do not break Form.get_field
if
id
!=
'enabled'
:
raise
else
:
return
field
.
get_value
(
id
,
field
=
self
,
**
kw
)
def
_getCacheId
(
self
):
assert
self
.
_p_oid
...
...
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