The request package and its primary class, Request, provide the "m" object in Myghty templates. The Request is instantiated by the Interpreter and handles component execution state as well as buffered state. It provides the interface to all actions taken by components, such as writing output, calling other components, calling subrequests, and controllling request state. Also provides the programmatic interface to key objects such as caches and sessions.
def instance() | |
returns the Request instance corresponding to the current thread |
|
def threadlocal(value=None) | |
returns a thread local container, with initial value that of the given variable |
request object, calls components and directs output. also is the primary programmatic interface presented to a template's environment.
the component package defines the Component class and several subclasses. FileComponent serves as the base class for template style-components, and ModuleComponent the base for module-based components.
Base class for all components. the primary method is the run() method which executes the Component in the context of a particular request. A Component instance is usually cached in memory based on its component ID and can execute many requests simultaneously.
a component that corresponds to a Myghty template file
A ModuleComponent that contains methods specific to a generic HTTP request.
def do_get(self, m, r, **params) | |
def do_post(self, m, r, **params) | |
def do_run_component(self, m, r, **params) | |
A component that is a regular Python class inside of a plain Python module.
a component that corresponds to a <%def> or <%method> tag inside a file-based component.
The interp package and its primary class, Interpreter, represents the runtime environment for Myghty components. It serves as a "home base" for configuration information and request construction, and also assists the Request object in locating components. The Interpreter maintains a pool of component objects and handles, at a high level, their compilation and filesystem representation.
Represents an environment in which to create requests, compile and execute components.
a ResolveFile rule that adds a pre-path-concatenation adjustment step, so the uri can be translated before determining the file path. unlike path_translate, this translated uri is only used to determine a filesystem path, and is not propigated anywhere else.
def __init__(self, adjust, *component_roots) | |
conditionally executes a rule, only executes if the uri matches a certain regexp, or a passed-in context string matches one of the contexts set up for this rule.
combines a Conditional and a Group to make a conditionally-executing Group.
def __init__(self, regexp=None, context=None, rules=[]) | |
creates a subgroup of resolver strategies.
def __init__(self, rules=[]) | |
def do(self, uri, remaining, resolution_detail, **params) | |
def do_init_resolver(self, resolver, remaining_rules, **params) | |
returns not found. place at the bottom of Group and Match chains to have them terminate.
performs path translation rules on the given uri and sends control off to the next rule.
def __init__(self, *translations) | |
def do(self, uri, remaining, resolution_detail, **params) | |
def do_init_resolver(self, resolver, remaining_rules, path_translate=None, **params) | |
def modifies_uri(self) | |
collects all the resolver rules below it and runs them for the requested uri, and if not found re-runs them again for the "dhandler" filename, pruning off path tokens until the root is reached.
def __init__(self, dhandler_name='dhandler') | |
def do(self, uri, remaining, resolution_detail, enable_dhandler=False, declined_components=None, **params) | |
performs file based resolution. looks up files within one or more component roots.
def __init__(self, *component_roots, **params) | |
def do(self, uri, remaining, resolution_detail, **params) | |
def do_init_resolver(self, resolver, remaining_rules, component_root=None, **params) | |
resolves a Module Component based on information in a given list of dictionaries, containing regular expressions for keys which are matched against the URI. The value for each key references either a class, a callable object or function, or a string in the form "<module>:<path.to.callable>".
def __init__(self, *module_components) | |
def do(self, uri, remaining, resolution_detail, context=None, **params) | |
def do_init_resolver(self, resolver, remaining_rules, module_components=None, **params) | |
resolves a callable object or class instance inside a module, based on a traversal of path tokens corresponding to the module's file location, and then of the object paths defined within the module.
takes the rules below it and applies "search upwards" logic to them, where it iteratively breaks off path tokens behind the filename and searches upwards until the root path is reached. if require_context is True, then this rule only takes effect if "search_upwards" is sent within the resolution options. this indicates that the upwards resolve is context-sensitive, and therefore should not be cached based on a URI alone. however, by default it allows its results to be cached since in practice its used strictly for autohandlers, which are always searched upwards.
def __init__(self, require_context=True) | |
def do(self, uri, remaining, resolution_detail, search_upwards=False, **params) | |
resolves incoming URIs against a list of rules, and returns Resolution objects and/or raises ComponentNotFound exceptions.
base class for a single rule that attempts to resolve a uri into a Resolution object. acts inside a chain of ResolverRules where when a uri cannot be resolved, the next rule in the chain is called in a continuation pattern.
caches the result of either a given nested rule, or the remaining rules in its chain, based on the incoming URI.
a time-sensitive descriptor object for a Myghty component.
def __init__(self, id, path_id, path, file_path, last_modified=None) | |
def get_component_source(self) | |
def get_component_source_file(self) | |
def __init__(self, source, id=None, last_modified=None) | |
def get_component_source(self) | |
def get_component_source_file(self) | |
represents a loadable module containing either a ModuleComponent class, a function, a class instance which is callable or a method on a class instance.
a metaclass for ModuleComponentSource which allows its constructor to cache the inspection results of the "arg" constructor parameter.
def __init__(self, data_dir=None, **params) | |
def clone(self, **params) | |
def get_session(self, request, **params) | |
session object that uses container package for storage
extends python cookie to give digital signature support
def __init__(self, secret, input=None) | |
def value_decode(self, val) | |
def value_encode(self, val) | |