]> git.openstreetmap.org Git - osqa.git/blob - forum/modules/ui.py
reversed the search order of the revisions drop down menu.
[osqa.git] / forum / modules / ui.py
1
2
3 class Registry(list):
4     def add(self, register):
5         for i, r in enumerate(self):
6             if r.weight > register.weight:
7                 self.insert(i, register)
8                 return
9
10         self.append(register)
11
12
13 HEAD_CONTENT = 'HEAD_CONTENT'
14 HEADER_LINKS = 'HEADER_LINKS'
15 PAGE_TOP_TABS = 'PAGE_TOP_TABS'
16 FOOTER_LINKS = 'FOOTER_LINKS'
17 PROFILE_TABS = 'PROFILE_TABS'
18
19
20 __CONTAINER = {
21     HEAD_CONTENT: Registry(),
22     HEADER_LINKS: Registry(),
23     PAGE_TOP_TABS: Registry(),
24     FOOTER_LINKS: Registry(),
25     PROFILE_TABS: Registry(),
26 }
27
28
29 def register(registry, *ui_objects):
30     if not registry in __CONTAINER:
31         raise('unknown registry')
32
33     for ui_object in ui_objects:
34         __CONTAINER[registry].add(ui_object)
35
36 def get_registry_by_name(name):
37     name = name.upper()
38
39     if not name in __CONTAINER:
40         raise('unknown registry')
41
42     return __CONTAINER[name]
43
44
45
46 from ui_objects import *
47