Global configuration information is accessed throughout SkunkWeb as attributes of the SkunkWeb.Configuration pseudo-module, which, although accessed like a Python module, is actually a subclass of scope.Scopeable, a chameleon object the values of whose attributes can be made to vary depending on the environment to which it has been told to adapt. In SkunkWeb's requestHandler and web services, scoping is used to (potentially) modify the Configuration object on the basis of values in the request per se or the request environment, thereby making possible direct support for configurable virtual hosts (based on host name, port, and/or IP address), location directives, and other more exotic options.
Scoping is configured in the sw.conf file by the use of the Scope, Location, Host, Port and IP configuration directives, which look like (and are) Python method calls. The Scope directive is always the outer container of the other directives, taking their return values (scope.ScopeMatcher instances) as its arguments; it applies the ScopeMatchers passed to it to the Configuration object. The first argument of the other directives is a value which is matched against a value in the request; in the case of Port, for instance, it should be an integer which will be compared with the port on which the request came. Host, Port and IP then take an arbitrary number of unnamed ScopeMatcher arguments, which are applied only in the case that they and all their parents match the request; Location is excluded from this recursive bonanza. Host, Port, IP and Location all then take an arbitrary number of named arguments, which should be configuration options and their desired values.
Take, for example, the following possible Scope directive:
Scope(IP('192.168.65.12', Port(9887, job=REMOTE_JOB))) job=TEMPLATING_JOB
To turn on basic authentication for the directory '/private' for host 'www.foo.com', you could use the following:
Scope(Host(`www.foo.com', Location(`/private', basicAuthName='privileged zone', basicAuthFile='/usr/local/skunk/var/AUTHDB')))