rpymostat.engine.site_hierarchy module

class rpymostat.engine.site_hierarchy.SiteHierarchy(apiserver, app, dbconn, parent_prefix)[source]

Bases: object

Helper class to implement hierarchical sites in Klein. All engine classes that provide routes must implement this.

_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 29
_abc_registry = <_weakrefset.WeakSet object>
_parse_json_request(request)[source]

Parse a JSON request; return the deserialized request or raise an exception.

Parameters:request (instance of twisted.web.server.Request) – the request
Returns:deserialized request JSON
Return type:str
add_route(func, path=None, methods=['GET'])[source]

Add a route to app, mapping func (a callable method in this class) to path (under self.prefix). If path is none, it will be mapped directly to self.prefix.

Parameters:
  • func – callable in this class to map to path
  • path (str) – path to map method to
  • methods (list) – methods allowed for this route
make_prefix(parent_list, prefix_str)[source]

Given a list of the parent’s prefix and our prefix string, construct a new list with our prefix.

Parameters:
  • parent_list (list) – parent’s prefix
  • prefix_str (str) – our prefix string
Returns:

our prefix list

Return type:

list

prefix_list_to_str(prefix_list)[source]

Convert a prefix list to a string path prefix.

Parameters:prefix_list (list) – the list to convert
Returns:prefix string
Return type:str
prefix_part = 'base'
setup_routes()[source]

Setup all routes for this class. Must be implemented by subclasses.