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