source: cows_wps/trunk/cows_wps/renderer/ui_renderer.py @ 6955

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows_wps/trunk/cows_wps/renderer/ui_renderer.py@6955
Revision 6955, 1.3 KB checked in by astephen, 10 years ago (diff)

various fixes, got ui renderer working instead of html pages. fixes zoom
and center of the bounding box on submit page.

Line 
1import os
2
3from pylons import config, tmpl_context as c
4
5
6from genshi.template import TemplateLoader
7from genshi.builder import * 
8from genshi import HTML
9
10c.tester = "OOJOJ"
11
12
13class UIPageRenderer(object):
14    """
15    A set of rendering methods.
16    """
17
18    def __init__(self):
19        # Instantiate Genshi template loader
20        self.template_dir = config["wps.template_dir"]
21        self.templateLoader = TemplateLoader(self.template_dir, auto_reload=True)
22
23    def _htmlifyItems(self, items):
24        """
25        Ensures that template treats all content items as HTML.
26        """
27        new_items = []
28
29        for i in range(len(items)):
30            new_items.append((items[i][0], HTML(items[i][1])))
31
32        return new_items
33
34    def render(self, title, items, bbox_required=False):
35        """
36        Renders the page using title and then a list of tuples of
37         (section_title, section_content).
38        """
39        tmpl_gen = self.templateLoader.load("ui_template.html")
40        # Make sure items are HTML and won't be escaped
41        items = self._htmlifyItems(items)
42        stream = tmpl_gen.generate(title=title, items=items, 
43                        wps_capabilities_url="/wps?Service=WPS&Request=GetCapabilities&Format=text/xml",
44                        bbox_required=bbox_required)
45        return stream.render('xhtml')
46
Note: See TracBrowser for help on using the repository browser.