Skip to content

Tech Meeting ·· What's new in C2C WSGI Utils 5.0

Stéphane Brunner edited this page Mar 17, 2022 · 3 revisions

Goals

No more use the Docker image as base image in your project but use the pypi package with standard extra c2cwsgiutils[standard] this is to:

  • Be able to choose the base image that's you need, (e.g. osgeo/gdal :-) ).
  • To lock the python dependency only at one place.

Have less magic in the project, to be easier to understand and to integrate in a new project.

Be nearer on what the projects provide around the paste application.

Better support of tools like proute, pview, ...

Implication

You need to update your project configuration files, you will provide the form scratch.

Configuration

We provide an example application (that's tested in the CI)

C2cwsgiutils will be a Pyramid extension that we use it with the include me.

We decide to use Gunicorn and Paste (for the dev) as it's thinking by the project, for Paste there is no big changes, the main changes got Gunicorn:

  • The application will be provided as a Paste application, no more as a WSGI application.
  • The logging configuration will be managed by Gunicorn.

The than then concerned configuration files are:

Notable parts:

development.ini

Almost the same as before, we just add the filter configuration

production.ini

The logging configuration is moved to gunicorn.conf.py, me also add the filter configuration

gunicorn.conf.py

Dockerfile

New features

Support of login with GitHub (OAuth, Should be deeper tested)

Other information

DBsession

We can use a global object models.DBSession as it's done before or having it on the request request.dbsession as it's done in the cookie cutter scaffold.

Command lines

Some function for the command lines https://github.com/camptocamp/c2cwsgiutils/blob/master/c2cwsgiutils/setup_process.py https://github.com/camptocamp/c2cwsgiutils#custom-scripts

# Add arguments
c2cwsgiutils.setup_process.fill_arguments(parser)
# Bootstrap the application
env = c2cwsgiutils.setup_process.bootstrap_application_from_options(args)
settings = env["registry"].settings
# Just initializing the logging
loader = pyramid.scripts.common.get_config_loader(args.config_uri)
loader.setup_logging(parse_vars(args.config_vars) if args.config_vars else None)
settings = loader.get_settings()

Final note

If you have an issue, especially if you didn't have any logs, ask me :-)