Software Freedom Law Center

root/trunk/trac/trac/about.py

Revision 103, 2.7 kB (checked in by bkuhn, 8 months ago)

r129@hughes: bkuhn | 2008-05-01 21:46:34 -0400

  • Merged upstream trac via: svk smerge /loblaw/local/branches/trac.upstream-r6969 .
Line 
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2004-2008 Edgewall Software
4 # Copyright (C) 2004-2005 Jonas Borgström <jonas@edgewall.com>
5 # Copyright (C) 2004-2005 Daniel Lundin <daniel@edgewall.com>
6 # Copyright (C) 2005-2006 Christopher Lenz <cmlenz@gmx.de>
7 # All rights reserved.
8 #
9 # This software is licensed as described in the file COPYING, which
10 # you should have received as part of this distribution. The terms
11 # are also available at http://trac.edgewall.org/wiki/TracLicense.
12 #
13 # This software consists of voluntary contributions made by many
14 # individuals. For the exact contribution history, see the revision
15 # history and logs, available at http://trac.edgewall.org/log/.
16 #
17 # Author: Jonas Borgström <jonas@edgewall.com>
18 #         Christopher Lenz <cmlenz@gmx.de>
19
20 import re
21
22 from genshi.builder import tag
23
24 from trac.core import *
25 from trac.perm import IPermissionRequestor
26 from trac.util.translation import _
27 from trac.web import IRequestHandler
28 from trac.web.chrome import INavigationContributor
29
30
31 class AboutModule(Component):
32     """Provides various about pages."""
33
34     implements(INavigationContributor, IPermissionRequestor, IRequestHandler)
35
36     # INavigationContributor methods
37
38     def get_active_navigation_item(self, req):
39         return 'about'
40
41     def get_navigation_items(self, req):
42         yield ('metanav', 'about',
43                tag.a(_('About Trac'), href=req.href.about()))
44
45     # IPermissionRequestor methods
46
47     def get_permission_actions(self):
48         return ['CONFIG_VIEW']
49
50     # IRequestHandler methods
51
52     def match_request(self, req):
53         return re.match(r'/about(?:_trac)?(?:/.*)?$', req.path_info)
54
55     def process_request(self, req):
56         data = {}
57
58         if 'CONFIG_VIEW' in req.perm('config', 'systeminfo'):
59             # Collect system information
60             data['systeminfo'] = self.env.systeminfo
61
62         if 'CONFIG_VIEW' in req.perm('config', 'ini'):
63             # Collect config information
64             sections = []
65             for section in self.config.sections():
66                 options = []
67                 default_options = self.config.defaults().get(section)
68                 for name,value in self.config.options(section):
69                     default = default_options and default_options.get(name) or ''
70                     options.append({
71                         'name': name, 'value': value,
72                         'modified': unicode(value) != unicode(default)
73                     })
74                 options.sort(lambda x,y: cmp(x['name'], y['name']))
75                 sections.append({'name': section, 'options': options})
76             sections.sort(lambda x,y: cmp(x['name'], y['name']))
77             data['config'] = sections
78
79         return 'about.html', data, None
Note: See TracBrowser for help on using the browser.

SFLC Main Page

[frdm] Support SFLC