[req,web] Make it possible to handle page language from URL prefix
Adding a short language prefix to URL (like "/en" or "/fr") changes the
language the pages are displayed in. This prefix is kept during navigation.
This way it is not necessary to do language negotiation, nor to use user
preferences to determine which language to apply.
This behavior is controlled through a new configuration option
"language-mode", which replaces "language-negociation" option and which values
may be "http-negotiation", "url-prefix" or "" (to disable language setting and
force using "ui.language" property). Migration from previous option is not
handled because I could not manage to have it working (users will get prompted
with the configuration file diff anyways).
Add some tests checking various scenarios.
Closes #15743487
[tox]
envlist =
check-manifest,flake8,
py{27,34}-{server,web,misc}
[testenv]
sitepackages = True
whitelist_externals =
/usr/bin/touch
deps =
-r{toxinidir}/requirements/dev.txt
py27: backports.tempfile
misc: -r{toxinidir}/requirements/test-misc.txt
server: -r{toxinidir}/requirements/test-server.txt
web: -r{toxinidir}/requirements/test-web.txt
commands =
py34: touch {envdir}/share/cubicweb/cubes/__init__.py
misc: {envpython} -m pip install --upgrade --no-deps --quiet git+git://github.com/logilab/yapps@master#egg=yapps
misc: {envpython} -m pytest {posargs} {toxinidir}/cubicweb/test {toxinidir}/cubicweb/dataimport/test {toxinidir}/cubicweb/devtools/test {toxinidir}/cubicweb/entities/test {toxinidir}/cubicweb/ext/test {toxinidir}/cubicweb/hooks/test {toxinidir}/cubicweb/sobjects/test {toxinidir}/cubicweb/wsgi/test {toxinidir}/cubicweb/pyramid/test
py27-misc: {envpython} -m pytest {posargs} {toxinidir}/cubicweb/etwist/test
server: {envpython} -m pytest {posargs} {toxinidir}/cubicweb/server/test
web: {envpython} -m pytest {posargs} {toxinidir}/cubicweb/web/test
[testenv:flake8]
skip_install = true
deps =
flake8 >= 3
commands =
flake8 {toxinidir}
[testenv:doc]
changedir = doc
deps =
sphinx
commands =
{envpython} -c 'import sphinx; sphinx.main()' -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
[testenv:check-manifest]
skip_install = true
deps =
check-manifest
commands =
check-manifest {toxinidir} \
# ignore symlinks that are not recognized by check-manifest, see
# https://github.com/mgedmin/check-manifest/issues/69
--ignore cubicweb/devtools/test/data/cubes/i18ntestcube*,cubicweb/test/data/legacy_cubes*
[pytest]
python_files = *test_*.py
[flake8]
format = pylint
ignore = W503
max-line-length = 100
exclude = setup.py,doc/*,cubicweb/misc/*,cubicweb/test/*,cubicweb/*/test/*,.tox/*
filename=
cubicweb/dataimport/csv.py,
cubicweb/dataimport/importer.py,
cubicweb/dataimport/massive_store.py,
cubicweb/dataimport/stores.py,
cubicweb/dataimport/test/data-massimport/schema.py,
cubicweb/dataimport/test/data/schema.py,
cubicweb/dataimport/test/test_csv.py,
cubicweb/dataimport/test/test_pgstore.py,
cubicweb/dataimport/test/test_massive_store.py,
cubicweb/dataimport/test/test_stores.py,
cubicweb/dataimport/test/unittest_importer.py,
cubicweb/devtools/test/data/cubes/i18ntestcube/__init__.py,
cubicweb/devtools/test/data/cubes/__init__.py,
cubicweb/devtools/test/data/schema.py,
cubicweb/devtools/testlib.py,
cubicweb/devtools/test/unittest_devctl.py,
cubicweb/devtools/test/unittest_i18n.py,
cubicweb/devtools/test/unittest_webtest.py,
cubicweb/devtools/webtest.py,
cubicweb/entities/adapters.py,
cubicweb/entities/test/unittest_base.py,
cubicweb/etwist/__init__.py,
cubicweb/ext/__init__.py,
cubicweb/hooks/test/data/hooks.py,
cubicweb/hooks/test/unittest_notification.py,
cubicweb/hooks/test/unittest_security.py,
cubicweb/hooks/test/unittest_syncsession.py,
cubicweb/__init__.py,
cubicweb/__main__.py,
cubicweb/pylintext.py,
cubicweb/server/repository.py,
cubicweb/server/rqlannotation.py,
cubicweb/server/schema2sql.py,
cubicweb/server/session.py,
cubicweb/server/sqlutils.py,
cubicweb/server/test/datacomputed/migratedapp/schema.py,
cubicweb/server/test/datacomputed/schema.py,
cubicweb/server/test/data/entities.py,
cubicweb/server/test/data-migractions/cubes/fakecustomtype/__init__.py,
cubicweb/server/test/data-migractions/cubes/fakeemail/__init__.py,
cubicweb/server/test/data-migractions/cubes/__init__.py,
cubicweb/server/test/data-migractions/migratedapp/__init__.py,
cubicweb/server/test/data-schema2sql/__init__.py,
cubicweb/server/test/unittest_checkintegrity.py,
cubicweb/server/test/unittest_ldapsource.py,
cubicweb/skeleton/test/pytestconf.py,
cubicweb/sobjects/test/unittest_notification.py,
cubicweb/sobjects/test/unittest_register_user.py,
cubicweb/sobjects/textparsers.py,
cubicweb/test/data/cubes/comment/__init__.py,
cubicweb/test/data/cubes/comment/__pkginfo__.py,
cubicweb/test/data/cubes/email/entities.py,
cubicweb/test/data/cubes/email/hooks.py,
cubicweb/test/data/cubes/email/__init__.py,
cubicweb/test/data/cubes/email/__pkginfo__.py,
cubicweb/test/data/cubes/email/views/__init__.py,
cubicweb/test/data/cubes/file/entities/__init__.py,
cubicweb/test/data/cubes/file/hooks/__init__.py,
cubicweb/test/data/cubes/file/__init__.py,
cubicweb/test/data/cubes/file/__pkginfo__.py,
cubicweb/test/data/cubes/file/views.py,
cubicweb/test/data/cubes/forge/__init__.py,
cubicweb/test/data/cubes/forge/__pkginfo__.py,
cubicweb/test/data/cubes/mycube/__init__.py,
cubicweb/test/data/cubes/mycube/__pkginfo__.py,
cubicweb/test/data/migration/0.1.0_common.py,
cubicweb/test/data/migration/0.1.0_repository.py,
cubicweb/test/data_schemareader/schema.py,
cubicweb/test/data/server_migration/bootstrapmigration_repository.py,
cubicweb/test/data/views.py,
cubicweb/test/unittest_binary.py,
cubicweb/test/unittest_mail.py,
cubicweb/test/unittest_repoapi.py,
cubicweb/test/unittest_schema.py,
cubicweb/test/unittest_toolsutils.py,
cubicweb/test/unittest_utils.py,
cubicweb/web/formwidgets.py,
cubicweb/web/test/data/entities.py,
cubicweb/web/test/unittest_http_headers.py,
cubicweb/web/test/unittest_views_basetemplates.py,
cubicweb/web/test/unittest_views_cwsources.py,
cubicweb/web/test/unittest_views_json.py,
cubicweb/web/views/json.py,
cubicweb/web/views/searchrestriction.py,
cubicweb/xy.py,
cubicweb/pyramid/auth.py,
cubicweb/pyramid/bwcompat.py,
cubicweb/pyramid/core.py,
cubicweb/pyramid/defaults.py,
cubicweb/pyramid/init_instance.py,
cubicweb/pyramid/__init__.py,
cubicweb/pyramid/login.py,
cubicweb/pyramid/predicates.py,
cubicweb/pyramid/profile.py,
cubicweb/pyramid/resources.py,
cubicweb/pyramid/rest_api.py,
cubicweb/pyramid/session.py,
cubicweb/pyramid/tools.py,
cubicweb/pyramid/test/__init__.py,
cubicweb/pyramid/test/test_bw_request.py,
cubicweb/pyramid/test/test_core.py,
cubicweb/pyramid/test/test_login.py,
cubicweb/pyramid/test/test_rest_api.py,
cubicweb/pyramid/test/test_tools.py,
cubicweb/pyramid/pyramidctl.py,
# vim: wrap sts=2 sw=2