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
Carlos Ramos Carreño
erp5
Commits
3c3ffc9b
Commit
3c3ffc9b
authored
Jul 02, 2012
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the issue 'Localizer.translate() does not work when it is called in activity'.
parent
5e9fa9d0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
product/CMFActivity/ActivityTool.py
product/CMFActivity/ActivityTool.py
+5
-0
product/ERP5Type/tests/testLocalizer.py
product/ERP5Type/tests/testLocalizer.py
+28
-0
No files found.
product/CMFActivity/ActivityTool.py
View file @
3c3ffc9b
...
...
@@ -54,6 +54,7 @@ from zExceptions import ExceptionFormatter
from
BTrees.OIBTree
import
OIBTree
from
Zope2
import
app
from
Products.ERP5Type.UnrestrictedMethod
import
PrivilegedUser
from
zope.site.hooks
import
setSite
try
:
from
Products
import
iHotfix
...
...
@@ -306,6 +307,10 @@ class Message(BaseMessage):
self
.
setExecutionState
(
MESSAGE_NOT_EXECUTABLE
,
exc_info
,
context
=
activity_tool
)
else
:
# Store site info
portal
=
getattr
(
obj
,
'getPortalObject'
,
lambda
:
None
)()
if
portal
is
not
None
:
setSite
(
portal
)
if
activity_tool
.
activity_timing_log
:
result
=
activity_timing_method
(
method
,
self
.
args
,
self
.
kw
)
else
:
...
...
product/ERP5Type/tests/testLocalizer.py
View file @
3c3ffc9b
...
...
@@ -29,7 +29,9 @@
import
unittest
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
from
Persistence
import
PersistentMapping
from
zope.site.hooks
import
setSite
class
TestLocalizer
(
ERP5TypeTestCase
):
def
afterSetUp
(
self
):
...
...
@@ -38,6 +40,12 @@ class TestLocalizer(ERP5TypeTestCase):
self
.
message_catalog
.
add_language
(
'fr'
)
self
.
message_catalog
.
_messages
.
clear
()
def
beforeTearDown
(
self
):
tmp_obj
=
getattr
(
self
,
'tmp_obj'
,
None
)
if
tmp_obj
is
not
None
:
tmp_obj
.
aq_parent
.
manage_delObjects
(
ids
=
[
tmp_obj
.
getId
(),])
self
.
tic
()
def
test_non_ascii_msgid
(
self
):
self
.
assertEqual
(
self
.
portal
.
Base_translateString
(
'This is 1€.'
,
lang
=
'fr'
),
"This is 1€."
)
...
...
@@ -99,6 +107,26 @@ class TestLocalizer(ERP5TypeTestCase):
self
.
assertFalse
(
'This is 1€.'
in
self
.
message_catalog
.
_messages
)
self
.
assertTrue
(
u'This is 1€.'
in
self
.
message_catalog
.
_messages
)
def
test_localizer_transle_in_activity
(
self
):
self
.
assertEqual
(
self
.
portal
.
Base_translateString
(
'This is 1€.'
,
lang
=
'fr'
),
"This is 1€."
)
self
.
message_catalog
.
message_edit
(
u'This is 1€.'
,
'fr'
,
u"C'est 1€."
,
''
)
skin
=
self
.
portal
.
portal_skins
.
custom
createZODBPythonScript
(
skin
,
'test_activity'
,
''
,
"context.setComment(context.Base_translateString('This is 1€.', lang='fr'))"
,
)
tmp_obj
=
self
.
portal
.
portal_templates
.
newContent
()
self
.
tic
()
tmp_obj
.
activate
().
test_activity
()
# here we don't call self.tic() that calls self.getPortal() that
# reinvoke setSite(portal).
setSite
()
self
.
commit
()
while
self
.
portal
.
portal_activities
.
getMessageList
():
self
.
portal
.
portal_activities
.
process_timer
(
None
,
None
)
self
.
assertEquals
(
tmp_obj
.
getComment
(),
"C'est 1€."
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestLocalizer
))
...
...
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