1 | # ndg middleware |
---|
2 | from paste.deploy import CONFIG |
---|
3 | from ows_server.models.Utilities import myConfig |
---|
4 | |
---|
5 | class ndgMiddleware: |
---|
6 | |
---|
7 | def __init__(self,app,g): |
---|
8 | |
---|
9 | #this is the next application in the wsgi stack |
---|
10 | self.app=app |
---|
11 | |
---|
12 | #set up the ndg configuration file |
---|
13 | cf=CONFIG.get('configfile') |
---|
14 | cf=myConfig(cf) |
---|
15 | |
---|
16 | self.globals=g |
---|
17 | self.globals.localLink=cf.get('layout','localLink',None) |
---|
18 | self.globals.localImage=cf.get('layout','localImage',None) |
---|
19 | self.globals.localAlt=cf.get('layout','localAlt','Visit Local Site') |
---|
20 | self.globals.ndgLink=cf.get('layout','ndgLink','http://ndg.nerc.ac.uk') |
---|
21 | self.globals.ndgImage=cf.get('layout','ndgImage',None) |
---|
22 | self.globals.ndgAlt=cf.get('layout','ndgAlt','Visit NDG') |
---|
23 | self.globals.PageLogo=cf.get('layout','pageLogo',None) |
---|
24 | |
---|
25 | self.globals.server=cf.get('DEFAULT','server','') |
---|
26 | self.globals.wayfuri='%s/wayf'%self.globals.server |
---|
27 | |
---|
28 | self.globals.logout='%s/logout'%self.globals.server |
---|
29 | |
---|
30 | self.config=cf |
---|
31 | |
---|
32 | |
---|
33 | def __call__(self,environ,start_response): |
---|
34 | |
---|
35 | environ['ndgConfig']=self.config |
---|
36 | return self.app(environ,start_response) |
---|
37 | |
---|