turbogears migration: tests: internationalization

Thomas De Schampheleire patrickdepinguin at gmail.com
Mon May 16 07:32:49 UTC 2016


Hi Alessandro,

On Mon, May 16, 2016 at 9:15 AM, Alessandro Molina
<alessandro.molina at gmail.com> wrote:
> Hi Thomas,
>
> did you manage to fix this be replacing "from tg.i18n import ugettext as _"
> with from "tg.i18n import lazy_ugettext as _" as suggested? I didn't have
> time to check but that should actually fix the issues you are facing.
>

Thanks for checking back.
Yes, using that fix in two places:

diff --git a/kallithea/model/forms.py b/kallithea/model/forms.py
--- a/kallithea/model/forms.py
+++ b/kallithea/model/forms.py
@@ -38,7 +38,7 @@ import logging
 import formencode
 from formencode import All

-from tg.i18n import ugettext as _
+from tg.i18n import lazy_ugettext as _

 from kallithea import BACKENDS
 from kallithea.model import validators as v
diff --git a/kallithea/model/validators.py b/kallithea/model/validators.py
--- a/kallithea/model/validators.py
+++ b/kallithea/model/validators.py
@@ -20,7 +20,7 @@ import re
 import formencode
 import logging
 from collections import defaultdict
-from tg.i18n import ugettext as _
+from tg.i18n import lazy_ugettext as _
 from webhelpers.pylonslib.secure_form import authentication_token
 import sqlalchemy


did solve this type of issue, but gave me the next one:

――――――――――――――――――――――――――――――――――――――――――――――――――― ERROR collecting
kallithea/tests/functional/test_pullrequests.py
―――――――――――――――――――――――――――――――――――――――――――――――――――
kallithea/tests/functional/test_pullrequests.py:7: in <module>
    from kallithea.controllers.pullrequests import PullrequestsController
kallithea/controllers/pullrequests.py:57: in <module>
    from kallithea.model.forms import PullRequestForm, PullRequestPostForm
kallithea/model/forms.py:49: in <module>
    class LoginForm(formencode.Schema):
kallithea/model/forms.py:72: in LoginForm
    chained_validators = [v.ValidAuth()]
kallithea/model/validators.py:302: in ValidAuth
    class _validator(formencode.validators.FancyValidator):
../venv/kallithea-tg/lib/python2.7/site-packages/formencode/declarative.py:75:
in __new__
    cls.__classinit__(cls, new_attrs)
../venv/kallithea-tg/lib/python2.7/site-packages/formencode/api.py:211:
in __classinit__
    cls._initialize_docstring()
../venv/kallithea-tg/lib/python2.7/site-packages/formencode/api.py:302:
in _initialize_docstring
    default = re.sub(r'(%\(.*?\)[rsifcx])', r'``\1``', default)
../venv/kallithea-tg/lib64/python2.7/re.py:155: in sub
    return _compile(pattern, flags).sub(repl, string, count)
E   TypeError: Error when calling the metaclass bases
E       expected string or buffer

I tried investigating this but it is out of my league.
I don't know if it is still related to internationalization or not, or
to some other turbogears-specific thing.

If you happen to have ideas here they are very welcome.

Being stuck there, I have been working on further migration of the
test suite to pytest, which is now finished, so I will be looking back
at the turbogears migration.

Best regards,
Thomas


More information about the kallithea-general mailing list