Mercurial > bitten > bitten-test
comparison bitten/web_ui.py @ 779:d29499a4450c
Copy trac's `trac.util.presentation.to_json` method to prevent `json` module requirement, and incorporate fallback methods to support Trac 0.11 etc. See #426
author | dfraser |
---|---|
date | Wed, 28 Apr 2010 09:18:15 +0000 |
parents | 0fdc8aaeb436 |
children | 8f12cd7ea767 |
comparison
equal
deleted
inserted
replaced
777:ab6fdaaf34f6 | 779:d29499a4450c |
---|---|
35 from bitten.api import ILogFormatter, IReportChartGenerator, IReportSummarizer | 35 from bitten.api import ILogFormatter, IReportChartGenerator, IReportSummarizer |
36 from bitten.master import BuildMaster | 36 from bitten.master import BuildMaster |
37 from bitten.model import BuildConfig, TargetPlatform, Build, BuildStep, \ | 37 from bitten.model import BuildConfig, TargetPlatform, Build, BuildStep, \ |
38 BuildLog, Report | 38 BuildLog, Report |
39 from bitten.queue import collect_changes | 39 from bitten.queue import collect_changes |
40 from bitten.util import json | |
40 | 41 |
41 _status_label = {Build.PENDING: 'pending', | 42 _status_label = {Build.PENDING: 'pending', |
42 Build.IN_PROGRESS: 'in progress', | 43 Build.IN_PROGRESS: 'in progress', |
43 Build.SUCCESS: 'completed', | 44 Build.SUCCESS: 'completed', |
44 Build.FAILURE: 'failed'} | 45 Build.FAILURE: 'failed'} |
718 implements(IRequestHandler) | 719 implements(IRequestHandler) |
719 | 720 |
720 generators = ExtensionPoint(IReportChartGenerator) | 721 generators = ExtensionPoint(IReportChartGenerator) |
721 | 722 |
722 # IRequestHandler methods | 723 # IRequestHandler methods |
723 | |
724 def _get_dumps(self): | |
725 try: | |
726 import json | |
727 return json.dumps | |
728 except ImportError: | |
729 pass | |
730 | |
731 import simplejson | |
732 return simplejson.dumps | |
733 | |
734 def match_request(self, req): | 724 def match_request(self, req): |
735 match = re.match(r'/build/([\w.-]+)/chart/(\w+)', req.path_info) | 725 match = re.match(r'/build/([\w.-]+)/chart/(\w+)', req.path_info) |
736 if match: | 726 if match: |
737 req.args['config'] = match.group(1) | 727 req.args['config'] = match.group(1) |
738 req.args['category'] = match.group(2) | 728 req.args['category'] = match.group(2) |
748 category) | 738 category) |
749 break | 739 break |
750 else: | 740 else: |
751 raise TracError('Unknown report category "%s"' % category) | 741 raise TracError('Unknown report category "%s"' % category) |
752 | 742 |
753 data['dumps'] = self._get_dumps() | 743 data['dumps'] = json.to_json |
754 | 744 |
755 return tmpl, data, 'text/plain' | 745 return tmpl, data, 'text/plain' |
756 | 746 |
757 | 747 |
758 class SourceFileLinkFormatter(Component): | 748 class SourceFileLinkFormatter(Component): |