pyramid_cubicweb.core

pyramid_cubicweb.core.includeme(config)[source]

Enables the core features of Pyramid CubicWeb.

Automatically called by the ‘pyramid’ command, or via config.include('pyramid_cubicweb.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.
pyramid_cubicweb.core.cw_to_pyramid(*args, **kwds)[source]

Context manager to wrap a call to the cubicweb API.

All CW exceptions will be transformed into their pyramid equivalent. When needed, some CW reponse bits may be converted too (mainly headers)

pyramid_cubicweb.core.render_view(request, vid, **kwargs)[source]

Helper function to render a CubicWeb view.

Parameters:
  • request – A pyramid request
  • vid – A CubicWeb view id
  • **kwargs

    Keyword arguments to select and instanciate the view

Returns:

The rendered view content

pyramid_cubicweb.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

pyramid_cubicweb.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

It 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

class pyramid_cubicweb.core.CubicWebPyramidRequest(request)[source]

Bases: cubicweb.web.request.ConnectionCubicWebRequestBase

A CubicWeb request that only wraps a pyramid request.

Parameters:request – A pyramid request
message

Returns a ‘<br>’ joined list of the cubicweb current message and the default pyramid flash queue messages.

pyramid_cubicweb.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.

pyramid_cubicweb.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
pyramid_cubicweb.core._cw_request(request)[source]

Obtains a CubicWeb request wrapper for the pyramid request.

Parameters:request – A pyramid request
Returns:A CubicWeb request
Returns type:CubicWebPyramidRequest

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