]> git.ipfire.org Git - ipfire.org.git/blob - webapp/backend/misc.py
22dce10b9b3ff3c25f988c09e2336f625cf2856d
[ipfire.org.git] / webapp / backend / misc.py
1 #!/usr/bin/python
2
3 class Object(object):
4 def __init__(self, backend):
5 self.backend = backend
6
7 @property
8 def db(self):
9 return self.backend.db
10
11 @property
12 def accounts(self):
13 return self.backend.accounts
14
15 @property
16 def planet(self):
17 return self.backend.planet
18
19
20 class Singleton(type):
21 """
22 A class for using the singleton pattern
23 """
24
25 def __init__(cls, name, bases, dict):
26 super(Singleton, cls).__init__(name, bases, dict)
27 cls.instance = None
28
29 def __call__(cls, *args, **kw):
30 if cls.instance is None:
31 cls.instance = super(Singleton, cls).__call__(*args, **kw)
32
33 return cls.instance