Rum’s WSGI interface and facade to all of Rum’s functionallity.
To be able to configure the app programatically after it has been initialized you can pass the finalize = False parameter when instantiating it and call rum.app.RumApp.finalize() when you’re done.
Warning
It is mandatory that finalize() is called or else bad things will happen.
Wraps wsgi_app() with needed middleware.
Override this method to customize the way middleware is stacked.
When the finalize flag is False when initializing RumApp this method must be called after the app has been manually tweaked after initialization.
It is very important that this method is called.
Calls func with args as positional and kw as keyword arguments inside the context of this app.
It is neccesary to call this way any function that accesses any of the components accesible from this app when this app is not the current active app (ie: The one serving the request).
If you get a traceback saying that rum.app is None when using this app the this is probably what you’re looking for.
Warning
This is only here for compatibility with python < 2.6 (or python 2.5 without “from __future__ import with_statement”). It will be deprecated as soon as it is feasible to drop support for Python 2.4
Connects default routes used by this app when not handling resources.
Override this method if you want to register controllers at whatever URL point you need.
Registers URL endpoints to handle resource and a endpoints to handle each of the resources which are values of attributes with resource as a parent. The keys of the attributes dict are the remote names from which each value can be accessed from resource.
Example:
register(Person, dict(addresses=Address, jobs=Job))
Will register Person at (usually) /persons and Address and Job at /persons/${person_id}/addresses and /persons/${person_id}/jobs respectively.
All operations on Address and Job when accessed at these endpoints will have a particular Person as a parent.
Generate a URL for the routes whose dict most closely resembles kw. raise a RoutesException if no url could be generated.
Isomorphic to url_for() but issues an HTTP redirect to the resulting URL. The redirect code can be set with the _code keyword argument (303 See Other by default).
If the _use_next flag is passed as a keyword arg. then it will try to use the URL the client provided through the _next_redirect arg. if provided, else it will use the URL that was requested explicitly.
Returns a controller to handle request. Raises a “404 Not Found” if no controller could be found.
Returns a list of rum.fields.Field for a resource or a rum.fields.Field for attribute attr of resource if attr is not None.
Registers the singular and plural names for obj and its instances.
Return (singular, plural) names for resource.
Renders the first template that can be loaded of possible_templates using the renderer named renderer with variables from the data dict.
Sets up a dummy request so urls can be properly generated when using the app’s services outside of the context of a request handled by Rum.
Usage:
with rum_app.mounted_at('/admin'):
url = rum_app.url_for(obj=some_obj, action='edit')
form = rum_app.viewfactory(SomeClass, action='new')
etc ...
This feature requires Python 2.6 or 2.5 with: “from __future__ import with_statement”
This attribute is the rum.interfaces.IControllerFactory implementation that has been configured for this app. It’s job is to match routing arguments and return a rum.interfaces.IController implementator’s instance that will be used to handle the request.
This attribute is the rum.interfaces.IRepositoryFactory implementation that has been configured for this app. It’s job is to match routing arguments and return a rum.interfaces.IRepository implementator’s instance that will be used to broker access to the data source.
This attribute is the rum.interfaces.IViewFactory implementation that has been configured for this app. It’s job is to match routing arguments and return a rum.interfaces.IView or rum.interfaces.IInputView implementator’s instance that will be used to generate a view or validate input parameters for a resource.
This attribute is the rum.interfaces.IRouter implementation that has been configured for this app. It’s job is to match incoming URLs and HTTP methods and generate a routes dict.
This routes dict can be accessed at the rum.wsgiutils.RumRequest.routes attribute (Remember that the current request object is accesible at rum.app.request.
The encoder that has been configured for this app to serialize objects into JSON format
A paste.registry.StackedObjectProxy that points to the current rum.wsgiutils.RumRequest.
It will be None if outside the scope of a request (ie: RumApp has not been been __call__ ed)