This module deals with marshalling information from the user to the install process for an application. We divide this process into two parts: this module addresses the specification of what fields the application is requesting, and submodules implement controller logic for actually getting this information from the user. Common logic between controllers is stored in this module.
ArgSchema is composed of two orthogonal components: a dictionary of Arg objects (which may be organized using ArgSet) and a list of Strategy objects. An Arg contains information about a given argument, and specified at compile-time by an application, while a Strategy contains a possible procedure for automatically determining what the contents of some argument are, and is specified at run-time by the user (this is not quite true yet, but will be soon). Some arguments are most commonly used together, so we group them together as an ArgSet and allow applications to refer to them as a single name.
Represents a strategy for calculating arg values without user input.
Under many circumstances, making some assumptions about the server environment means that we don’t actually have to ask the user for values such as the host or the path: these tend to be side effect free strategies. Furthermore, we may have utility scripts present that can automatically configure a new database for a user when one is necessary: these are side effectful computations.
Note for an implementor: it is perfectly acceptable to calculate preliminary results in prepare(), store them as underscore prefixed variables, and refer to them from execute().
The wizard.app.Application being installed.
The directory we are being installed to.
Performs effectful computations associated with this strategy, and mutates options with the new values. Behavior is undefined if prepare() was not called first. If this method throws an exception, it should be treated as fatal.
Performs all side-effectless computation associated with this strategy. It also detects if computation is possible, and raises StrategyFailed if it isn’t.
Arguments that this strategy provides
Whether or not this strategy has side effects.
The directory web stub files are being installed to.
Represent a required, named argument for installation.
Callback that this argument wants to get run on options after finished
Name of the environment variable containing this arg.
Help string
Attribute name of the argument
If true, is a password
String to display if prompting a user for a value
String “type” of the argument, used for metavar
Represents a set of named installation arguments that are required for an installation to complete successfully. Arguments in a set should share a common prefix and be related in functionality (the litmus test is if you need one of these arguments, you should need all of them). Register them in preloads().
Schema container for arguments.
Valid identifiers for subclasses of ArgSet are:
The options web_path and web_host are automatically required.
Example:
parser = ArgHandler("db", "admin", "email")
parser.add(Arg("title", help="Title of the new application"))
Adds an argument to our schema.
Populates strategies and provides
Fills an object with all arguments pre-set to None.
Load values from strategy. Must be called after commit(). We omit strategies whose provided variables are completely specified already. Will raise MissingRequiredParam if strategies aren’t sufficient to fill all options. It will then run any callbacks on arguments.
Set of arguments that are already provided by strategies.
Bases: wizard.install.ArgSet
Common arguments for any application that lives on the web.
Bases: wizard.install.ArgSet
Common arguments for applications that use a database.
Bases: wizard.install.ArgSet
Common arguments when an admin account is to be created.
Bases: wizard.install.ArgSet
Common arguments when an administrative email is required.
Bases: wizard.install.ArgSet
Common arguments when a title is required.
Bases: wizard.install.Strategy
Fills in values from environment variables, based off of Arg.envname from schema.
Sets undefined options to their environment variables.
This strategy is always available.
Bases: wizard.install.Strategy
Performs guesses for web variables using the URL hook.
No-op.
Uses deploy.web().
Fetches a web page from the autoinstall, usually to perform database installation. path is the path of the file to retrieve, relative to the autoinstall base (options.web_path), not the web root. post is a dictionary to post. options is the options object generated by OptionParser.
Base error class for this module.
Bases: wizard.install.Error
Strategy couldn’t figure out values.
Bases: wizard.install.Error
You passed a preload that was not recognized.
The preloads that were not recognized.
Bases: wizard.install.Error
You missed a required argument, and we couldn’t generate it. Controllers should catch this exception and provide better behavior.
The names of the arguments that were not specified.