1 | # ndg middleware |
---|
2 | from paste.deploy import CONFIG |
---|
3 | from ows_server.models.Utilities import myConfig |
---|
4 | class ndgMiddleware: |
---|
5 | |
---|
6 | def __init__(self,app,g): |
---|
7 | |
---|
8 | #this is the next application in the wsgi stack |
---|
9 | self.app=app |
---|
10 | |
---|
11 | #set up the ndg configuration file |
---|
12 | |
---|
13 | #Changed by Dom: CONFIG.get wasn't respecting the %(home)s variable, so moved to app_conf section in ini file. |
---|
14 | #cf=CONFIG.get('configfile') |
---|
15 | cf= CONFIG['app_conf']['configfile'] |
---|
16 | cf=myConfig(cf) |
---|
17 | |
---|
18 | self.globals=g |
---|
19 | self.globals.localLink=cf.get('layout','localLink',None) |
---|
20 | self.globals.localImage=cf.get('layout','localImage',None) |
---|
21 | self.globals.localAlt=cf.get('layout','localAlt','Visit Local Site') |
---|
22 | self.globals.ndgLink=cf.get('layout','ndgLink','http://ndg.nerc.ac.uk') |
---|
23 | self.globals.ndgImage=cf.get('layout','ndgImage',None) |
---|
24 | self.globals.ndgAlt=cf.get('layout','ndgAlt','Visit NDG') |
---|
25 | self.globals.stfcLink=cf.get('layout','stfcLink') |
---|
26 | self.globals.stfcImage=cf.get('layout','stfcImage') |
---|
27 | self.globals.helpIcon=cf.get('layout','helpIcon') |
---|
28 | self.globals.LeftAlt=cf.get('layout','HdrLeftAlt') |
---|
29 | self.globals.LeftLogo=cf.get('layout','HdrLeftLogo') |
---|
30 | self.globals.pageLogo="bodcHdr" |
---|
31 | self.globals.icons_xml=cf.get('layout','Xicon') |
---|
32 | self.globals.icons_prn=cf.get('layout','printer') |
---|
33 | self.globals.icons_A=cf.get('NDG_A_SERVICE','icon') |
---|
34 | self.globals.icons_B=cf.get('NDG_B_SERVICE','icon') |
---|
35 | self.globals.icons_D=cf.get('DISCOVERY','icon') |
---|
36 | self.globals.icons_R=cf.get('RELATED','icon') |
---|
37 | |
---|
38 | self.globals.discoveryURL=cf.get('SEARCH','discoveryURL') |
---|
39 | |
---|
40 | self.globals.server=cf.get('DEFAULT','server','') |
---|
41 | self.globals.wayfuri='%s/wayf'%self.globals.server |
---|
42 | |
---|
43 | self.globals.logout='%s/logout'%self.globals.server |
---|
44 | |
---|
45 | self.config=cf |
---|
46 | |
---|
47 | |
---|
48 | def __call__(self,environ,start_response): |
---|
49 | |
---|
50 | environ['ndgConfig']=self.config |
---|
51 | return self.app(environ,start_response) |
---|
52 | |
---|