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
Levin Zimmermann
erp5
Commits
ca2febe1
Commit
ca2febe1
authored
Mar 28, 2022
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/zope4py2' into zope4py3
parents
326a1655
82d9aee7
Changes
39
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
253 additions
and
818 deletions
+253
-818
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testDateUtils.py
...TemplateItem/portal_components/test.erp5.testDateUtils.py
+25
-0
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
bt5/erp5_maileva_connector/SkinTemplateItem/portal_skins/erp5_maileva_connector/MailevaSOAPConnector_getAvailableConnector.py
...a_connector/MailevaSOAPConnector_getAvailableConnector.py
+1
-0
bt5/erp5_maileva_connector/WorkflowTemplateItem/portal_workflow/send_state_workflow.xml
...kflowTemplateItem/portal_workflow/send_state_workflow.xml
+1
-4
bt5/erp5_maileva_connector/WorkflowTemplateItem/portal_workflow/send_state_workflow/state_draft.xml
...eItem/portal_workflow/send_state_workflow/state_draft.xml
+2
-40
bt5/erp5_maileva_connector/WorkflowTemplateItem/portal_workflow/send_state_workflow/state_failed.xml
...Item/portal_workflow/send_state_workflow/state_failed.xml
+2
-40
bt5/erp5_maileva_connector/WorkflowTemplateItem/portal_workflow/send_state_workflow/state_sending.xml
...tem/portal_workflow/send_state_workflow/state_sending.xml
+2
-40
bt5/erp5_maileva_connector/WorkflowTemplateItem/portal_workflow/send_state_workflow/state_success.xml
...tem/portal_workflow/send_state_workflow/state_success.xml
+2
-40
bt5/erp5_open_trade/TestTemplateItem/portal_components/test.erp5.testOpenOrder.py
...TemplateItem/portal_components/test.erp5.testOpenOrder.py
+15
-6
bt5/erp5_payroll_l10n_fr/TestTemplateItem/portal_components/test.erp5.testDSNSocialDeclarationReport.py
...al_components/test.erp5.testDSNSocialDeclarationReport.py
+1
-7
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_date_time_field_zuite/testDisplayWithAndWithoutTimeZone.zpt
...te_time_field_zuite/testDisplayWithAndWithoutTimeZone.zpt
+6
-9
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_date_time_field_zuite/testRestoreDateTimeValueIfValidationError.zpt
...field_zuite/testRestoreDateTimeValueIfValidationError.zpt
+6
-9
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+2
-4
product/ERP5/TargetSolver/CopyToTarget.py
product/ERP5/TargetSolver/CopyToTarget.py
+7
-8
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.FolderWorkflowActionUtils.py
...al_components/extension.erp5.FolderWorkflowActionUtils.py
+5
-3
product/ERP5/bootstrap/erp5_core/ModuleComponentTemplateItem/portal_components/module.erp5.DateUtils.py
...ntTemplateItem/portal_components/module.erp5.DateUtils.py
+0
-25
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
+65
-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/ERP5TypeTestCase.py
product/ERP5Type/tests/ERP5TypeTestCase.py
+19
-5
product/ERP5Type/tests/testDynamicClassGeneration.py
product/ERP5Type/tests/testDynamicClassGeneration.py
+1
-1
scalability_test/example/scalabilityUsers.py
scalability_test/example/scalabilityUsers.py
+1
-1
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testDateUtils.py
View file @
ca2febe1
...
...
@@ -32,6 +32,7 @@ import unittest
from
DateTime
import
DateTime
from
erp5.component.module.DateUtils
import
addToDate
,
getIntervalListBetweenDates
,
\
atTheEndOfPeriod
,
getClosestDate
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
class
TestDateUtils
(
unittest
.
TestCase
):
"""
...
...
@@ -175,7 +176,31 @@ class TestDateUtils(unittest.TestCase):
self
.
assertEqual
(
'Sep. 10, 2008 12:00 am GMT-2'
,
getClosestDate
(
date
=
date
,
target_date
=
target_date
,
precision
=
'month'
,
before
=
False
).
pCommonZ
())
class
TestPinDateTime
(
ERP5TypeTestCase
):
def
test_pinDateTime
(
self
):
actual_begin_date
=
DateTime
()
datetime
=
DateTime
(
'2001/01/01 01:01:01'
)
fixed_date_with_timezone
=
DateTime
(
'2002/02/02 02:02:02 GMT+2'
)
self
.
pinDateTime
(
datetime
)
self
.
assertEqual
(
DateTime
(),
datetime
)
self
.
assertEqual
(
DateTime
(
'2002/02/02 02:02:02 GMT+2'
),
fixed_date_with_timezone
)
self
.
unpinDateTime
()
self
.
assertGreaterEqual
(
DateTime
(),
actual_begin_date
)
def
test_pinDateTime_context_manager
(
self
):
actual_begin_date
=
DateTime
()
datetime
=
DateTime
(
'2001/01/01 01:01:01'
)
with
self
.
pinDateTime
(
datetime
):
self
.
assertEqual
(
DateTime
(),
datetime
)
self
.
assertGreaterEqual
(
DateTime
(),
actual_begin_date
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestDateUtils
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestPinDateTime
))
return
suite
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFieldValueCache.py
deleted
100644 → 0
View file @
326a1655
# -*- 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
(
cache_id
in
field_value_cache
)
# 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
(
cache_id
in
field_value_cache
)
# Render
form
()
# Make sure cache has field
self
.
assertTrue
(
cache_id
in
field_value_cache
)
# 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 @
326a1655
<?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 @
ca2febe1
...
...
@@ -49,7 +49,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
...
...
@@ -68,7 +68,7 @@ class TestRenderViewAPI(ERP5TypeTestCase):
for
field
in
FieldRegistry
.
get_field_classes
().
values
():
# pylint: disable=no-value-for-parameter
self
.
assertEqual
((
'self'
,
'value'
,
'REQUEST'
,
'render_prefix'
),
field
.
render_view
.
__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
.
__func__
.
__code__
.
co_varnames
[:
4
],
'%s %s'
%
(
field
.
widget
,
field
.
widget
.
render_view
.
__func__
.
__code__
.
co_varnames
[:
4
]))
...
...
@@ -713,6 +713,9 @@ class TestMultiListField(ERP5TypeTestCase):
class
TestProxyField
(
ERP5TypeTestCase
):
def
getBusinessTemplateList
(
self
):
return
'erp5_core_proxy_field_legacy'
,
def
getTitle
(
self
):
return
"Proxy Field"
...
...
@@ -732,9 +735,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'
,))
...
...
@@ -872,7 +875,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'
))
...
...
@@ -1107,12 +1110,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'
)
...
...
@@ -1142,7 +1145,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.
...
...
@@ -1151,19 +1154,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 @
ca2febe1
...
...
@@ -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 @
ca2febe1
...
...
@@ -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 @
ca2febe1
...
...
@@ -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 @
ca2febe1
...
...
@@ -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
)
...
...
bt5/erp5_maileva_connector/SkinTemplateItem/portal_skins/erp5_maileva_connector/MailevaSOAPConnector_getAvailableConnector.py
View file @
ca2febe1
maileva_connector
=
context
.
portal_catalog
.
getResultValue
(
portal_type
=
'Maileva SOAP Connector'
,
reference
=
reference
,
validation_state
=
'validated'
)
if
not
maileva_connector
:
...
...
bt5/erp5_maileva_connector/WorkflowTemplateItem/portal_workflow/send_state_workflow.xml
View file @
ca2febe1
...
...
@@ -67,10 +67,7 @@
<item>
<key>
<string>
workflow_managed_permission
</string>
</key>
<value>
<tuple>
<string>
Modify portal content
</string>
<string>
Add portal content
</string>
</tuple>
<tuple/>
</value>
</item>
</dictionary>
...
...
bt5/erp5_maileva_connector/WorkflowTemplateItem/portal_workflow/send_state_workflow/state_draft.xml
View file @
ca2febe1
...
...
@@ -9,10 +9,7 @@
<item>
<key>
<string>
acquire_permission
</string>
</key>
<value>
<tuple>
<string>
Modify portal content
</string>
<string>
Add portal content
</string>
</tuple>
<tuple/>
</value>
</item>
<item>
...
...
@@ -67,42 +64,7 @@
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
Add portal content
</string>
</key>
<value>
<tuple>
<string>
Assignor
</string>
<string>
Authenticated
</string>
<string>
Associate
</string>
<string>
Author
</string>
<string>
Member
</string>
<string>
Assignee
</string>
<string>
Manager
</string>
<string>
Auditor
</string>
<string>
Owner
</string>
<string>
Reviewer
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
Modify portal content
</string>
</key>
<value>
<tuple>
<string>
Assignor
</string>
<string>
Authenticated
</string>
<string>
Author
</string>
<string>
Associate
</string>
<string>
Member
</string>
<string>
Assignee
</string>
<string>
Manager
</string>
<string>
Auditor
</string>
<string>
Owner
</string>
<string>
Reviewer
</string>
</tuple>
</value>
</item>
</dictionary>
<dictionary/>
</value>
</item>
</dictionary>
...
...
bt5/erp5_maileva_connector/WorkflowTemplateItem/portal_workflow/send_state_workflow/state_failed.xml
View file @
ca2febe1
...
...
@@ -9,10 +9,7 @@
<item>
<key>
<string>
acquire_permission
</string>
</key>
<value>
<tuple>
<string>
Modify portal content
</string>
<string>
Add portal content
</string>
</tuple>
<tuple/>
</value>
</item>
<item>
...
...
@@ -66,42 +63,7 @@
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
Add portal content
</string>
</key>
<value>
<tuple>
<string>
Assignor
</string>
<string>
Authenticated
</string>
<string>
Associate
</string>
<string>
Author
</string>
<string>
Member
</string>
<string>
Assignee
</string>
<string>
Manager
</string>
<string>
Auditor
</string>
<string>
Owner
</string>
<string>
Reviewer
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
Modify portal content
</string>
</key>
<value>
<tuple>
<string>
Assignor
</string>
<string>
Authenticated
</string>
<string>
Author
</string>
<string>
Associate
</string>
<string>
Member
</string>
<string>
Assignee
</string>
<string>
Manager
</string>
<string>
Auditor
</string>
<string>
Owner
</string>
<string>
Reviewer
</string>
</tuple>
</value>
</item>
</dictionary>
<dictionary/>
</value>
</item>
</dictionary>
...
...
bt5/erp5_maileva_connector/WorkflowTemplateItem/portal_workflow/send_state_workflow/state_sending.xml
View file @
ca2febe1
...
...
@@ -9,10 +9,7 @@
<item>
<key>
<string>
acquire_permission
</string>
</key>
<value>
<tuple>
<string>
Modify portal content
</string>
<string>
Add portal content
</string>
</tuple>
<tuple/>
</value>
</item>
<item>
...
...
@@ -66,42 +63,7 @@
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
Add portal content
</string>
</key>
<value>
<tuple>
<string>
Assignor
</string>
<string>
Authenticated
</string>
<string>
Associate
</string>
<string>
Author
</string>
<string>
Member
</string>
<string>
Assignee
</string>
<string>
Manager
</string>
<string>
Auditor
</string>
<string>
Owner
</string>
<string>
Reviewer
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
Modify portal content
</string>
</key>
<value>
<tuple>
<string>
Assignor
</string>
<string>
Authenticated
</string>
<string>
Author
</string>
<string>
Associate
</string>
<string>
Member
</string>
<string>
Assignee
</string>
<string>
Manager
</string>
<string>
Auditor
</string>
<string>
Owner
</string>
<string>
Reviewer
</string>
</tuple>
</value>
</item>
</dictionary>
<dictionary/>
</value>
</item>
</dictionary>
...
...
bt5/erp5_maileva_connector/WorkflowTemplateItem/portal_workflow/send_state_workflow/state_success.xml
View file @
ca2febe1
...
...
@@ -9,10 +9,7 @@
<item>
<key>
<string>
acquire_permission
</string>
</key>
<value>
<tuple>
<string>
Modify portal content
</string>
<string>
Add portal content
</string>
</tuple>
<tuple/>
</value>
</item>
<item>
...
...
@@ -57,42 +54,7 @@
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
Add portal content
</string>
</key>
<value>
<tuple>
<string>
Assignor
</string>
<string>
Authenticated
</string>
<string>
Associate
</string>
<string>
Author
</string>
<string>
Member
</string>
<string>
Assignee
</string>
<string>
Manager
</string>
<string>
Auditor
</string>
<string>
Owner
</string>
<string>
Reviewer
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
Modify portal content
</string>
</key>
<value>
<tuple>
<string>
Assignor
</string>
<string>
Authenticated
</string>
<string>
Author
</string>
<string>
Associate
</string>
<string>
Member
</string>
<string>
Assignee
</string>
<string>
Manager
</string>
<string>
Auditor
</string>
<string>
Owner
</string>
<string>
Reviewer
</string>
</tuple>
</value>
</item>
</dictionary>
<dictionary/>
</value>
</item>
</dictionary>
...
...
bt5/erp5_open_trade/TestTemplateItem/portal_components/test.erp5.testOpenOrder.py
View file @
ca2febe1
...
...
@@ -26,17 +26,13 @@
##############################################################################
import
unittest
import
os
import
sys
import
time
import
mock
from
unittest
import
expectedFailure
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
DateTime
import
DateTime
# explicitly set Europe/Paris timezone
os
.
environ
[
'TZ'
]
=
'Europe/Paris'
time
.
tzset
()
DateTime
.
_localzone0
=
'GMT+1'
DateTime
.
_localzone1
=
'GMT+2'
DateTime
.
_multipleZones
=
True
class
TestOpenOrder
(
ERP5TypeTestCase
):
"""
...
...
@@ -47,6 +43,19 @@ class TestOpenOrder(ERP5TypeTestCase):
return
'Test Open Order'
def
afterSetUp
(
self
):
# explicitly set Europe/Paris timezone
# We use mock, to make sure we patch in the right place, but the stopping
# the patcher does not really work as we also have to set TZ
os
.
environ
[
'TZ'
]
=
'Europe/Paris'
time
.
tzset
()
for
patcher
in
(
mock
.
patch
.
object
(
sys
.
modules
[
'DateTime.DateTime'
],
'_localzone0'
,
new
=
'GMT+1'
),
mock
.
patch
.
object
(
sys
.
modules
[
'DateTime.DateTime'
],
'_localzone1'
,
new
=
'GMT+2'
),
mock
.
patch
.
object
(
sys
.
modules
[
'DateTime.DateTime'
],
'_multipleZones'
,
new
=
True
),
):
patcher
.
start
()
self
.
addCleanup
(
patcher
.
stop
)
if
getattr
(
self
.
portal
,
'_run_after_setup'
,
None
)
is
not
None
:
return
...
...
bt5/erp5_payroll_l10n_fr/TestTemplateItem/portal_components/test.erp5.testDSNSocialDeclarationReport.py
View file @
ca2febe1
...
...
@@ -31,12 +31,6 @@ import time
from
DateTime
import
DateTime
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
# As tests rely on documents exported in test bt5, setting up timezone allows
# consistency between test environment execution and virtual ERP5 instance
os
.
environ
[
'TZ'
]
=
'GMT'
time
.
tzset
()
DateTime
.
_localzone0
=
'GMT'
class
TestDSNSocialDeclarationReport
(
ERP5TypeTestCase
):
"""
Test Suite for the generation of the French Social Declaration Report,
...
...
@@ -50,8 +44,8 @@ class TestDSNSocialDeclarationReport(ERP5TypeTestCase):
"""
This is ran before anything, used to set the environment
"""
self
.
portal
=
self
.
getPortalObject
()
self
.
dsn_module
=
self
.
portal
.
getDefaultModuleValue
(
"DSN Monthly Report"
)
self
.
setTimeZoneToUTC
()
self
.
pinDateTime
(
DateTime
(
2015
,
12
,
0o1
))
# Create the id_group 'dsn_event_counter'
self
.
portal
.
portal_ids
.
generateNewId
(
id_group
=
'dsn_event_counter'
,
id_generator
=
'continuous_integer_increasing'
)
...
...
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_date_time_field_zuite/testDisplayWithAndWithoutTimeZone.zpt
View file @
ca2febe1
...
...
@@ -120,14 +120,13 @@
<tr>
<td>
click
</td>
<td>
click
AndWait
</td>
<td>
//input[@value='Save Changes']
</td>
<td></td>
</tr>
<tr>
<td>
waitForElemen
tPresent
</td>
<td>
//div[@class='system-msg']
</td>
<td>
assertTex
tPresent
</td>
<td>
Content changed
</td>
<td></td>
</tr>
...
...
@@ -170,18 +169,16 @@
<tr>
<td>
click
</td>
<td>
click
AndWait
</td>
<td>
//input[@value='Save Changes']
</td>
<td></td>
</tr>
<tr>
<td>
waitForElemen
tPresent
</td>
<td>
//div[@class='system-msg']
</td>
<td>
assertTex
tPresent
</td>
<td>
Content changed
</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_date_time_field_zuite/testRestoreDateTimeValueIfValidationError.zpt
View file @
ca2febe1
...
...
@@ -68,14 +68,13 @@
</tr>
<tr>
<td>
click
</td>
<td>
click
AndWait
</td>
<td>
//input[@value='Save Changes']
</td>
<td></td>
</tr>
<tr>
<td>
waitForElemen
tPresent
</td>
<td>
//div[@class='system-msg']
</td>
<td>
assertTex
tPresent
</td>
<td>
Content changed
</td>
<td></td>
</tr>
...
...
@@ -172,18 +171,16 @@
</tr>
<tr>
<td>
click
</td>
<td>
click
AndWait
</td>
<td>
//input[@value='Save Changes']
</td>
<td></td>
</tr>
<tr>
<td>
waitForElemen
tPresent
</td>
<td>
//div[@class='system-msg']
</td>
<td>
assertTex
tPresent
</td>
<td>
Content changed
</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
product/ERP5/Document/BusinessTemplate.py
View file @
ca2febe1
...
...
@@ -5582,8 +5582,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
,
...
...
@@ -5593,8 +5592,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/TargetSolver/CopyToTarget.py
View file @
ca2febe1
...
...
@@ -30,6 +30,8 @@ from __future__ import division
##############################################################################
from
past.utils
import
old_div
import
datetime
from
DateTime
import
DateTime
from
.TargetSolver
import
TargetSolver
class
CopyToTarget
(
TargetSolver
):
...
...
@@ -62,13 +64,11 @@ class CopyToTarget(TargetSolver):
quantity_ratio
=
0
if
old_quantity
not
in
(
None
,
0.0
):
# XXX: What if quantity happens to be an integer ?
quantity_ratio
=
old_div
(
new_quantity
,
old_quantity
)
start_date_delta
=
0
stop_date_delta
=
0
# get the date delta in milliseconds, to prevent rounding issues
stop_date_delta
=
start_date_delta
=
datetime
.
timedelta
()
if
new_start_date
is
not
None
and
old_start_date
is
not
None
:
start_date_delta
=
new_start_date
.
millis
()
-
old_start_date
.
millis
()
start_date_delta
=
new_start_date
.
asdatetime
()
-
old_start_date
.
asdatetime
()
if
new_stop_date
is
not
None
and
old_stop_date
is
not
None
:
stop_date_delta
=
new_stop_date
.
millis
()
-
old_stop_date
.
millis
()
stop_date_delta
=
new_stop_date
.
asdatetime
()
-
old_stop_date
.
asdatetime
()
return
{
'quantity_ratio'
:
quantity_ratio
,
'start_date_delta'
:
start_date_delta
,
...
...
@@ -89,15 +89,14 @@ class CopyToTarget(TargetSolver):
"""
Generate values to save on simulation movement.
"""
from
erp5.component.module.DateUtils
import
createDateTimeFromMillis
value_dict
=
{}
# Modify quantity, start_date, stop_date
start_date
=
simulation_movement
.
getStartDate
()
if
start_date
is
not
None
:
value_dict
[
'start_date'
]
=
createDateTimeFromMillis
(
start_date
.
millis
()
+
start_date_delta
)
value_dict
[
'start_date'
]
=
DateTime
(
start_date
.
asdatetime
()
+
start_date_delta
)
stop_date
=
simulation_movement
.
getStopDate
()
if
stop_date
is
not
None
:
value_dict
[
'stop_date'
]
=
createDateTimeFromMillis
(
stop_date
.
millis
()
+
stop_date_delta
)
value_dict
[
'stop_date'
]
=
DateTime
(
stop_date
.
asdatetime
()
+
stop_date_delta
)
value_dict
[
'quantity'
]
=
simulation_movement
.
getQuantity
()
*
quantity_ratio
return
value_dict
...
...
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.FolderWorkflowActionUtils.py
View file @
ca2febe1
...
...
@@ -27,6 +27,8 @@
#
##############################################################################
import
six
from
past.builtins
import
cmp
from
hashlib
import
md5
...
...
@@ -126,8 +128,8 @@ def getDocumentGroupByWorkflowStateList(self, form_id='', **kw):
for
(
ptype
,
workflow_id
,
_
),
(
doc
,
document_count
)
in
\
workflow_state_dict
.
items
(
):
workflow
=
wf_tool
.
getWorkflowById
(
workflow_id
)
six
.
iteritems
(
workflow_state_dict
):
workflow
=
wf_tool
.
_getOb
(
workflow_id
)
state_var
=
workflow
.
getStateVariable
()
translated_workflow_state_title
=
doc
.
getProperty
(
'translated_%s_title'
%
state_var
)
...
...
@@ -186,7 +188,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/ModuleComponentTemplateItem/portal_components/module.erp5.DateUtils.py
View file @
ca2febe1
...
...
@@ -455,31 +455,6 @@ def convertDateToHour(date=None):
hour_
=
(
ordinal_date
-
ordinal_reference_date
)
*
number_of_hours_in_day
+
number_of_hours_in_day
+
date
.
hour
()
return
int
(
hour_
)
def
createDateTimeFromMillis
(
millis
):
# pylint: disable=redefined-outer-name
"""
Returns a DateTime object, build from the number of milliseconds since epoch.
Parameter should be a int or long.
This one should be used by solvers, as DateTime.__cmp__ actually only
compares the _millis parameter of the two DateTime objects.
This is currently not perfect: DateTime only supports creating a new object
from a floating point number of seconds since epoch, so a rounding issue is
still possible, that's why _millis is explicitely set to the same value
after the DateTime object has been created from (millis / 1000.)
A better way would be to compute (yr,mo,dy,hr,mn,sc,tz,t,d,s,millisecs) from
millis, and then create the DateTime object from it (see "elif ac == 11:" in
DateTime._parse_args).
Another solution would be a DateTime implementation that relies exclusively
on integer values internally.
"""
millis
=
int
(
millis
)
date
=
DateTime
(
millis
/
1000.
)
date
.
_millis
=
millis
return
date
def
getNumberOfDayInMonth
(
date
):
month
=
date
.
month
()
mapping
=
{
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/SkinsTool_checkFieldExternalValidator.py
View file @
ca2febe1
...
...
@@ -15,8 +15,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 @
ca2febe1
...
...
@@ -183,15 +183,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
)
...
...
@@ -200,6 +191,7 @@ class TALESValue(StaticValue):
else
:
container
=
None
kw
[
'field'
]
=
field
kw
[
'form'
]
=
form
kw
[
'request'
]
=
REQUEST
kw
[
'here'
]
=
obj
...
...
@@ -343,15 +335,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'
:
...
...
@@ -362,24 +352,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
:
...
...
@@ -390,11 +371,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 @
ca2febe1
...
...
@@ -2893,23 +2893,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
)
...
...
@@ -3218,7 +3212,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 @
ca2febe1
...
...
@@ -631,10 +631,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
)
...
...
@@ -642,7 +649,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 @
ca2febe1
...
...
@@ -774,7 +774,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 @
ca2febe1
...
...
@@ -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
key
in
REQUEST
:
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 @
ca2febe1
...
...
@@ -3050,9 +3050,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
)
...
...
@@ -3079,7 +3084,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 @
ca2febe1
...
...
@@ -31,38 +31,29 @@
from
future
import
standard_library
standard_library
.
install_aliases
()
from
builtins
import
str
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.
...
...
@@ -414,7 +405,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
...
...
@@ -481,30 +472,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
:
...
...
@@ -548,22 +544,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'
)
...
...
@@ -634,154 +623,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
...
...
@@ -818,46 +688,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 @
ca2febe1
...
...
@@ -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 @
ca2febe1
...
...
@@ -1368,6 +1368,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 @
ca2febe1
...
...
@@ -57,7 +57,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__
)
...
...
@@ -82,7 +82,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__
)
...
...
@@ -93,7 +93,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
)
...
...
@@ -110,7 +110,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 @
ca2febe1
...
...
@@ -3379,7 +3379,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 @
ca2febe1
...
...
@@ -114,7 +114,7 @@ class WorkflowTool(BaseTool):
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.'
)
...
...
@@ -209,7 +209,7 @@ class WorkflowTool(BaseTool):
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.'
))
...
...
@@ -349,7 +349,7 @@ class WorkflowTool(BaseTool):
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 @
ca2febe1
...
...
@@ -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/ERP5TypeTestCase.py
View file @
ca2febe1
...
...
@@ -32,6 +32,7 @@ from hashlib import md5
from
warnings
import
warn
from
ExtensionClass
import
pmc_init_of
from
DateTime
import
DateTime
import
mock
import
Products.ZMySQLDA.DA
from
Products.ZMySQLDA.DA
import
Connection
as
ZMySQLDA_Connection
...
...
@@ -376,12 +377,25 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
def
pinDateTime
(
self
,
date_time
):
# pretend time has stopped at a certain date (i.e. the test runs
# infinitely fast), to avoid errors on tests that are started
# infinitely fast),
for example
to avoid errors on tests that are started
# just before midnight.
# This can be used as a context manager, otherwise use unpinDateTime to
# reset.
global
_pinned_date_time
assert
date_time
is
None
or
isinstance
(
date_time
,
DateTime
)
_pinned_date_time
=
date_time
unpinDateTime
=
self
.
unpinDateTime
class
UnpinContextManager
(
object
):
def
__enter__
(
self
):
return
self
def
__exit__
(
self
,
*
args
):
unpinDateTime
()
return
UnpinContextManager
()
def
unpinDateTime
(
self
):
self
.
pinDateTime
(
None
)
def
setTimeZoneToUTC
(
self
):
# Make sure tests runs with UTC timezone. Some tests are checking values
# based on now, and this could give unexpected results:
...
...
@@ -390,11 +404,11 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
# UTC
os
.
environ
[
'TZ'
]
=
"UTC"
time
.
tzset
()
DateTime
.
_isDST
=
False
DateTime
.
_localzone
=
DateTime
.
_localzone0
=
DateTime
.
_localzone1
=
"UTC"
def
unpinDateTime
(
self
):
self
.
pinDateTime
(
None
)
mock
.
patch
.
object
(
sys
.
modules
[
'DateTime.DateTime'
],
'_localzone0'
,
new
=
'UTC'
).
start
()
mock
.
patch
.
object
(
sys
.
modules
[
'DateTime.DateTime'
],
'_localzone1'
,
new
=
'UTC'
).
start
()
mock
.
patch
.
object
(
sys
.
modules
[
'DateTime.DateTime'
],
'_multipleZones'
,
new
=
False
).
start
()
def
getDefaultSystemPreference
(
self
):
id
=
'default_system_preference'
...
...
product/ERP5Type/tests/testDynamicClassGeneration.py
View file @
ca2febe1
...
...
@@ -406,7 +406,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
def
getBusinessTemplateList
(
self
):
return
'erp5_
base'
,
return
'erp5_
core_proxy_field_legacy'
,
'erp5_base'
def
_newStandardProperty
(
self
,
operation_type
):
"""
...
...
scalability_test/example/scalabilityUsers.py
View file @
ca2febe1
# Specify user login/password used to run the tests.
# <password> and <user_quantity> will be automatically replaced by testnode for each configuration
user_tuple
=
tuple
([(
'scalability_user_%i'
%
x
,
"<password>"
)
for
x
in
range
(
0
,
<
user_quantity
>
)])
\ No newline at end of file
user_tuple
=
tuple
([(
'scalability_user_%i'
%
x
,
"<password>"
)
for
x
in
range
(
0
,
int
(
'<user_quantity>'
))])
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