Edit me on GitHub

pyramid.scripting

get_root(app, request=None)[source]

Return a tuple composed of (root, closer) when provided a router instance as the app argument. The root returned is the application root object. The closer returned is a callable (accepting no arguments) that should be called when your scripting application is finished using the root.

request is passed to the Pyramid application root factory to compute the root. If request is None, a default will be constructed using the registry’s Request Factory via the pyramid.interfaces.IRequestFactory.blank() method.

prepare(request=None, registry=None)[source]

This function pushes data onto the Pyramid threadlocal stack (request and registry), making those objects ‘current’. It returns a dictionary useful for bootstrapping a Pyramid application in a scripting environment.

request is passed to the Pyramid application root factory to compute the root. If request is None, a default will be constructed using the registry’s Request Factory via the pyramid.interfaces.IRequestFactory.blank() method.

If registry is not supplied, the last registry loaded from pyramid.config.global_registries will be used. If you have loaded more than one Pyramid application in the current process, you may not want to use the last registry loaded, thus you can search the global_registries and supply the appropriate one based on your own criteria.

The function returns a dictionary composed of root, closer, registry, request and root_factory. The root returned is the application’s root resource object. The closer returned is a callable (accepting no arguments) that should be called when your scripting application is finished using the root. registry is the registry object passed or the last registry loaded into pyramid.config.global_registries if no registry is passed. request is the request object passed or the constructed request if no request is passed. root_factory is the root factory used to construct the root.

Previous topic

pyramid.response

Next topic

pyramid.security