Ignore:
Timestamp:
20/03/08 16:19:47 (13 years ago)
Author:
cbyrom
Message:

Remove the selectedItems class from stubB and put into its own separate class
+ add additional documentation to viewItems and selectedItems python scripts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/selectedItems.py

    r3607 r3660  
     1# Copyright (C) 2007 STFC & NERC (Science and Technology Facilities Council). 
     2# This software may be distributed under the terms of the 
     3# Q Public License, version 1.0 or later. 
     4# http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt 
     5# 
     6""" 
     7 Controller for the 'Selections' tab - which displays selected WMC/granules and allows 
     8 these to be displayed via a selection of methods 
     9 
     10 @author: C Byrom 
     11""" 
     12 
    113from ows_server.lib.base import * 
    214from paste.request import parse_querystring 
    315from ows_server.models import Utilities 
    4 from ows_server.models import stubB 
     16from ows_server.models import selectedItem 
    517from ows_server.lib.wmc_util import * 
    618from ows_server.controllers import viewItems 
     
    1123     
    1224    def index(self): 
    13         # Return a rendered template 
    14         #   return render('/some/template.html') 
    15         # or, Return a response object 
     25        # Get the inputs passed via the URL 
    1626        self.inputs=dict(parse_querystring(request.environ)) 
    1727                
     
    2434            # get all selected selections 
    2535            self.getSelectedItems() 
    26              
    2736            # ensure selections have been made 
    2837            if 'selectedItems' in session: 
    2938                # now create the aggregated KML file 
    3039                # NB, set header info correctly to open as a file 
    31                 response.write(render('kml_aggregate', format='xml')) 
     40                #response.write(render('kml_aggregate', format='xml')) 
    3241                response.headers['Content-Type'] = 'text/xml' 
    3342                response.headers['Content-Disposition'] = 'attachment;filename=kmlAggregate.kml' 
    34                 return response;  
     43                return render('kml_aggregate', format='xml') 
    3544 
    3645        elif 'PlotSelectedInConTerra' in self.inputs: 
     
    4049            # ensure selections have been made 
    4150            if 'selectedItems' in session: 
     51                # NB, only add selections which have a WMC URL defined 
    4252                wmcURLs = [] 
    4353                for item in session['selectedItems']: 
     
    6070                # redirect to the view tab index code 
    6171                h.redirect_to(h.url_for(controller='viewItems',action='index')) 
    62                  
    6372         
    6473        else: 
     
    7079                    dummy, wmcURL = str(input).split('____') 
    7180                    # NB, the image key that we're parsing has either .x or .y at the end 
     81                    # - so strip this off 
    7282                    wmcURL = wmcURL[0:len(wmcURL)-2] 
    7383                    wmcURLs = [wmcURL] 
     
    7888    # check through the inputs to determine which checkboxes 
    7989    # have been selected in the 'selections' tab; use these 
    80     # to build a new session list to use with the kml_aggregate template 
     90    # to build a new session list to use with the various visualisation methods 
    8191    def getSelectedItems(self): 
    8292        # clear out existing data 
     
    118128    def addSelectedItem(self,entryid,kmlurl,wmcurl,title,divid): 
    119129         
    120         item = stubB.SelectedItem(entryid, title, kmlurl, wmcurl) 
     130        item = selectedItem.SelectedItem(entryid, title, kmlurl, wmcurl) 
    121131         
    122132        selections = [item,] 
     
    157167        # rerender selections to update with item removed 
    158168        return render('selectedItems') 
     169 
    159170     
    160171    # Remove selected item from session data 
Note: See TracChangeset for help on using the changeset viewer.