"""
Per-site stuff
"""
import imp
SITE_DIR = "sites"
class Site (object) :
"""
A site is a website and its configuration
"""
def __init__ (self, name) :
"""
The given name must be like a valid hostname, e.g. 'www.qmsk.net'
"""
# store
self.name = name
# load the site
self._load()
def _load (self) :
"""
Loads this site, as a python module (i.e. dir with __init__.py)
"""
# first, we need to find it
file, pathname, description = imp.find_module(self.name, [SITE_DIR])
# then, we can load it
self.module = imp.load_module(self.name, file, pathname, description)
# create our mapper
self.mapper = self.module.build_mapper()
def get_mapper (self) :
"""
Return the Mapper for this site
"""
return self.mapper
def lookup (request) :
"""
Lookup and return a Site object for the given request
"""
# request hostnmae
hostname = request.env.get('HTTP_POST')
# XXX: hardcoded for now
return Site("www.qmsk.net")