]> git.llucax.com Git - z.facultad/75.52/sercom.git/blob - sercom/menu.py
Agrego class faltantes.
[z.facultad/75.52/sercom.git] / sercom / menu.py
1
2 from turbogears import url
3 from turbogears import controllers
4
5 class Menu:
6     def __init__(self, controller):
7         # Armo la lista de subcontrollers
8         self.items = []
9         for i in controller.__dict__:
10             if isinstance(getattr(controller, i),controllers.Controller):
11                 self.items.append(i)
12         self.items.sort()
13
14     def __repr__(self):
15         t = """
16         <div id="navbar">
17                         Ir a :
18                         <select OnChange="window.location=this.options[this.selectedIndex].value;">
19                                 %s
20                         </select>
21                 </div>
22         """
23         s = ''
24         for i in self.items:
25             s = s + u"""<option value="%s">%s</option>" """ % (url('/' + i), i.capitalize().replace('_', ' '))
26         return t % s
27