]>
git.ipfire.org Git - ipfire.org.git/blob - src/backend/base.py
3 import ConfigParser
as configparser
22 from . import zeiterfassung
24 DEFAULT_CONFIG
= StringIO
.StringIO("""
29 static_dir = %(data_dir)s/static
30 templates_dir = %(data_dir)s/templates
33 class Backend(object):
34 def __init__(self
, configfile
, debug
=False):
35 # Read configuration file.
36 self
.config
= self
.read_config(configfile
)
38 # Enable debug logging if configured
39 self
.debug
= debug
or self
.config
.getboolean("global", "debug")
44 # Initialize settings first.
45 self
.settings
= settings
.Settings(self
)
46 self
.memcache
= memcached
.Memcached(self
)
48 # Initialize backend modules.
49 self
.accounts
= accounts
.Accounts(self
)
50 self
.advertisements
= ads
.Advertisements(self
)
51 self
.downloads
= mirrors
.Downloads(self
)
52 self
.geoip
= geoip
.GeoIP(self
)
53 self
.fireinfo
= fireinfo
.Fireinfo(self
)
54 self
.iuse
= iuse
.IUse(self
)
55 self
.mirrors
= mirrors
.Mirrors(self
)
56 self
.netboot
= netboot
.NetBoot(self
)
57 self
.nopaste
= nopaste
.Nopaste(self
)
58 self
.news
= news
.News(self
)
59 self
.planet
= planet
.Planet(self
)
60 self
.releases
= releases
.Releases(self
)
61 self
.talk
= talk
.Talk(self
)
63 self
.zeiterfassung
= zeiterfassung
.ZeiterfassungClient(self
)
65 def read_config(self
, configfile
):
66 cp
= configparser
.ConfigParser()
68 # Initialize configuration with some sensible defaults
69 cp
.readfp(DEFAULT_CONFIG
)
76 def setup_database(self
):
78 Sets up the database connection.
81 "host" : self
.config
.get("database", "server"),
82 "database" : self
.config
.get("database", "database"),
83 "user" : self
.config
.get("database", "username"),
84 "password" : self
.config
.get("database", "password"),
87 self
.db
= database
.Connection(**credentials
)