Bases: builtins.object
Base WSGI application class to handle Views.
Controllers try to call methods wrapped by uiro.view.view_config. But actually it will call _wrapped attribute of each Views:
You can inherit this class and register views. Then, decorate views with uiro.view.view_config to apply configation to each views, such as witch views will be call or witch template to use.
class DashboardController(BaseController):
@view_config(method='get')
def get_view(self, request):
return "Hello guys"
@view_config(method='post')
def post_view(self, request):
return "Posted something"
Check the behavior of view_config for more detail.
Bases: builtins.type
Bases: builtins.Exception
Error for notifying the resource was not found.
Initializing database settings by using config from .ini file.
Creating a matching for WSGI application to serve static files for passed app.
Static files will be collected from directory named ‘static’ under passed application:
./blog/static/
This example is with an application named blog. URLs for static files in static directory will begin with /static/app_name/. so in blog app case, if the directory has css/main.css file, the file will be published like this:
yoursite.com/static/blog/css/main.css
And you can get this URL by reversing form matching object:
matching.reverse('blog:static', path=['css', 'main.css'])
Returning a matching containing applications to serve static files correspond to each passed applications.
Getter function of templates for each applications.
Argument name will be interpreted as colon separated, the left value means application name, right value means a template name.
get_app_template(‘blog:dashboarb.mako’)
It will return a template for dashboard page of blog application.
Returning the lookups
The global variable _lookups should not be imported directory by another modules. By importing directory, the value will not change evenif setup_lookup
Registering template directories of apps to Lookup.
Lookups will be set up as dictionary, app name as key and lookup for this app will be it’s value. Each lookups is correspond to each template directories of apps._lookups. The directory should be named ‘templates’, and put under app directory.
Bases: builtins.object
Predicate class to checking Method of request object.
MethodPredicate is preserve views when the request method was not same with applied in instantiate.
Bases: builtins.Exception
Called view was not apposite. This exception is to notify Controllers that called view was not apposite to the applied rquest.
basic View Wrappers used by view_config.
Raising ViewNotMatched when applied request was not apposite.
preserve_view calls all Predicates and when return values of them was all True it will call a wrapped view. It raises ViewNotMatched if this is not the case.
Predicates: This decorator takes Predicates one or more, Predicate is callable to return True or False in response to inputted request. If the request was apposite it should return True.
Decorator to specify which template to use for Wrapped Views.
It will return string rendered by specified template and returned dictionary from wrapped views as a context for template. The returned value was not dictionary, it does nothing, just returns the result.
Creating Views applied some configurations and store it to _wrapped attribute on each Views.
Entry point to create Uiro application.
Setup all of necessary things:
- Getting root matching
- Initializing DB connection
- Initializing Template Lookups
- Collecting installed applications
- Creating apps for serving static files
and will create/return Uiro application.