#!/usr/bin/python
-import ConfigParser as configparser
-
-import accounts
-import ads
-import database
-import geoip
-import fireinfo
-import iuse
-import memcached
-import mirrors
-import netboot
-import nopaste
-import news
-import planet
-import releases
-import settings
-import talk
+import configparser as configparser
+import io
+from . import accounts
+from . import database
+from . import geoip
+from . import fireinfo
+from . import iuse
+from . import mirrors
+from . import netboot
+from . import nopaste
+from . import releases
+from . import settings
+from . import talk
+
+from . import blog
from . import zeiterfassung
+DEFAULT_CONFIG = io.StringIO("""
+[global]
+debug = false
+
+data_dir =
+static_dir = %(data_dir)s/static
+templates_dir = %(data_dir)s/templates
+""")
+
class Backend(object):
def __init__(self, configfile, debug=False):
# Read configuration file.
self.config = self.read_config(configfile)
- self.debug = debug
+
+ # Enable debug logging if configured
+ self.debug = debug or self.config.getboolean("global", "debug")
# Setup database.
self.setup_database()
# Initialize settings first.
self.settings = settings.Settings(self)
- self.memcache = memcached.Memcached(self)
# Initialize backend modules.
self.accounts = accounts.Accounts(self)
- self.advertisements = ads.Advertisements(self)
self.downloads = mirrors.Downloads(self)
self.geoip = geoip.GeoIP(self)
self.fireinfo = fireinfo.Fireinfo(self)
self.mirrors = mirrors.Mirrors(self)
self.netboot = netboot.NetBoot(self)
self.nopaste = nopaste.Nopaste(self)
- self.news = news.News(self)
- self.planet = planet.Planet(self)
self.releases = releases.Releases(self)
self.talk = talk.Talk(self)
+ self.blog = blog.Blog(self)
self.zeiterfassung = zeiterfassung.ZeiterfassungClient(self)
def read_config(self, configfile):
cp = configparser.ConfigParser()
+
+ # Initialize configuration with some sensible defaults
+ cp.readfp(DEFAULT_CONFIG)
+
+ # Parse file
cp.read(configfile)
return cp