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
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
Alexander Emmerich
erp5
Commits
82d9aee7
Commit
82d9aee7
authored
Mar 25, 2022
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'nexedi/master' into zope4py2
parents
82a57949
25ad9ece
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
159 additions
and
583 deletions
+159
-583
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFieldValueCache.py
...teItem/portal_components/test.erp5.testFieldValueCache.py
+0
-89
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFieldValueCache.xml
...eItem/portal_components/test.erp5.testFieldValueCache.xml
+0
-110
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFields.py
...estTemplateItem/portal_components/test.erp5.testFields.py
+13
-22
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testProxyField.py
...emplateItem/portal_components/test.erp5.testProxyField.py
+20
-12
bt5/erp5_core_test/bt/template_test_id_list
bt5/erp5_core_test/bt/template_test_id_list
+0
-1
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_glossary/GlossaryModule_getBusinessFieldFieldList.py
...erp5_glossary/GlossaryModule_getBusinessFieldFieldList.py
+1
-1
bt5/erp5_hal_json_style/ExtensionTemplateItem/portal_components/extension.erp5.HalStyle.py
...TemplateItem/portal_components/extension.erp5.HalStyle.py
+1
-1
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+2
-4
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.FolderWorkflowActionUtils.py
...al_components/extension.erp5.FolderWorkflowActionUtils.py
+2
-2
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_checkFieldExternalValidator.py
..._skins/erp5_core/SkinsTool_checkFieldExternalValidator.py
+1
-2
product/ERP5Form/Form.py
product/ERP5Form/Form.py
+14
-33
product/ERP5Form/ListBox.py
product/ERP5Form/ListBox.py
+6
-16
product/ERP5Form/MatrixBox.py
product/ERP5Form/MatrixBox.py
+11
-8
product/ERP5Form/MultiRelationField.py
product/ERP5Form/MultiRelationField.py
+0
-4
product/ERP5Form/ParallelListField.py
product/ERP5Form/ParallelListField.py
+5
-19
product/ERP5Form/PlanningBox.py
product/ERP5Form/PlanningBox.py
+8
-7
product/ERP5Form/ProxyField.py
product/ERP5Form/ProxyField.py
+64
-238
product/ERP5Form/RelationField.py
product/ERP5Form/RelationField.py
+0
-4
product/ERP5Security/tests/testERP5Security.py
product/ERP5Security/tests/testERP5Security.py
+1
-0
product/ERP5Type/Accessor/WorkflowState.py
product/ERP5Type/Accessor/WorkflowState.py
+4
-4
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+1
-1
product/ERP5Type/Tool/WorkflowTool.py
product/ERP5Type/Tool/WorkflowTool.py
+3
-3
product/ERP5Type/patches/WorkflowTool.py
product/ERP5Type/patches/WorkflowTool.py
+1
-1
product/ERP5Type/tests/testDynamicClassGeneration.py
product/ERP5Type/tests/testDynamicClassGeneration.py
+1
-1
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFieldValueCache.py
deleted
100644 → 0
View file @
82a57949
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2002-2009 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
class
TestFieldValueCache
(
ERP5TypeTestCase
):
"""
A Sample Test Class
"""
def
getTitle
(
self
):
return
"TestDiscussionThread"
def
getBusinessTemplateList
(
self
):
"""
Tuple of Business Templates we need to install
"""
return
(
'erp5_base'
,
)
def
setUpOnce
(
self
):
"""
Do nothing
"""
def
afterSetUp
(
self
):
"""
This is ran before each and every test, used to set up the environment
"""
self
.
person_module
=
self
.
portal
.
getDefaultModule
(
portal_type
=
'Person'
)
def
testEditZMIFieldPurgesValueCache
(
self
):
"""
This test makes sure that if manage_edit is called on a ZMI
field then its ValueCache is purged.
"""
person
=
self
.
person_module
.
newContent
()
form
=
person
.
Person_view
# Render
form
()
# Get form value
field
=
form
.
my_first_name
id_
=
'title'
from
Products.ERP5Form.Form
import
field_value_cache
cache_id
=
(
'ProxyField.get_value'
,
field
.
_p_oid
,
field
.
_p_oid
,
id_
)
# Make sure cache has field
self
.
assertTrue
(
field_value_cache
.
has_key
(
cache_id
))
# Make sure cache and field are equal
self
.
assertEqual
(
field
.
get_value
(
id_
),
field_value_cache
[
cache_id
])
# Call manage_renameObject
form
.
manage_renameObject
(
'my_first_name'
,
'my_first_name2'
)
form
.
manage_renameObject
(
'my_first_name2'
,
'my_first_name'
)
# Make sure cache has no field
self
.
assertFalse
(
field_value_cache
.
has_key
(
cache_id
))
# Render
form
()
# Make sure cache has field
self
.
assertTrue
(
field_value_cache
.
has_key
(
cache_id
))
# Make sure cache and field are equal
self
.
assertEqual
(
field
.
get_value
(
id_
),
field_value_cache
[
cache_id
])
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFieldValueCache.xml
deleted
100644 → 0
View file @
82a57949
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Test Component"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testFieldValueCache
</string>
</value>
</item>
<item>
<key>
<string>
default_source_reference
</string>
</key>
<value>
<string>
Products.ERP5Form.tests.testFieldValueCache
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
test.erp5.testFieldValueCache
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Test Component
</string>
</value>
</item>
<item>
<key>
<string>
sid
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_log
</string>
</key>
<value>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFields.py
View file @
82d9aee7
...
...
@@ -48,7 +48,7 @@ from Products.Formulator.TALESField import TALESMethod
from
Products.ERP5Type.Core.Folder
import
Folder
from
Products.ERP5Form.Form
import
field_value_cache
from
Products.ERP5Form.Form
import
getFieldValue
from
Products.ERP5Form
import
ProxyField
from
Products.ERP5Form
.ProxyField
import
BrokenProxyField
,
ProxyField
from
DateTime
import
DateTime
import
lxml.html
...
...
@@ -67,7 +67,7 @@ class TestRenderViewAPI(ERP5TypeTestCase):
for
field
in
FieldRegistry
.
get_field_classes
().
itervalues
():
# pylint: disable=no-value-for-parameter
self
.
assertEqual
((
'self'
,
'value'
,
'REQUEST'
,
'render_prefix'
),
field
.
render_view
.
im_func
.
func_code
.
co_varnames
)
if
field
is
not
ProxyField
.
ProxyField
:
if
field
is
not
ProxyField
:
self
.
assertEqual
((
'self'
,
'field'
,
'value'
,
'REQUEST'
),
field
.
widget
.
render_view
.
im_func
.
func_code
.
co_varnames
[:
4
],
'%s %s'
%
(
field
.
widget
,
field
.
widget
.
render_view
.
im_func
.
func_code
.
co_varnames
[:
4
]))
...
...
@@ -712,6 +712,9 @@ class TestMultiListField(ERP5TypeTestCase):
class
TestProxyField
(
ERP5TypeTestCase
):
def
getBusinessTemplateList
(
self
):
return
'erp5_core_proxy_field_legacy'
,
def
getTitle
(
self
):
return
"Proxy Field"
...
...
@@ -731,9 +734,9 @@ class TestProxyField(ERP5TypeTestCase):
'my_title'
,
'Title'
,
'StringField'
)
proxy_field
=
self
.
addField
(
self
.
container
.
Base_view
,
'my_title'
,
'Not Title'
,
'ProxyField'
)
self
.
assert
Equal
(
None
,
proxy_field
.
getTemplateField
())
self
.
assert
Equal
(
None
,
proxy_field
.
get_value
(
'enable
'
))
self
.
assert
Equal
(
None
,
proxy_field
.
get_value
(
'default'
)
)
self
.
assert
IsNone
(
proxy_field
.
getTemplateField
())
self
.
assert
False
(
proxy_field
.
get_value
(
'enabled
'
))
self
.
assert
Raises
(
BrokenProxyField
,
proxy_field
.
get_value
,
'default'
)
proxy_field
.
manage_edit_xmlrpc
(
dict
(
form_id
=
'Base_viewProxyFieldLibrary'
,
field_id
=
'my_title'
,))
...
...
@@ -871,7 +874,7 @@ class TestProxyField(ERP5TypeTestCase):
proxy_field
=
self
.
addField
(
self
.
container
.
Base_view
,
'my_String'
,
''
,
'ProxyField'
)
proxy_field
.
manage_edit_xmlrpc
(
dict
(
form_id
=
'Base_viewProxyFieldLibrary'
,
field_id
=
'my_
date
'
,))
field_id
=
'my_
string
'
,))
proxy_field
.
manage_edit_surcharged_xmlrpc
(
dict
(
title
=
'Title'
))
self
.
assertFalse
(
proxy_field
.
is_delegated
(
'title'
))
...
...
@@ -1106,12 +1109,12 @@ class TestFieldValueCache(ERP5TypeTestCase):
'default'
:
'python: repr(here)'
})
form
.
my_on_memory_field
.
_p_oid
=
None
# proxy field
addField
(
ProxyField
.
ProxyField
(
'proxy_field'
))
addField
(
ProxyField
(
'proxy_field'
))
form
.
proxy_field
.
_p_oid
=
makeDummyOid
()
form
.
proxy_field
.
values
[
'form_id'
]
=
'form'
form
.
proxy_field
.
values
[
'field_id'
]
=
'field'
# proxy field with tales
addField
(
ProxyField
.
ProxyField
(
'proxy_field_tales'
))
addField
(
ProxyField
(
'proxy_field_tales'
))
form
.
proxy_field_tales
.
_p_oid
=
makeDummyOid
()
form
.
proxy_field_tales
.
tales
[
'form_id'
]
=
TALESMethod
(
'string:form'
)
form
.
proxy_field_tales
.
tales
[
'field_id'
]
=
TALESMethod
(
'string:field'
)
...
...
@@ -1141,7 +1144,7 @@ class TestFieldValueCache(ERP5TypeTestCase):
# make sure that this will use cache.
cache_size
=
self
.
_getCacheSize
(
'Form.get_value'
)
self
.
root
.
form
.
field
.
get_value
(
'title'
)
self
.
assert
Equal
(
True
,
cache_size
<
self
.
_getCacheSize
(
'Form.get_value'
))
self
.
assert
Less
(
cache_size
,
self
.
_getCacheSize
(
'Form.get_value'
))
# check on-memory field
# make sure that this will not use cache.
...
...
@@ -1150,19 +1153,7 @@ class TestFieldValueCache(ERP5TypeTestCase):
self
.
root
.
form
.
my_on_memory_tales_field
.
get_value
(
'default'
))
self
.
assertEqual
(
'123'
,
self
.
root
.
form
.
my_on_memory_field
.
get_value
(
'default'
))
self
.
assertEqual
(
True
,
cache_size
==
self
.
_getCacheSize
(
'Form.get_value'
))
# check proxy field
# make sure that this will use cache.
cache_size
=
self
.
_getCacheSize
(
'ProxyField.get_value'
)
self
.
root
.
form
.
proxy_field
.
get_value
(
'title'
)
self
.
assertEqual
(
True
,
cache_size
<
self
.
_getCacheSize
(
'ProxyField.get_value'
))
# check proxy field with tales
# make sure that this will not use cache.
cache_size
=
self
.
_getCacheSize
(
'ProxyField.get_value'
)
self
.
root
.
form
.
proxy_field_tales
.
get_value
(
'title'
)
self
.
assertEqual
(
True
,
cache_size
==
self
.
_getCacheSize
(
'ProxyField.get_value'
))
self
.
assertEqual
(
cache_size
,
self
.
_getCacheSize
(
'Form.get_value'
))
class
TestCaptchaField
(
ERP5TypeTestCase
):
...
...
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testProxyField.py
View file @
82d9aee7
...
...
@@ -26,13 +26,17 @@
#
##############################################################################
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.Formulator.XMLToForm
import
XMLToForm
import
re
from
functools
import
partial
from
unittest
import
expectedFailure
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
zExceptions
import
BadRequest
from
Products.Formulator.XMLToForm
import
XMLToForm
from
Products.ERP5Form.ProxyField
import
BrokenProxyField
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
class
TestProxyField
(
ERP5TypeTestCase
):
"""
...
...
@@ -400,15 +404,19 @@ return printed
form
=
skin_folder
.
_getOb
(
'Base_viewGeek'
,
None
)
form
.
manage_addField
(
'my_title'
,
'Title'
,
'ProxyField'
)
field
=
getattr
(
form
,
'my_title'
)
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
.
render
())
self
.
assertEqual
(
''
,
field
.
get_tales
(
'default'
))
self
.
assertIsNone
(
field
.
get_value
(
'default'
))
with
self
.
assertRaisesRegexp
(
AttributeError
,
'The proxy field <ProxyField at /%s/portal_skins/erp5_geek/Base_viewGeek/my_title> cannot find a template field'
%
self
.
portal
.
getId
()):
field
.
get_recursive_tales
(
'default'
)
regexp
=
'^%s$'
%
re
.
escape
(
"Can't find the template field of"
" <ProxyField at /%s/portal_skins/erp5_geek/Base_viewGeek/my_title>"
%
self
.
portal
.
getId
())
for
func
in
(
field
.
render
,
partial
(
field
.
get_value
,
'default'
)
,
partial
(
field
.
get_recursive_tales
,
'default'
)
):
self
.
assertRaisesRegexp
(
BrokenProxyField
,
regexp
,
func
)
bt5/erp5_core_test/bt/template_test_id_list
View file @
82d9aee7
...
...
@@ -23,7 +23,6 @@ test.erp5.testERP5Core
test.erp5.testERP5Type
test.erp5.testERP5TypeInterfaces
test.erp5.testERP5Workflow
test.erp5.testFieldValueCache
test.erp5.testFields
test.erp5.testFolder
test.erp5.testFolderMigration
...
...
bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_glossary/GlossaryModule_getBusinessFieldFieldList.py
View file @
82d9aee7
...
...
@@ -55,7 +55,7 @@ for business_field in business_field_list:
if
field
.
meta_type
==
'ProxyField'
:
if
field
.
is_delegated
(
'title'
)
is
True
:
field_note_list
.
append
(
'Delegated.'
)
elif
field
.
get_
tales_expression
(
'title'
)
is
not
None
:
elif
field
.
get_
recursive_tales
(
'title'
)
is
not
None
:
field_note_list
.
append
(
'Tales is used.'
)
if
len
(
term_list
)
==
1
and
\
...
...
bt5/erp5_hal_json_style/ExtensionTemplateItem/portal_components/extension.erp5.HalStyle.py
View file @
82d9aee7
...
...
@@ -87,7 +87,7 @@ def WorkflowTool_listActionParameterList(self):
for
action
in
action_list
:
if
(
action
[
'workflow_id'
]
not
in
workflow_dict
):
workflow
=
self
.
getWorkflowById
(
action
[
'workflow_id'
]
)
workflow
=
self
.
_getOb
(
action
[
'workflow_id'
],
None
)
if
workflow
is
not
None
:
workflow_dict
[
action
[
'workflow_id'
]]
=
workflow
.
getWorklistVariableMatchDict
(
info
,
check_guard
=
False
)
...
...
product/ERP5/Document/BusinessTemplate.py
View file @
82d9aee7
...
...
@@ -5572,8 +5572,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
Returns the current state in building
"""
portal_workflow
=
getToolByName
(
self
,
'portal_workflow'
)
wf
=
portal_workflow
.
getWorkflowById
(
'business_template_building_workflow'
)
wf
=
portal_workflow
.
_getOb
(
'business_template_building_workflow'
)
return
wf
.
_getWorkflowStateOf
(
self
,
id_only
=
id_only
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
...
...
@@ -5583,8 +5582,7 @@ Business Template is a set of definitions, such as skins, portal types and categ
Returns the current state in installation
"""
portal_workflow
=
getToolByName
(
self
.
getPortalObject
(),
'portal_workflow'
)
wf
=
portal_workflow
.
getWorkflowById
(
'business_template_installation_workflow'
)
wf
=
portal_workflow
.
_getOb
(
'business_template_installation_workflow'
)
return
wf
.
_getWorkflowStateOf
(
self
,
id_only
=
id_only
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'toxml'
)
...
...
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.FolderWorkflowActionUtils.py
View file @
82d9aee7
...
...
@@ -126,7 +126,7 @@ def getDocumentGroupByWorkflowStateList(self, form_id='', **kw):
for
(
ptype
,
workflow_id
,
_
),
(
doc
,
document_count
)
in
\
workflow_state_dict
.
iteritems
():
workflow
=
wf_tool
.
getWorkflowById
(
workflow_id
)
workflow
=
wf_tool
.
_getOb
(
workflow_id
)
state_var
=
workflow
.
getStateVariable
()
translated_workflow_state_title
=
doc
.
getProperty
(
'translated_%s_title'
%
state_var
)
...
...
@@ -185,7 +185,7 @@ def getWorkflowActionDocumentList(self, **kw):
selection_params
[
'uid'
]
=
selection_uid_list
workflow_id
,
action
=
listbox_selection
[
'workflow_action'
].
split
(
'/'
)[:
2
]
workflow
=
wtool
.
getWorkflowById
(
workflow_id
)
workflow
=
wtool
.
_getOb
(
workflow_id
)
for
doc
in
selection_tool
.
callSelectionFor
(
selection_name
,
params
=
selection_params
):
doc
=
doc
.
getObject
()
action_list
=
[
ai
for
ai
in
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_checkFieldExternalValidator.py
View file @
82d9aee7
...
...
@@ -14,8 +14,7 @@ for skin_name, skin_path_list in skins_tool.getSkinPaths():
):
for
field
in
form
.
get_fields
():
if
field
.
meta_type
==
'ProxyField'
:
if
field
.
getRecursiveTemplateField
(
)
is
None
or
field
.
get_recursive_tales
(
'external_validator'
):
if
field
.
get_recursive_tales
(
'external_validator'
):
continue
try
:
external_validator
=
field
.
get_recursive_orig_value
(
...
...
product/ERP5Form/Form.py
View file @
82d9aee7
...
...
@@ -179,15 +179,6 @@ class TALESValue(StaticValue):
def
__call__
(
self
,
field
,
id
,
**
kw
):
REQUEST
=
kw
.
get
(
'REQUEST'
,
get_request
())
if
REQUEST
is
not
None
:
# Proxyfield stores the "real" field in the request. Look if the
# corresponding field exists in request, and use it as field in the
# TALES context
field
=
REQUEST
.
get
(
'field__proxyfield_%s_%s_%s'
%
(
field
.
id
,
field
.
_p_oid
,
id
),
field
)
kw
[
'field'
]
=
field
form
=
field
.
aq_parent
# XXX (JPS) form for default is wrong apparently in listbox - double check
obj
=
getattr
(
form
,
'aq_parent'
,
None
)
...
...
@@ -196,6 +187,7 @@ class TALESValue(StaticValue):
else
:
container
=
None
kw
[
'field'
]
=
field
kw
[
'form'
]
=
form
kw
[
'request'
]
=
REQUEST
kw
[
'here'
]
=
obj
...
...
@@ -339,15 +331,13 @@ def getFieldValue(self, field, id, **kw):
value
=
copyMethod
(
value
)
cacheable
=
isCacheable
(
value
)
field_id
=
field
.
id
if
id
==
'default'
and
(
field_id
.
startswith
(
'my_'
)
or
field_id
.
startswith
(
'listbox_'
)):
if
field
.
meta_type
==
'ProxyField'
and
\
field
.
getRecursiveTemplateField
().
meta_type
==
'CheckBoxField'
or
\
self
.
meta_type
==
'CheckBoxField'
:
return
DefaultCheckBoxValue
(
field_id
,
value
),
cacheable
return
DefaultValue
(
field_id
,
value
),
cacheable
if
id
==
'default'
:
field_id
=
field
.
id
if
field_id
.
startswith
((
'my_'
,
'listbox_'
)):
if
(
self
.
getRecursiveTemplateField
()
if
self
.
meta_type
==
'ProxyField'
else
self
).
meta_type
==
'CheckBoxField'
:
return
DefaultCheckBoxValue
(
field_id
,
value
),
cacheable
return
DefaultValue
(
field_id
,
value
),
cacheable
# For the 'editable' value, we try to get a default value
if
id
==
'editable'
:
...
...
@@ -358,24 +348,15 @@ def getFieldValue(self, field, id, **kw):
return
StaticValue
(
value
),
cacheable
# Return default value in non callable mode
return_value
=
StaticValue
(
value
)(
field
,
id
,
**
kw
)
return_value
=
StaticValue
(
value
)(
None
,
id
,
**
kw
)
return
return_value
,
isCacheable
(
return_value
)
def
get_value
(
self
,
id
,
REQUEST
=
None
,
**
kw
):
if
REQUEST
is
None
:
REQUEST
=
get_request
()
if
REQUEST
is
not
None
:
field
=
REQUEST
.
get
(
'field__proxyfield_%s_%s_%s'
%
(
self
.
id
,
self
.
_p_oid
,
id
),
self
)
else
:
field
=
self
def
get_value
(
self
,
id
,
**
kw
):
field
=
kw
.
pop
(
'field'
,
self
)
cache_id
=
(
'Form.get_value'
,
self
.
_p_oid
,
field
.
_p_oid
,
field
.
_p_oid
if
id
==
'default'
else
id
)
try
:
value
=
field_value_cache
[
cache_id
]
except
KeyError
:
...
...
@@ -386,11 +367,11 @@ def get_value(self, id, REQUEST=None, **kw):
# because such field must be used for editing field in ZMI
# and caching sometimes break these field settings at initialization.
# As the result, we would see broken field editing screen in ZMI.
if
cacheable
and
self
.
_p_o
id
:
if
cacheable
and
None
not
in
cache_
id
:
field_value_cache
[
cache_id
]
=
value
if
callable
(
value
):
return
value
(
field
,
id
,
REQUEST
=
REQUEST
,
**
kw
)
return
value
(
field
,
id
,
**
kw
)
return
value
psyco
.
bind
(
get_value
)
...
...
product/ERP5Form/ListBox.py
View file @
82d9aee7
...
...
@@ -2888,23 +2888,17 @@ class ListBox(ZMIField):
security
.
declareProtected
(
'Access contents information'
,
'get_value'
)
def
get_value
(
self
,
id
,
**
kw
):
if
(
id
==
'default'
):
if
(
kw
.
get
(
'render_format'
)
in
(
'list'
,
)):
request
=
kw
.
get
(
'REQUEST'
,
None
)
if
id
==
'default'
:
render_format
=
kw
.
get
(
'render_format'
)
if
render_format
==
'list'
:
request
=
kw
.
get
(
'REQUEST'
)
if
request
is
None
:
request
=
get_request
()
# here the field can be a a proxyfield target, in this case just find
# back the original proxy field so that renderer's calls to .get_value
# are called on the proxyfield.
field
=
request
.
get
(
'field__proxyfield_%s_%s_%s'
%
(
self
.
id
,
self
.
_p_oid
,
id
),
self
)
field
=
kw
.
get
(
'field'
,
self
)
# for proxy field
return
self
.
widget
.
render
(
field
,
self
.
generate_field_key
(),
None
,
request
,
render_format
=
kw
.
get
(
'render_format'
)
,
render_format
=
render_format
,
render_prefix
=
kw
.
get
(
'render_prefix'
))
else
:
return
None
else
:
return
ZMIField
.
get_value
(
self
,
id
,
**
kw
)
...
...
@@ -3213,7 +3207,3 @@ allow_class(ListBoxLine)
from
Products.ERP5Type.PsycoWrapper
import
psyco
#psyco.bind(ListBoxWidget.render)
psyco
.
bind
(
ListBoxValidator
.
validate
)
# Register get_value
from
Products.ERP5Form.ProxyField
import
registerOriginalGetValueClassAndArgument
registerOriginalGetValueClassAndArgument
(
ListBox
,
'default'
)
product/ERP5Form/MatrixBox.py
View file @
82d9aee7
...
...
@@ -629,10 +629,17 @@ class MatrixBox(ZMIField):
security
.
declareProtected
(
'Access contents information'
,
'get_value'
)
def
get_value
(
self
,
id
,
**
kw
):
if
id
==
'default'
and
kw
.
get
(
'render_format'
)
in
(
'list'
,
):
return
self
.
widget
.
render
(
self
,
self
.
generate_field_key
(),
None
,
kw
.
get
(
'REQUEST'
),
render_format
=
kw
.
get
(
'render_format'
))
if
id
==
'default'
:
render_format
=
kw
.
get
(
'render_format'
)
if
render_format
==
'list'
:
request
=
kw
.
get
(
'REQUEST'
)
if
request
is
None
:
request
=
get_request
()
field
=
kw
.
get
(
'field'
,
self
)
# for proxy field
return
self
.
widget
.
render
(
field
,
self
.
generate_field_key
(),
None
,
request
,
render_format
=
render_format
,
render_prefix
=
kw
.
get
(
'render_prefix'
))
else
:
return
ZMIField
.
get_value
(
self
,
id
,
**
kw
)
...
...
@@ -640,7 +647,3 @@ class MatrixBox(ZMIField):
from
Products.ERP5Type.PsycoWrapper
import
psyco
psyco
.
bind
(
MatrixBoxWidget
.
render
)
psyco
.
bind
(
MatrixBoxValidator
.
validate
)
# Register get_value
from
Products.ERP5Form.ProxyField
import
registerOriginalGetValueClassAndArgument
registerOriginalGetValueClassAndArgument
(
MatrixBox
,
'default'
)
product/ERP5Form/MultiRelationField.py
View file @
82d9aee7
...
...
@@ -769,7 +769,3 @@ class MultiRelationStringField(ZMIField):
else
:
result
=
ZMIField
.
get_value
(
self
,
id
,
REQUEST
=
REQUEST
,
**
kw
)
return
result
# Register get_value
from
Products.ERP5Form.ProxyField
import
registerOriginalGetValueClassAndArgument
registerOriginalGetValueClassAndArgument
(
MultiRelationStringField
,
'items'
)
product/ERP5Form/ParallelListField.py
View file @
82d9aee7
...
...
@@ -225,7 +225,11 @@ class ParallelListField(ZMIField):
Optionally pass keyword arguments that get passed to TALES
expression.
"""
return
paralellListFieldGetValue
(
self
,
id
,
REQUEST
=
REQUEST
,
**
kw
)
if
REQUEST
is
not
None
:
result
=
REQUEST
.
get
(
KEYWORD
%
id
,
MARKER
)
if
result
is
not
MARKER
:
return
result
return
ZMIField
.
get_value
(
self
,
id
,
REQUEST
=
REQUEST
,
**
kw
)
def
generateSubForm
(
self
,
value
,
REQUEST
):
item_list
=
[
x
for
x
in
self
.
get_value
(
'items'
,
REQUEST
=
REQUEST
)
...
...
@@ -259,21 +263,3 @@ def generateSubForm(self, value, REQUEST):
empty_sub_field_property_dict
[
'item_list'
]
=
item_list
empty_sub_field_property_dict
[
'value'
]
=
value_list
return
[
empty_sub_field_property_dict
]
def
paralellListFieldGetValue
(
field
,
id
,
REQUEST
=
None
,
**
kw
):
result
=
MARKER
key
=
KEYWORD
%
id
if
REQUEST
is
not
None
and
REQUEST
.
has_key
(
key
):
result
=
REQUEST
.
get
(
key
)
if
result
is
MARKER
:
result
=
ZMIField
.
get_value
(
field
,
id
,
REQUEST
=
REQUEST
,
**
kw
)
return
result
# Register get_value
from
Products.ERP5Form.ProxyField
import
registerOriginalGetValueClassAndArgument
registerOriginalGetValueClassAndArgument
(
ParallelListField
,
(
'title'
,
'required'
,
'size'
,
'default'
,
'first_item'
,
'items'
),
paralellListFieldGetValue
)
product/ERP5Form/PlanningBox.py
View file @
82d9aee7
...
...
@@ -3046,9 +3046,14 @@ class PlanningBox(ZMIField):
XXX What is the purpose ?
"""
if
id
==
'default'
and
render_format
==
'list'
:
return
self
.
widget
.
render
(
self
,
self
.
generate_field_key
(),
None
,
kw
.
get
(
'REQUEST'
),
render_format
=
render_format
)
request
=
kw
.
get
(
'REQUEST'
)
if
request
is
None
:
request
=
get_request
()
field
=
kw
.
get
(
'field'
,
self
)
# for proxy field
return
self
.
widget
.
render
(
field
,
self
.
generate_field_key
(),
None
,
request
,
render_format
=
render_format
,
render_prefix
=
kw
.
get
(
'render_prefix'
))
else
:
return
ZMIField
.
get_value
(
self
,
id
,
**
kw
)
...
...
@@ -3075,7 +3080,3 @@ for klass in (PlanningBoxWidget, BasicStructure, BasicGroup,
Info
):
InitializeClass
(
klass
)
allow_class
(
klass
)
# Register get_value
from
Products.ERP5Form.ProxyField
import
registerOriginalGetValueClassAndArgument
registerOriginalGetValueClassAndArgument
(
PlanningBox
,
'default'
)
product/ERP5Form/ProxyField.py
View file @
82d9aee7
...
...
@@ -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.
...
...
@@ -411,7 +401,7 @@ class ProxyField(ZMIField):
"""
Return template field of the proxy field.
"""
if
cache
is
True
:
if
cache
:
tales
=
self
.
tales
if
self
.
_p_oid
is
None
or
tales
[
'field_id'
]
or
tales
[
'form_id'
]:
cache
=
False
...
...
@@ -478,30 +468,35 @@ class ProxyField(ZMIField):
LOG
(
'ProxyField'
,
WARNING
,
'Could not get a field from a proxy field %s in %s'
%
\
(
self
.
id
,
object
.
id
))
if
cache
is
True
:
if
cache
:
self
.
_setTemplateFieldCache
(
proxy_field
)
return
proxy_field
security
.
declareProtected
(
'Access contents information'
,
'getRecursiveTemplateField'
)
def
getRecursiveTemplateField
(
self
):
def
getRecursiveTemplateField
(
self
,
delegated_id
=
None
):
"""
Return template field of the proxy field.
This result must not be a ProxyField.
"""
field
=
self
chain
=
[]
while
True
:
template_field
=
field
.
getTemplateField
()
if
template_field
.
__class__
!=
ProxyField
:
If delegated_id is None, the result is not a ProxyField,
else it is the field that defines the value (possibly an
intermediate proxy field).
"""
seen
=
[
aq_base
(
self
)]
while
delegated_id
is
None
or
self
.
is_delegated
(
delegated_id
):
field
=
self
.
getTemplateField
()
if
not
isinstance
(
field
,
ProxyField
):
if
field
is
None
:
error
=
"Can't find the template field of %r"
break
return
field
self
=
field
field
=
aq_base
(
field
)
if
field
in
seen
:
error
=
"Infinite loop when searching template field of %r"
break
template_field_base
=
aq_base
(
template_field
)
if
template_field_base
in
chain
:
LOG
(
'ProxyField'
,
WARNING
,
'Infinite loop detected in %s.'
%
'/'
.
join
(
self
.
getPhysicalPath
()))
return
chain
.
append
(
template_field_base
)
field
=
template_field
return
template_field
seen
.
append
(
field
)
else
:
return
self
raise
BrokenProxyField
(
error
%
self
)
def
_get_sub_form
(
self
,
field
=
None
):
if
field
is
None
:
...
...
@@ -545,22 +540,15 @@ class ProxyField(ZMIField):
return
proxied_field
.
get_orig_value
(
id
)
security
.
declareProtected
(
'View management screens'
,
'get_recursive_tales'
)
def
get_recursive_tales
(
self
,
id
,
include
=
1
):
def
get_recursive_tales
(
self
,
id
):
"""
Get tales expression method for id.
"""
if
include
and
\
((
id
in
self
.
widget
.
property_names
)
or
\
not
self
.
is_delegated
(
id
)):
return
self
.
get_tales
(
id
)
else
:
proxied_field
=
self
.
getTemplateField
()
if
proxied_field
is
None
:
raise
AttributeError
(
'The proxy field %r cannot find a template field'
%
self
)
if
proxied_field
.
__class__
==
ProxyField
:
return
proxied_field
.
get_recursive_tales
(
id
)
else
:
return
proxied_field
.
get_tales
(
id
)
if
id
not
in
self
.
widget
.
property_names
:
self
=
self
.
getRecursiveTemplateField
(
id
)
tales
=
self
.
get_tales
(
id
)
if
tales
:
return
TALESMethod
(
tales
.
_text
)
# XXX Not implemented
security
.
declareProtected
(
'View management screens'
,
'get_recursive_override'
)
...
...
@@ -631,154 +619,35 @@ class ProxyField(ZMIField):
return
self
.
getTemplateField
().
get_orig_value
(
id
)
return
ZMIField
.
get_orig_value
(
self
,
id
)
#
# Performance improvement
#
def
get_tales_expression
(
self
,
id
):
field
=
self
while
True
:
if
(
id
in
field
.
widget
.
property_names
or
not
field
.
is_delegated
(
id
)):
tales
=
field
.
get_tales
(
id
)
if
tales
:
return
TALESMethod
(
tales
.
_text
)
else
:
return
None
proxied_field
=
field
.
getTemplateField
()
if
proxied_field
.
__class__
==
ProxyField
:
field
=
proxied_field
elif
proxied_field
is
None
:
raise
ValueError
(
"Can't find the template field of %s"
%
self
.
id
)
else
:
tales
=
proxied_field
.
get_tales
(
id
)
if
tales
:
return
TALESMethod
(
tales
.
_text
)
else
:
return
None
security
.
declareProtected
(
'Access contents information'
,
'getFieldValue'
)
def
getFieldValue
(
self
,
field
,
id
,
**
kw
):
"""
Return a callable expression and cacheable boolean flag
"""
# Some field types have their own get_value implementation,
# then we must use it always. This check must be done at first.
template_field
=
self
.
getRecursiveTemplateField
()
# Old ListBox instance might have default attribute. so we need to check it.
if
checkOriginalGetValue
(
template_field
,
id
):
return
_USE_ORIGINAL_GET_VALUE_MARKER
,
True
try
:
tales_expr
=
self
.
get_tales_expression
(
id
)
except
ValueError
:
return
None
,
False
if
tales_expr
:
tales_expr
=
copyMethod
(
tales_expr
)
return
TALESValue
(
tales_expr
),
isCacheable
(
tales_expr
)
# FIXME: backwards compat hack to make sure overrides dict exists
if
not
hasattr
(
self
,
'overrides'
):
self
.
overrides
=
{}
override
=
self
.
overrides
.
get
(
id
,
""
)
if
override
:
override
=
copyMethod
(
override
)
return
OverrideValue
(
override
),
isCacheable
(
override
)
# Get a normal value.
try
:
value
=
self
.
get_recursive_orig_value
(
id
)
except
KeyError
:
# For ListBox and other exceptional fields.
return
self
.
_get_value
(
id
,
**
kw
),
False
field_id
=
field
.
id
value
=
copyMethod
(
value
)
cacheable
=
isCacheable
(
value
)
if
id
==
'default'
and
(
field_id
.
startswith
(
'my_'
)
or
field_id
.
startswith
(
'listbox_'
)):
# XXX far from object-oriented programming
if
template_field
.
meta_type
==
'CheckBoxField'
:
return
DefaultCheckBoxValue
(
field_id
,
value
),
cacheable
return
DefaultValue
(
field_id
,
value
),
cacheable
# For the 'editable' value, we try to get a default value
if
id
==
'editable'
:
return
EditableValue
(
value
),
cacheable
# Return default value in callable mode
if
callable
(
value
):
return
StaticValue
(
value
),
cacheable
# Return default value in non callable mode
return_value
=
StaticValue
(
value
)(
field
,
id
,
**
kw
)
return
return_value
,
isCacheable
(
return_value
)
security
.
declareProtected
(
'Access contents information'
,
'get_value'
)
def
get_value
(
self
,
id
,
**
kw
):
if
id
in
self
.
widget
.
property_names
:
return
ZMIField
.
get_value
(
self
,
id
,
**
kw
)
if
not
self
.
is_delegated
(
id
):
original_template_field
=
self
.
getRecursiveTemplateField
()
function
=
getOriginalGetValueFunction
(
original_template_field
,
id
)
if
function
is
not
None
:
return
function
(
self
,
id
,
**
kw
)
else
:
return
ZMIField
.
get_value
(
self
,
id
,
**
kw
)
field
=
self
proxy_field
=
self
.
getTemplateField
()
REQUEST
=
kw
.
get
(
'REQUEST'
,
get_request
())
if
proxy_field
is
not
None
and
REQUEST
is
not
None
:
field
=
REQUEST
.
get
(
'field__proxyfield_%s_%s_%s'
%
(
self
.
id
,
self
.
_p_oid
,
id
),
self
)
REQUEST
.
set
(
'field__proxyfield_%s_%s_%s'
%
(
proxy_field
.
id
,
proxy_field
.
_p_oid
,
id
),
field
)
# Don't use cache if field is not stored in zodb, or if target field is
# defined by a TALES
if
self
.
_p_oid
is
None
or
self
.
tales
[
'field_id'
]
or
self
.
tales
[
'form_id'
]:
return
self
.
_get_value
(
id
,
**
kw
)
# XXX: Are these disabled?
proxy_field
=
self
.
getTemplateField
(
cache
=
False
)
if
proxy_field
is
not
None
:
return
proxy_field
.
get_value
(
id
,
**
kw
)
else
:
return
None
cache_id
=
(
'ProxyField.get_value'
,
self
.
_p_oid
,
field
.
_p_oid
,
id
)
from
Products.ERP5Form.Form
import
field_value_cache
try
:
value
=
field_value_cache
[
cache_id
]
except
KeyError
:
# either returns non callable value (ex. "Title")
# or a FieldValue instance of appropriate class
value
,
cacheable
=
self
.
getFieldValue
(
field
,
id
,
**
kw
)
if
cacheable
:
field_value_cache
[
cache_id
]
=
value
if
value
is
_USE_ORIGINAL_GET_VALUE_MARKER
:
return
proxy_field
.
get_value
(
id
,
**
kw
)
if
callable
(
value
):
return
value
(
field
,
id
,
**
kw
)
return
value
def
_get_value
(
self
,
id
,
**
kw
):
proxy_field
=
self
.
getTemplateField
(
cache
=
False
)
if
proxy_field
is
not
None
:
return
proxy_field
.
get_value
(
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
except
BrokenProxyField
:
# do not break Form.get_field
if
id
!=
'enabled'
:
raise
else
:
return
field
.
get_value
(
id
,
field
=
self
,
**
kw
)
def
_getCacheId
(
self
):
return
'%s%s'
%
(
'ProxyField'
,
self
.
_p_oid
or
repr
(
self
))
assert
self
.
_p_oid
return
'ProxyField'
,
self
.
_p_oid
def
_setTemplateFieldCache
(
self
,
field
):
getTransactionalVariable
()[
self
.
_getCacheId
()]
=
field
...
...
@@ -815,46 +684,3 @@ class ProxyField(ZMIField):
message
=
"Internal proxy field data structures are inconsistent. "
"Differences: {}"
.
format
(
difference
))]
return
[]
#
# get_value exception dict
#
_get_value_exception_dict
=
{}
def
registerOriginalGetValueClassAndArgument
(
class_
,
argument_name_list
=
(),
get_value_function
=
None
):
"""
if field class has its own get_value implementation and
must use it rather than ProxyField's one, then register it.
if argument_name_list is '*' , original get_value is
applied for all arguments.
"""
if
not
isinstance
(
argument_name_list
,
(
list
,
tuple
)):
argument_name_list
=
(
argument_name_list
,)
if
get_value_function
is
None
:
get_value_function
=
ZMIField
.
get_value
_get_value_exception_dict
[
class_
]
=
{
'argument_name_list'
:
argument_name_list
,
'get_value_function'
:
get_value_function
}
def
checkOriginalGetValue
(
instance
,
argument_name
):
"""
if exception data is registered, then return True
"""
class_
=
aq_base
(
instance
).
__class__
dict_
=
_get_value_exception_dict
.
get
(
class_
,
{})
argument_name_list
=
dict_
.
get
(
'argument_name_list'
)
if
argument_name_list
is
None
:
return
False
if
len
(
argument_name_list
)
==
1
and
argument_name_list
[
0
]
==
'*'
:
return
True
if
argument_name
in
argument_name_list
:
return
True
return
False
def
getOriginalGetValueFunction
(
instance
,
argument_name
):
class_
=
aq_base
(
instance
).
__class__
dict_
=
_get_value_exception_dict
.
get
(
class_
,
{})
return
dict_
.
get
(
'get_value_function'
)
product/ERP5Form/RelationField.py
View file @
82d9aee7
...
...
@@ -174,7 +174,3 @@ class RelationStringField(ZMIField):
else
:
result
=
ZMIField
.
get_value
(
self
,
id
,
REQUEST
=
REQUEST
,
**
kw
)
return
result
# Register get_value
from
Products.ERP5Form.ProxyField
import
registerOriginalGetValueClassAndArgument
registerOriginalGetValueClassAndArgument
(
RelationStringField
,
'items'
)
product/ERP5Security/tests/testERP5Security.py
View file @
82d9aee7
...
...
@@ -1366,6 +1366,7 @@ class TestKeyAuthentication(RoleManagementTestCase):
"""This test also uses web and dms
"""
return
super
(
TestKeyAuthentication
,
self
).
getBusinessTemplateList
()
+
(
'erp5_core_proxy_field_legacy'
,
# for erp5_web
'erp5_base'
,
'erp5_web'
,
'erp5_ingestion'
,
'erp5_dms'
,
'erp5_administration'
)
...
...
product/ERP5Type/Accessor/WorkflowState.py
View file @
82d9aee7
...
...
@@ -56,7 +56,7 @@ class Getter(BaseGetter):
def
__call__
(
self
,
instance
):
portal_workflow
=
instance
.
getPortalObject
().
portal_workflow
wf
=
portal_workflow
.
getWorkflowById
(
self
.
_key
)
wf
=
portal_workflow
.
_getOb
(
self
.
_key
)
return
wf
.
_getWorkflowStateOf
(
instance
,
id_only
=
1
)
psyco
.
bind
(
__call__
)
...
...
@@ -81,7 +81,7 @@ class TitleGetter(BaseGetter):
def
__call__
(
self
,
instance
):
portal_workflow
=
instance
.
getPortalObject
().
portal_workflow
wf
=
portal_workflow
.
getWorkflowById
(
self
.
_key
)
wf
=
portal_workflow
.
_getOb
(
self
.
_key
)
return
wf
.
_getWorkflowStateOf
(
instance
).
title
psyco
.
bind
(
__call__
)
...
...
@@ -92,7 +92,7 @@ class TranslatedGetter(Getter):
def
__call__
(
self
,
instance
):
portal
=
instance
.
getPortalObject
()
wf
=
portal
.
portal_workflow
.
getWorkflowById
(
self
.
_key
)
wf
=
portal
.
portal_workflow
.
_getOb
(
self
.
_key
)
state_id
=
wf
.
_getWorkflowStateOf
(
instance
,
id_only
=
1
)
warn
(
'Translated workflow state getters, such as %s are deprecated'
%
self
.
_id
,
DeprecationWarning
)
...
...
@@ -109,7 +109,7 @@ class TranslatedTitleGetter(TitleGetter):
portal
=
instance
.
getPortalObject
()
localizer
=
portal
.
Localizer
wf_id
=
self
.
_key
wf
=
portal
.
portal_workflow
.
getWorkflowById
(
wf_id
)
wf
=
portal
.
portal_workflow
.
_getOb
(
wf_id
)
selected_language
=
localizer
.
get_selected_language
()
state_title
=
wf
.
_getWorkflowStateOf
(
instance
).
title
msg_id
=
'%s [state in %s]'
%
(
state_title
,
wf_id
)
...
...
product/ERP5Type/Base.py
View file @
82d9aee7
...
...
@@ -3373,7 +3373,7 @@ class Base(
There's no check that the document is actually chained to the workflow,
it's caller responsability to perform this check.
"""
workflow
=
self
.
portal_workflow
.
getWorkflowById
(
wf_id
)
workflow
=
self
.
portal_workflow
.
_getOb
(
wf_id
,
None
)
if
workflow
is
not
None
:
changed
=
workflow
.
updateRoleMappingsFor
(
self
)
if
changed
:
...
...
product/ERP5Type/Tool/WorkflowTool.py
View file @
82d9aee7
...
...
@@ -99,7 +99,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
raise
WorkflowException
(
'No workflow provides the destination state %r'
\
%
state_id
)
else
:
workflow
=
self
.
getWorkflowById
(
wf_id
)
workflow
=
self
.
_getOb
(
wf_id
,
None
)
if
workflow
is
None
:
raise
WorkflowException
(
'Requested workflow definition not found.'
)
...
...
@@ -194,7 +194,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
Message
(
u"No workflow provides the '${action_id}' action."
,
mapping
=
{
'action_id'
:
action
}))
else
:
workflow
=
self
.
getWorkflowById
(
workflow_id
)
workflow
=
self
.
_getOb
(
workflow_id
,
None
)
if
workflow
is
None
:
raise
WorkflowException
(
Message
(
u'Requested workflow not found.'
))
...
...
@@ -334,7 +334,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
worklist_dict
=
{}
wf_ids
=
self
.
objectIds
()
for
wf_id
in
wf_ids
:
wf
=
self
.
getWorkflowById
(
wf_id
)
wf
=
self
.
_getOb
(
wf_id
,
None
)
if
wf
is
not
None
:
a
=
wf
.
getWorklistVariableMatchDict
(
info
,
check_guard
=
False
)
if
a
is
not
None
:
...
...
product/ERP5Type/patches/WorkflowTool.py
View file @
82d9aee7
...
...
@@ -160,7 +160,7 @@ def canDoActionFor(self, ob, action, wf_id=None, guard_kw={}):
if
wf_id
is
None
:
workflow_list
=
self
.
getWorkflowValueListFor
(
ob
)
or
()
else
:
workflow
=
self
.
getWorkflowById
(
wf_id
)
workflow
=
self
.
_getOb
(
wf_id
,
None
)
if
workflow
:
workflow_list
=
(
workflow
,)
else
:
...
...
product/ERP5Type/tests/testDynamicClassGeneration.py
View file @
82d9aee7
...
...
@@ -403,7 +403,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
def
getBusinessTemplateList
(
self
):
return
'erp5_
base'
,
return
'erp5_
core_proxy_field_legacy'
,
'erp5_base'
def
_newStandardProperty
(
self
,
operation_type
):
"""
...
...
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