I'm unsure of what I should be putting in the "def main(global_config,
**settings):" function and what should go in "def includeme(config):"
function in __init__.py for my top-level application package.
Right now they look like this for me, but I patched it together over time
and am not sure what is the proper way to be dividing it up.
I see the "config.include('myapp')" is calling includeme, but couldn't I
replace that line with the 4 lines from includeme and get rid of includeme?
What is the best practice behind using includeme?
def main(global_config, **settings):
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
config = Configurator(settings=settings)
config.set_root_factory(RootFactory)
config.set_session_factory(SignedCookieSessionFactory('...'))
config.include('myapp')
config.include('pyramid_mako')
config.include('pyramid_chameleon')
config.add_static_view('deform_static', 'deform:static')
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
# Add all other routes here...
config.scan()
return config.make_wsgi_app()
def includeme(config):
authz_policy = ACLAuthorizationPolicy()
config.set_authorization_policy(authz_policy)
authn_policy = AuthTktAuthenticationPolicy('...', hashalg='sha512')
config.set_authentication_policy(authn_policy)
I've seen includeme used in some examples of writing pyramid tests, but I'm
still not sure. If the idea is to allow tests to have a lot of the context
of the regular app, then shouldn't I instead move most of the lines from
main to includeme and allow tests to call "config.include('myapp')"? In
this case main would just basically return config.make_wsgi_app() after
calling includeme?
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.