cubicweb.pyramid.core#

Binding of CubicWeb connection to Pyramid request.

cubicweb.pyramid.core.includeme(config)[source]#

Enables the core features of Pyramid CubicWeb.

Automatically called by the ‘pyramid’ command, or via config.include('cubicweb.pyramid.code'). In the later case, the following registry entries must be defined first:

‘cubicweb.config’

A cubicweb ‘config’ instance.

‘cubicweb.repository’

The correponding cubicweb repository.

‘cubicweb.registry’

The vreg.

cubicweb.pyramid.core.repo_connect(request, repo, eid)[source]#

A lightweight version of cubicweb.server.repository.Repository.connect() that does not keep track of opened sessions, removing the need of closing them

cubicweb.pyramid.core.get_principals(login, request)[source]#

Returns the group names of the authenticated user.

This function is meant to be used as an authentication policy callback.

It also pre-open the cubicweb session and put it in request._cw_cached_session for later usage by _cw_session().

Note

If the default authentication policy is not used, make sure this function gets called by the active authentication policy.

Parameters
  • login – A cubicweb user eid

  • request – A pyramid request

Returns

A list of group names

cubicweb.pyramid.core._cw_session(request)[source]#

Obtains a cw session from a pyramid request

Parameters

request – A pyramid request

Returns type

cubicweb.server.session.Session

Not meant for direct use, use request.cw_session instead.

cubicweb.pyramid.core._cw_cnx(request)[source]#

Obtains a cw session from a pyramid request

The connection will be commited or rolled-back in a request finish callback (this is temporary, we should make use of the transaction manager in a later version).

Not meant for direct use, use request.cw_cnx instead.

Parameters

request – A pyramid request

Returns type

cubicweb.server.session.Connection