source: TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/config/oiemiddleware.py @ 5470

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/config/oiemiddleware.py@5470
Revision 5470, 2.6 KB checked in by cbyrom, 10 years ago (diff)

Update documentation, adding a section on how to set up the security
+ tidy up the codebase, moving configuration files to the top level
and deleting any app specific data + fix a few links to properly
include the admin parameter + fix an issue with the admin redirection.

  • Property svn:executable set to *
Line 
1'''
2 Middleware controller extension for the OAI info editor
3 
4 @author: C Byrom, Tessella Apr 2009
5'''
6import logging, urllib, os
7from paste.deploy import CONFIG
8from ndg.common.src.models.myconfig import myConfig
9from oai_info_editor.dal.providerinfodao import *
10from oai_info_editor.lib.harvester import Harvester
11   
12class OIEMiddleware(object):
13   
14    MISSING_HELP_TEXT_ERROR = 'Error: Help text missing from config file'
15
16    # flags to lookup in config files - and to refer to data stored in global constants
17    MANDATORY_DATA = 'mandatory'
18    FIXED_DATA = 'fixed'
19    HELP_DATA = 'help_text'
20   
21    def __init__(self, app, g, app_conf):
22        logging.debug("Setting up editor configuration")
23        #this is the next application in the wsgi stack
24        self.app=app
25       
26        #set up the app configuration file
27        cf=app_conf['configfile']
28        cf=myConfig(cf)
29     
30        self.globals=g
31        self.globals.ndgLink=cf.get('layout','ndgLink','http://ndg.nerc.ac.uk')
32        self.globals.ndgImage=cf.get('layout','ndgImage',None)
33        self.globals.helpIcon=cf.get('layout','helpIcon')
34        self.globals.LeftAlt=cf.get('layout','HdrLeftAlt')
35        self.globals.LeftLogo=cf.get('layout','HdrLeftLogo')
36        self.globals.pageLogo="bodcHdr"
37        self.globals.disclaimer=cf.get('default','disclaimer')
38        self.globals.xslt=cf.get('layout','xslt','')
39        self.globals.xmlIcon=cf.get('layout','XMLicon')
40        self.globals.loadingIcon=cf.get('layout','loadingIcon')
41       
42        self.globals.server=cf.get('SERVERS','server','')
43        self.globals.proxy = cf.get('SERVERS','proxyServer')
44        self.globals.mailServer = cf.get('SERVERS', 'mailserver')
45       
46        self.globals.dataDir = cf.get('DATA_STORE', 'appDataFileDir')
47        self.globals.backupDir = cf.get('DATA_STORE', 'backupFileDir')
48        harvestDir = cf.get('DATA_STORE', 'harvestDir')
49        if not harvestDir:
50            raise ValueError("No harvest directory config data has been specified - so cannot harvest files.")
51       
52        self.globals.harvester = Harvester(self.globals.mailServer, outDir = harvestDir)
53
54        # store a data access object to general use
55        logging.info("Set up central data access object for reuse across editor")
56        self.globals.dao = createDAOWithClient(client = FILE_CLIENT_TYPE, configFile = cf)
57        logging.info("DAO set up")
58           
59        self.config=cf
60        logging.info("- editor configuration complete")
61       
62    def __call__(self,environ,start_response):
63       
64        environ['appConfig']=self.config
65        return self.app(environ,start_response)
66   
Note: See TracBrowser for help on using the repository browser.