Migrating to v4#
Prerequisite#
You have read the ChangeLog of CubicWeb 4.
You already upgraded your CubicWeb application to CubicWeb 3.38,
which means you may or not have changed all your import from
cubicweb.web
to cubicweb_web
and installed cubicweb-web
package, according to 3.38 changelog.
In this version we removed import proxying to cubicweb_web
.
This means that you can no longer import cubicweb.web
.
As described in 3.38 changelog, there is a script here
https://forge.extranet.logilab.fr/cubicweb/cw_versions_migration_tools
made to ease this migration.
Breaking changes and how to keep your application working#
AutomaticWebTest
,how_many_dict
andAutoPopulateTest
have been moved fromcubicweb.devtools.testlib
tocubicweb_web.devtools.testlib
.cubicweb.pyramid.bwcompat
module have been moved tocubicweb_web
.cubicweb.sobjects.notification.RecipientFinder
is no more acomponent
, but aservice
. Thus, this class and all its potential children are now inservices
registry instead ofcomponents
registry.- Configuration classes have been simplified:
cubicweb.server.serverconfig.ServerConfiguration
have been merged intocubicweb.cw_config.CubicWebConfiguration
, you have to use this one instead ofServerConfiguration
all methods and options from
cubicweb.devtools.TestServerConfiguration
, andcubicweb.devtools.apptest_config.BaseApptestConfiguration
are now in the classcubicweb.devtools.apptest_config.ApptestConfiguration
CubicWeb configuration classes no longer include anything related to the
cubicweb_web
package.
All methods, attributes and properties related to CubicWeb-Web in
cubicweb.devtools.testlib.CubicWebTC
class have been moved into the classcubicweb_web.devtools.testlib.WebCWTC
, which is now the base class for all CubicWeb-Web related tests (if you need Pyramid and CubicWeb-Web, youâll have to usecubicweb_web.devtools.testlib.PyramidWebCWTC
).cubicweb.devtools.fake.FakeRequest
have been moved tocubicweb_web.devtools.testlib
.cubicweb.ext.rest
have been moved tocubicweb_web.ext.rest
, thuscubicweb.devtools.apptest_config.ApptestConfiguration
no longer initialize rest components.cubicweb.predicates.paginated_rset
have been moved tocubicweb_web.predicates.paginated_rset
.cubicweb.pyramid.url_redirections
have been moved tocubicweb_web.pyramid.url_redirection
, thus,add_redirection_rule
pyramid directive is no longer usable withoutcubicweb_web
.cubicweb.utils.HTMLHead
andcubicweb.utils.HTMLStream
have been moved tocubicweb_web.utils
.has_cw_permission
pyramid view and route predicates are now incubicweb_web.pyramid.predicates
cubicweb.rset.limited_rql
ResultSet
method is now a function which can be called fromcubicweb_web.views.navigation.limited_rql
and_limit_offset_rql
ResultSet
method is now a function which can be called fromcubicweb_web.views.navigation._limit_offset_rql
.cubicweb.web.webconfig.WebConfiguration
have been moved tocubicweb_web.webconfig
.cubicweb.devtools.RealDatabaseConfiguration
have been removed. You can redo it yourself by heriting fromcubicweb.devtools.apptest_config.ApptestConfiguration
and adding the following class attributes:skip_db_create_and_restore = True
andread_instance_schema = True
.by default, there is no more session added to the pyramid request. Thus, you cannot access
request.session
anymore if you donât use pyramid_session_redis or if you donât includecubicweb.pyramid.session
in pyramid.ini (see below).cubicweb.pyramid.auth
is no longer included by default in pyramid config, you will need to add it manually in pyramid.ini (see below)Since
cubicweb.pyramid.session
andcubicweb.pyramid.auth
are now included only in pyramid.ini, you may need to add them manually in your test, insettings
class attribute ofcubicweb_web.devtools.testlib.PyramidWebCWTC
. For instance:settings = {"cubicweb.includes": ["cubicweb.pyramid.auth", "cubicweb.pyramid.session"]}
.Now, all modules in the
cubicweb.includes
directives in the pyramid.ini file are included before all cubesâinclude
directives.
Pyramid configuration file: pyramid.ini
#
cubicweb.defaults
option has been removed from explicit inclusions. Previously,cubicweb.defaults
added 3 modules:cubicweb.pyramid.login
,cubicweb.pyramid.auth
andcubicweb.pyramid.session
.cubicweb.pyramid.login
is now in CubicWeb-Web;cubicweb.pyramid.auth
andcubicweb.pyramid.session
need to be included incubicweb.includes
directive (see pyramid file template). By default,cubicweb.pyramid.session
is commented, thus there is no infinite CWSession objects created in your database if you forget to use an other session storage in production. This also means you can no longer userequest.session
.Two other module are included by default in pyramid.ini when you create your instance:
cubicweb.pyramid.rest_api.include_html
andcubicweb.pyramid.rest_api.include_rdf
. They add respectively default RDF views and default HTML views in order to describe entities.If you create a new instance, you will have a better pyramid.ini from our new upgraded template. In order to migrate an old instance, you may want to take a look at the template here
As before, all directive in pyramid.ini can be added in tests using
settings
class attribute ofcubicweb_web.devtools.testlib.PyramidWebCWTC
. For instance:settings = {"cubicweb.includes": ["cubicweb.pyramid.auth", "cubicweb.pyramid.session"]}
.
Content negociation#
CubicWeb 4 keep by default a mecanism allowing to have entities description
in html or in RDF. They can be disabled or enabled in pyramid.ini
configuration
file.
CubicWebRequest#
There is no longer CubicWebRequest inside Pyramid Request (except if you add
cubicweb-web
cube). However, there is still a cubicweb connection accessible
by request.cw_cnx
, which can be used for many purpose, for instance execute RQL
queries.
Translations#
A lot of translations were generated for cubicweb.web views and components. These
translations had been moved to cubicweb-web
cube, and its generations too.
In order to still have it, you will need to add a cubicweb.i18ncube
entrypoint to your package:
"cubicweb.i18ncube": [
"<your cube name>=cubicweb_web.i18n:WebI18nCubeMessageExtractor",
]
With <your cube name>
being the name of your cube.