]>
Commit | Line | Data |
---|---|---|
a6dc0bad MT |
1 | #!/usr/bin/python |
2 | ||
9068dba1 | 3 | import ConfigParser as configparser |
a6dc0bad MT |
4 | |
5 | import accounts | |
9068dba1 MT |
6 | import ads |
7 | import database | |
8 | import geoip | |
66862195 | 9 | import fireinfo |
9068dba1 MT |
10 | import iuse |
11 | import memcached | |
12 | import mirrors | |
13 | import netboot | |
66862195 | 14 | import nopaste |
9068dba1 | 15 | import news |
a6dc0bad | 16 | import planet |
9068dba1 MT |
17 | import releases |
18 | import settings | |
66862195 | 19 | import talk |
9068dba1 MT |
20 | import tracker |
21 | import wishlist | |
a6dc0bad MT |
22 | |
23 | class Backend(object): | |
9068dba1 MT |
24 | def __init__(self, configfile): |
25 | # Read configuration file. | |
26 | self.config = self.read_config(configfile) | |
27 | ||
28 | # Setup database. | |
29 | self.setup_database() | |
a6dc0bad | 30 | |
9068dba1 MT |
31 | # Initialize settings first. |
32 | self.settings = settings.Settings(self) | |
33 | self.memcache = memcached.Memcached(self) | |
34 | ||
35 | # Initialize backend modules. | |
a6dc0bad | 36 | self.accounts = accounts.Accounts(self) |
9068dba1 MT |
37 | self.advertisements = ads.Advertisements(self) |
38 | self.downloads = mirrors.Downloads(self) | |
39 | self.geoip = geoip.GeoIP(self) | |
66862195 | 40 | self.fireinfo = fireinfo.Fireinfo(self) |
9068dba1 MT |
41 | self.iuse = iuse.IUse(self) |
42 | self.mirrors = mirrors.Mirrors(self) | |
43 | self.netboot = netboot.NetBoot(self) | |
66862195 | 44 | self.nopaste = nopaste.Nopaste(self) |
9068dba1 | 45 | self.news = news.News(self) |
a6dc0bad | 46 | self.planet = planet.Planet(self) |
9068dba1 | 47 | self.releases = releases.Releases(self) |
66862195 | 48 | self.talk = talk.Talk(self) |
9068dba1 MT |
49 | self.tracker = tracker.Tracker(self) |
50 | self.wishlist = wishlist.Wishlist(self) | |
51 | ||
52 | def read_config(self, configfile): | |
53 | cp = configparser.ConfigParser() | |
54 | cp.read(configfile) | |
55 | ||
56 | return cp | |
57 | ||
58 | def setup_database(self): | |
59 | """ | |
60 | Sets up the database connection. | |
61 | """ | |
62 | credentials = { | |
63 | "host" : self.config.get("database", "server"), | |
64 | "database" : self.config.get("database", "database"), | |
65 | "user" : self.config.get("database", "username"), | |
66 | "password" : self.config.get("database", "password"), | |
67 | } | |
68 | ||
69 | self.db = database.Connection(**credentials) |