morepath.publish – Web publisher¶
Functionality to turn a
morepath.Request into a
morepath.Response using Morepath configuration. It looks up a
model instance for the request path and parameters, then looks up a
view for that model object to create the response.
The publish module:
- resolves the request into a model object.
- resolves the model object and the request into a view.
- the view then generates a response.
It all starts at
Consume path segments from request to find model obj.
Removes the successfully consumed path segments from
morepath.traject.Traject.consume()to consume path segments according to path configuration.
Extracts URL parameters from the path.
Gets a factory function and uses matched path variables and URL parameters to construct the model instance (or
The new model object, or a mounted
Noneif no new instance could be found.
Determine view name from leftover stack of path segments
Parameters: stack – a list of path segments left over after consuming the path. Returns: view name string or
Noneif no view name can be determined.
Handle request and return response.
Resolve request to a model object.
This takes the path information as a stack of path segments in
morepath.Request.unconsumedand consumes it step by step using
consume()to find the model object as declared by
morepath.App.path()directive. It can traverse through mounted applications as indicated by the
The implicit Reg lookup used to look up generic dispatch functions is set to the app and is updated to the mounted application when traversing into it.
Returns: model object or
Noneif not found.
Given model object and request, create response.
get_view_name()to set up the view name on the request object.
If no view name exist it raises
It then uses
morepath.generic.view()to resolve the view for the model object and the request by doing dynamic dispatch.
- obj – model object to get response for.
- request –