source: TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/viewItems.py @ 3544

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/viewItems.py@3544
Revision 3544, 1.8 KB checked in by cbyrom, 14 years ago (diff)

Adjust code to allow multiple WMC docs to be selected in the selections
tab and displayed in the view tab. Also rename the display tab to 'details'
and add new exceptions to deal with URL lookup failures.

Line 
1from ows_server.lib.base import *
2from paste.request import parse_querystring
3from ows_server.models import Utilities
4from ows_server.lib.wmc_util import *
5from ows_server.models import stubB
6import copy
7
8class ViewitemsController(BaseController):
9   
10    def index(self):
11        self.inputs=dict(parse_querystring(request.environ))
12        c.wmcURL = ""
13        # check if we're doing an AJAX callback to get some WMC data
14        if 'REQUEST' in self.inputs and self.inputs['REQUEST'] == 'GetWebMapContext':
15            return GetWebMapContext(self)
16        # otherwise, we can get here by two routes:
17        # i) either by clicking on the WMC icon in the details view - if so, get passed endpoint and add to
18        #    selected items;
19        # ii) or from the selections tab - which will already have set up the correct selected items
20       
21        # firstly check if page has been visited before; if not display tab
22        if 'viewItems' not in session:
23            c.pageTabs.append(('View', h.url_for(controller='viewItems',action='index')))
24
25        # if ENDPOINT specified, we've reached the page via the WMC icon
26        if ('ENDPOINT' in self.inputs):
27            self.addViewItem(self.inputs['ENDPOINT'])
28                                   
29        session.save()
30        return render('viewItems')
31
32
33    # add a selected item to the session
34    # - if this is the first item, then display the selections tab
35    def addViewItem(self,endpoint):
36       
37        item = stubB.SelectedItem(None, None, None, endpoint)
38       
39        selections = [item,]
40        # avoid duplicates
41        if 'viewItems' in session:
42            for selection in session['viewItems']:
43                if selection.wmcURL != endpoint:
44                    selections.append(selection)
45                   
46        session['viewItems'] = selections
47        session.save()
Note: See TracBrowser for help on using the repository browser.