Changeset 3660 for TI05-delivery


Ignore:
Timestamp:
20/03/08 16:19:47 (11 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.

Location:
TI05-delivery/ows_framework/trunk/ows_server/ows_server
Files:
1 added
3 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 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/viewItems.py

    r3647 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 
    15# 
    2 # Controller for the 'View' tab - allowing the display of WMC map layers 
    3 # 
    4 # $Id$ 
    5 # 
     6""" 
     7 Controller for the 'View' tab - allowing the display of WMC map layers 
     8 
     9 @author C Byrom Feb 08 
     10""" 
     11 
    612from ows_server.lib.base import * 
    713from paste.request import parse_querystring 
    814from ows_server.models import Utilities 
    915from ows_server.lib.wmc_util import * 
    10 from ows_server.models import stubB 
     16from ows_server.models import selectedItem 
    1117import copy 
    1218 
     
    5460    def addViewItem(self,endpoint): 
    5561         
    56         item = stubB.SelectedItem(None, None, None, endpoint) 
     62        item = selectedItem.SelectedItem(None, None, None, endpoint) 
    5763         
    5864        selections = [item,] 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/stubB.py

    r3501 r3660  
    7979            self.timeCoverage=temporal(self.elem,helper) 
    8080            self.parameters=helper.getText(elem,'dgGranuleSummary/dgParameterSummary/ParameterName',multiple=1) 
    81             
    82 class SelectedItem: 
    83     ''' A simple object representing key info on selected items ''' 
    84     def __init__(self,entryID,title,kmlURL,wmcURL): 
    85             self.entryID = entryID 
    86             self.title = title 
    87             self.kmlURL = kmlURL 
    88             self.wmcURL = wmcURL 
    89             self.kmlList = Utilities.recreateListFromUnicode(kmlURL) 
    90             self.wmcList = Utilities.recreateListFromUnicode(wmcURL) 
    9181             
    9282class ObservationStation: 
Note: See TracChangeset for help on using the changeset viewer.