mewlo.mpacks.core.route.mroute module

mroute.py This file contains classes to support url routes

class mewlo.mpacks.core.route.mroute.MewloRoute(id, path, controller, args=, []allow_extra_args=False, extras=None, forcedargs=None)[source]

Bases: object

The MewloRoute class represents a single route.

DEF_ARGID_extraargs = 'extraargs'
build_structure(parent, mewlosite, eventlist)[source]

Startup any info/caching; this is called before system startup by our parent site.

construct_url(flag_relative=True, args={})[source]

Construct a url for this route. ATTN: TODO - this is preliminary version; eventually we will want to be able to accept info for context so we can fill parameters.

dumps(indent=0)[source]

Return a string (with newlines and indents) that displays some debugging useful information about the object.

force_args(argdict)[source]

Merge in forced args (i use an explicit loop here because argdict is not likely to remain a pure dictionary in future code).

get_controllerroot()[source]
get_extras()[source]
get_id()[source]
get_isgroup()[source]
get_mewlosite()[source]
get_parent()[source]
get_routegroup()[source]
handle_request(mewlosite, request, argdict)[source]

We matched against this route, so WE will handle the request.

invoke_routecall(request)[source]

Invoke the specified function by route string This requires a little bit of magic, since we are going to launch the function given its dotted path name

match_args(requestargstring)[source]

Split argstring into ‘/’ separated args and try to match against route args. :return: tuple(didmatchargs, argdict, failure), where:

  • didmatchargs is True on match or False on no match.
  • argdict is a dictionary with argid = value entries.
  • failure is None on success

if didmatchargs = False, then caller should treat failure as explanation for failure to match rather than as an error per se. ATTN: we may want to rewrite this and not use failure = EFailure() on “failure” because this is inefficient when frequenly it just means it didn’t match the route and we don’t care about the failure code and it is just ignored; though it might be useful for debugging purposes sometimes.

process_request(mewlosite, request)[source]

Called to see if we this route matches the request. :return: True if the request is for this site and we have set request.response :return: False if we fail to match

class mewlo.mpacks.core.route.mroute.MewloRouteArg(id, required, positional, help, defaultval)[source]

Bases: object

The MewloRouteArg represents a single route argument.

dumps(indent=0)[source]

Return a string (with newlines and indents) that displays some debugging useful information about the object.

get_argtypestr()[source]

Just nice label for display.

get_isflag()[source]

Return true if this arg type is a flag; base class returns False; subclasses may override.

validate_argvalue(argval)[source]

Check arg type and value. :return: tuple (argval, failure) where argval is CONVERTED/COERCED argval, or None on failure

class mewlo.mpacks.core.route.mroute.MewloRouteArgFlag(id, required=True, positional=False, help=None, defaultval=None)[source]

Bases: mewlo.mpacks.core.route.mroute.MewloRouteArg

The MewloRouteArg represents a single route argument.

get_argtypestr()[source]

Just nice label for display.

get_isflag()[source]
validate_argvalue(argval)[source]
class mewlo.mpacks.core.route.mroute.MewloRouteArgInteger(id, required=True, positional=False, help=None, defaultval=None)[source]

Bases: mewlo.mpacks.core.route.mroute.MewloRouteArg

The MewloRouteArg represents a single route argument.

get_argtypestr()[source]

Just nice label for display.

validate_argvalue(argval)[source]
class mewlo.mpacks.core.route.mroute.MewloRouteArgString(id, required=True, positional=False, help=None, defaultval=None)[source]

Bases: mewlo.mpacks.core.route.mroute.MewloRouteArg

The MewloRouteArg represents a single route argument.

get_argtypestr()[source]

Just nice label for display.

validate_argvalue(argval)[source]
class mewlo.mpacks.core.route.mroute.MewloRouteGroup(id='', controllerroot=None, routes=None)[source]

Bases: object

The MewloRouteGroup class holds a list of routes (or child RouteGroups); it’s a way of letting us organize collections of routes

append(routes)[source]

Append a new route (or list of routes) (or hierarchical routegroups) to our routes list.

build_routehash()[source]

Build hash of all routes in entire collection.

build_structure(parent, mewlosite, eventlist)[source]

Initial preparation, invoked by parent.

dumps(indent=0)[source]

Return a string (with newlines and indents) that displays some debugging useful information about the object.

get_controllerroot()[source]
get_isgroup()[source]
get_parent()[source]
get_pathprefix()[source]
lookup_route_byid(routeid)[source]

Lookup routeid in our hash of all routes.

process_request(mewlosite, request)[source]

Walk through the site list and let each site take a chance at processing the request.

set_controllerroot(controllerroot)[source]
set_pathprefix(pathprefix)[source]
class mewlo.mpacks.core.route.mroute.MewloRouteManager(mewlosite, debugmode)[source]

Bases: mewlo.mpacks.core.manager.manager.MewloManager

The MewloRouteManager class manages the routes in a site; it is a thin class that owns a single route group

append(routes)[source]

Append a new route (or list of routes) (or hierarchical routegroups) to our routes list.

build_routeurl_byid(routeid, flag_relative, args)[source]

Build a url to a route with some optional args.

description = 'Manages all url routes that are used to parse urls and route them to the proper controllers'
dumps(indent=0)[source]

Return a string (with newlines and indents) that displays some debugging useful information about the object.

lookup_route_byid(routeid)[source]

Lookup routeid in our hash of all routes.

process_request(mewlosite, request)[source]

Walk through the site list and let each site take a chance at processing the request.

startup_prep(stageid, eventlist)[source]

This is invoked by site strtup, for each stage specified in startup_stages_needed() above.

typestr = 'core'

Table Of Contents

Previous topic

mewlo.mpacks.core.route package

Next topic

mewlo.mpacks.core.route.mroute_staticfiles module

This Page