Roundup Tracker - Issues

Issue 2551199

classification
remove translationService from templating.py
Type: rfe Severity: normal
Components: Web interface Versions: devel
process
Status: fixed fixed
:
: rouilj : marcus.priesch, rouilj
Priority: normal : patch

Created on 2022-04-26 13:02 by marcus.priesch, last changed 2022-05-04 19:34 by rouilj.

Files
File name Uploaded Description Edit Remove
templating_form_parser.patch marcus.priesch, 2022-04-26 13:02
templating_form_parser_2.patch marcus.priesch, 2022-04-26 13:16
templating_form_parser_3.patch marcus.priesch, 2022-05-04 05:54
Messages
msg7466 Author: [hidden] (marcus.priesch) Date: 2022-04-26 13:02
working on issue2551184 i found the following:

translationService is only used in cgi.form_parser.py as fallback (which i dont know when this can happen, because client always has self.gettext and self.ngettext - but maybe i am wrong - maybe during tests ?)

could be better to remove it from templating.py and replace it by TranslationService.get_translation()

see attached patch

regards,
marcus
msg7467 Author: [hidden] (marcus.priesch) Date: 2022-04-26 13:16
sorry, i forgot engine_zopetal.py

i am wondering if anyone is using "global translationService"
msg7468 Author: [hidden] (rouilj) Date: 2022-04-26 21:31
Hi Marcus:

I just committed a test of the translation code accessed via the templating/web interface.
I am running it via a live server.

It looks like existing tests are not testing translation paths through the templating
code and call i18n or TranslationService directly.

Hopefully this new test will test some additional paths and we can clean up the code.

If you can add tests that cover the code you are changing it would be helpful.
It may not be possible, but please give it a shot.

-- rouilj
msg7500 Author: [hidden] (rouilj) Date: 2022-05-03 23:06
Hi Marcus:

It looks like most of these patches have been applied in changeset:   6658:408fd477761f
and merged back into default branch in changeset:   6664:ac0df9272162.

However the diff for roundup/cgi/engine_zopetal.py is missing:

-GlobalTranslationService.setGlobalTranslationService(translationService)
+GlobalTranslationService.setGlobalTranslationService(TranslationService.get_translation())

the changesets don't have this change. They remove the call to 
GlobalTranslationService.setGlobalTranslationService entirely. But the file
still imports GlobalTranslationService:

   from roundup.cgi.PageTemplates import PageTemplate, GlobalTranslationService

This looks wrong. I assume the call to:

 GlobalTranslationService.setGlobalTranslationService(TranslationService.get_translation())

should still be there right? If so can you check with Ralf and figure out how it went
missing.

Thanks.

-- rouilj
msg7501 Author: [hidden] (marcus.priesch) Date: 2022-05-04 05:54
Hi John,

the import is not needed, when you search the code for
'translationService' it is not used anywhere as a global variable.

it is only referenced in GlobaltranslationService.py and in
DummyEngine.py where a *self.*translationService gets assigned with
a DummyTranslationService instance.

grepping for getGlobalTranslationService and setGlobalTranslationService
yields that those are also not used anywhere.

getGlobalTranslationService only gets imported in TALES.py where it is
also not used.

therefore i assume it's not needed at all and can be removed.

i18n for TAL gets injected in cgi.TranslationService.py

i am working here with ralf's tracker and i18n is working with the
changes - and also without the import of GlobalTranslationService in
engine_zopetal.py.

i assume that i just forgot to remove the import when creating the patch.

is the change you are refering in msg7468 this one 6640:6ac3667706be ?

if yes, than i think we can assume things are working without the
GlobalTranslationService import - at least tests pass here without the
import.

attached is the patch to current tip also removing the unused code from
GlobalTranslationService.py (getGlo... and setGlo... and the global ...)

all tests pass ... postgresql and mysql not tested but there should be
no impact on these.

regards,
marcus.
msg7506 Author: [hidden] (rouilj) Date: 2022-05-04 19:34
Applied patch 3 in changeset:   6665:bd4097fa0671.
Closing.
History
Date User Action Args
2022-05-04 19:34:07rouiljsetpriority: normal
status: open -> fixed
resolution: fixed
messages: + msg7506
2022-05-04 14:46:04rouiljsetstatus: new -> open
assignee: rouilj
2022-05-04 05:54:18marcus.prieschsetfiles: + templating_form_parser_3.patch
messages: + msg7501
2022-05-03 23:06:19rouiljsetmessages: + msg7500
2022-04-26 21:31:27rouiljsetnosy: + rouilj
messages: + msg7468
2022-04-26 13:16:39marcus.prieschsetfiles: + templating_form_parser_2.patch
messages: + msg7467
2022-04-26 13:02:11marcus.prieschcreate