TileStache.Config
index

The configuration bits of TileStache.
 
TileStache configuration is stored in JSON files, and is composed of two main
top-level sections: "cache" and "layers". There are examples of both in this
minimal sample configuration:
 
    {
      "cache": {"name": "Test"},
      "layers": {
        "example": {
            "provider": {"name": "mapnik", "mapfile": "examples/style.xml"},,
            "projection": "spherical mercator"
        } 
      }
    }
 
The contents of the "cache" section are described in greater detail in the
TileStache.Caches module documentation. Here is a different sample:
 
    "cache": {
      "name": "Disk",
      "path": "/tmp/stache",
      "umask": "0000"
    }
 
The "layers" section is a dictionary of layer names which are specified in the
URL of an individual tile. More detail on the configuration of individual layers
can be found in the TileStache.Core module documentation. Another sample:
 
    {
      "cache": ...,
      "layers": 
      {
        "example-name":
        {
            "provider": { ... },
            "metatile": { ... },
            "preview": { ... },
            "stale lock timeout": ...,
            "projection": ...
        }
      }
    }
 
In-depth explanations of the layer components can be found in the module
documentation for TileStache.Providers, TileStache.Core, and TileStache.Geography.

 
Modules
       
TileStache.Caches
TileStache.Core
TileStache.Geography
TileStache.Providers

 
Classes
       
Bounds
Configuration

 
class Bounds
    Coordinate bounding box for tiles.
 
  Methods defined here:
__init__(self, upper_left_high, lower_right_low)
Two required Coordinate objects defining tile pyramid bounds.
 
Boundaries are inclusive: upper_left_high is the left-most column,
upper-most row, and highest zoom level; lower_right_low is the
right-most column, furthest-dwn row, and lowest zoom level.
__str__(self)
excludes(self, tile)
Check a tile Coordinate against the bounds, return true/false.

 
class Configuration
    A complete site configuration, with a collection of Layer objects.
 
Attributes:
 
  cache:
    Cache instance, e.g. TileStache.Caches.Disk etc.
    See TileStache.Caches for details on what makes
    a usable cache.
 
  layers:
    Dictionary of layers keyed by name.
    
    When creating a custom layers dictionary, e.g. for dynamic
    layer collections backed by some external configuration,
    these dictionary methods must be provided for a complete
    collection of layers:
    
      keys():
        Return list of layer name strings.
 
      items():
        Return list of (name, layer) pairs.
 
      __contains__(key):
        Return boolean true if given key is an existing layer.
        
      __getitem__(key):
        Return existing layer object for given key or raise KeyError.
 
  dirpath:
    Local filesystem path for this configuration,
    useful for expanding relative paths.
 
  Methods defined here:
__init__(self, cache, dirpath)

 
Functions
       
buildConfiguration(config_dict, dirpath='.')
Build a configuration dictionary into a Configuration object.
 
The second argument is an optional dirpath that specifies where in the
local filesystem the parsed dictionary originated, to make it possible
to resolve relative paths.
enforcedLocalPath(relpath, dirpath, context='Path')
Return a forced local path, relative to a directory.
 
Throw an error if the combination of path and directory seems to
specify a remote path, e.g. "/path" and "http://example.com".
 
Although a configuration file can be parsed from a remote URL, some
paths (e.g. the location of a disk cache) must be local to the server.
In cases where we mix a remote configuration location with a local
cache location, e.g. "http://example.com/tilestache.cfg", the disk path
must include the "file://" prefix instead of an ambiguous absolute
path such as "/tmp/tilestache".
loadClassPath(classpath)
Load external class based on a path.
 
Example classpath: "Module.Submodule:Classname".
 
Equivalent soon-to-be-deprecated classpath: "Module.Submodule.Classname".

 
Data
        modules = {'ConfigParser': <module 'ConfigParser' from '/System/Library/Fra...ork/Versions/2.6/lib/python2.6/ConfigParser.pyc'>, 'FixTk': <module 'FixTk' from '/System/Library/Frameworks...work/Versions/2.6/lib/python2.6/lib-tk/FixTk.py'>, 'Image': <module 'Image' from '/usr/local/lib/python2.6/site-packages/PIL/Image.pyc'>, 'ImageColor': <module 'ImageColor' from '/usr/local/lib/python2.6/site-packages/PIL/ImageColor.pyc'>, 'ImageMode': <module 'ImageMode' from '/usr/local/lib/python2.6/site-packages/PIL/ImageMode.pyc'>, 'ImagePalette': <module 'ImagePalette' from '/usr/local/lib/python2.6/site-packages/PIL/ImagePalette.pyc'>, 'ModestMaps': <module 'ModestMaps' from '/Library/Python/2.6/site-packages/ModestMaps/__init__.py'>, 'ModestMaps.BlueMarble': <module 'ModestMaps.BlueMarble' from '/Library/Python/2.6/site-packages/ModestMaps/BlueMarble.pyc'>, 'ModestMaps.CloudMade': <module 'ModestMaps.CloudMade' from '/Library/Python/2.6/site-packages/ModestMaps/CloudMade.pyc'>, 'ModestMaps.Core': <module 'ModestMaps.Core' from '/Library/Python/2.6/site-packages/ModestMaps/Core.pyc'>, ...}
stderr = <open file '<stderr>', mode 'w' at 0x100416140>