I'm a few months into learning python. After going through pyramid tutorials I'm having trouble understanding a line in the init.py
from pyramid.config import Configurator
from sqlalchemy import engine_from_config
from .models import (
DBSession,
Base,
)
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
config = Configurator(settings=settings)
config.include('pyramid_chameleon')
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.scan()
return config.make_wsgi_app()
I'm lost about settings=settings in the configurator argument.
What is this telling python?
Python functions support keyword arguments:
def add(a, b):
return a + b
add(a=1, b=2)
This happens here.
Configurator(settings=settings)
The first settings
is the name of the parameter in the __init__
of Configurator
. The second is a name for an object in the current name space.