source: cowsserver/trunk/lib/cowsserver/controllers/catalogue.py @ 6097

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cowsserver/trunk/lib/cowsserver/controllers/catalogue.py@6097
Revision 6097, 1.2 KB checked in by pnorton, 11 years ago (diff)

Modified the catalog page so that it uses the dataset names rather than the csml file names. Copied and modified the catalog template form cows.

Line 
1import logging
2
3import cowsserver.lib.base as base
4
5from cowsserver.lib.base import csTemplateLoader , globalCSMLConnector, c
6import operator
7
8
9log = logging.getLogger(__name__)
10
11class CatalogueController(base.BaseController):
12    """
13    List available endpoints.
14    """
15
16    def index(self):
17       
18        c.allwxs=[]
19        c.wfsonly=[]
20
21        #need to handle wfs only features separately so sort into two lists
22        listwfsonly = list(globalCSMLConnector.listwfsonly())
23       
24        for fc in globalCSMLConnector.list():
25            doc = globalCSMLConnector.getCsmlDoc(fc)
26           
27            if hasattr(doc, 'name'):
28                fc_name = doc.name.CONTENT
29            else:
30                fc_name = fc
31           
32            if fc in listwfsonly:
33                c.wfsonly.append((fc, fc_name) )
34            else:
35                c.allwxs.append((fc, fc_name) )
36       
37       
38        def sortCFByName(a, b):
39            return cmp(a[1].lower(), b[1].lower())
40       
41        c.allwxs.sort(cmp=sortCFByName)
42       
43        c.wfsonly.sort(cmp=sortCFByName)
44               
45        t = csTemplateLoader.load('catalogue.xml')
46       
47        return t.generate(c=c).render()
Note: See TracBrowser for help on using the repository browser.