Changeset 4992 for MILK/trunk
- Timestamp:
- 18/02/09 12:53:17 (12 years ago)
- Location:
- MILK/trunk/milk_server
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
MILK/trunk/milk_server/milk.config
r4599 r4992 37 37 proxyServer: http://wwwcache3.rl.ac.uk:8080/ 38 38 disclaimer: 39 40 # if set to True, errors output will generally be more verbose - e.g. with stacktrace to templates 41 debug: True 39 42 40 43 [SEARCH] … … 76 79 # if set to True, the editor will be available 77 80 enabled: True 78 # if set to True, errors output with stacktrace to templates79 debug: True80 81 81 82 [WMC_CLIENT] … … 96 97 # 97 98 #These are the hosts which are publicly available on which the browse 98 #service is running. The list should be of the form repository: hostname99 #service is running. The list should be of the form 'repository: hostname' 99 100 #where repository is the NDG identifier .... 100 101 # … … 116 117 # entire purpose of the rest of the list is to simplify updates. These 117 118 # hosts do not need to be visible outside of corporate firewalls. 118 # The list should be of the form repository: hostnamewhere repository119 # The list should be of the form 'repository: hostname' where repository 119 120 # is the NDG identifier. 120 121 # -
MILK/trunk/milk_server/milk_server/config/milkMiddleware.py
r4984 r4992 45 45 self.globals.icons_R=cf.get('RELATED','icon') 46 46 self.globals.icons_key=cf.get('layout','key') 47 self.globals.debugModeOn = cf.get('DEFAULT','debug') or False 47 48 48 49 self.globals.atomEditorEnabled = cf.get('ATOM_EDITOR','enabled') 49 self.globals.debugAtomEditor = cf.get('ATOM_EDITOR','debug') or False50 50 51 51 self.globals.wmcClientURL = cf.get('WMC_CLIENT','url') … … 73 73 dbHostName = localDbHostName, 74 74 newLineChar="<br/>", 75 isDebug = self.globals.debug AtomEditor,75 isDebug = self.globals.debugModeOn, 76 76 loadAllCollections = False) 77 77 -
MILK/trunk/milk_server/milk_server/controllers/atom_editor/atomeditorcontroller.py
r4979 r4992 110 110 111 111 errorMessage = e.message 112 if g.debug AtomEditor== 'True':112 if g.debugModeOn == 'True': 113 113 errorMessage = traceback.format_exc() 114 114 -
MILK/trunk/milk_server/milk_server/controllers/browse/discovery.py
r4979 r4992 6 6 from ndg.common.src.clients.ws.discoveryserviceclient import DiscoveryServiceClient 7 7 from ndg.common.src.clients.xmldb.eXist.searchclient import SearchClient 8 from ndg.common.src. dal.DocumentRetrieve import ndgVocabPOXas VS8 from ndg.common.src.clients.http.vocabserverclient import VocabServerClient as VS 9 9 from ndg.common.src.models.ndgObject import ndgObject 10 10 from ndg.common.src.models.DIF import DIF … … 14 14 from milk_server.lib.mailer import mailHandler 15 15 16 logging.basicConfig(level=logging.DEBUG,17 format='%(asctime)s %(filename)s:%(lineno)d %(levelname)s %(message)s')18 19 debug=020 21 16 class DiscoveryController(BaseController): 22 17 ''' Provides the pylons controller for NDG discovery ''' … … 25 20 ''' Common setup for controller methods ''' 26 21 self.cf=request.environ['ndgConfig'] 27 self.exist=(self.cf.get('NDG_EXIST','local'),\ 28 g.pwFile) 22 self.exist=(self.cf.get('NDG_EXIST','local'), g.pwFile) 29 23 self.inputs=dict(parse_querystring(request.environ)) 30 24 self.message='' … … 276 270 277 271 except ValueError,e: 278 if debug:272 if g.debugModeOn == 'True': 279 273 raise ValueError,str(e) 280 274 else: … … 348 342 def semantic(self): 349 343 self.__setup() 350 vs =VS(proxyServer=self.cf.get('DEFAULT','proxyServer'))344 vs = VS(proxyServer=self.cf.get('DEFAULT','proxyServer')) 351 345 if 'searchString' in self.inputs: 352 346 try: 353 [broader,narrower,synonyms] =vs.getRelated(self.inputs['searchString'])347 [broader,narrower,synonyms] = vs.getRelated(self.inputs['searchString']) 354 348 #get a base string for the links to new searches 355 349 if 'start' in self.inputs: del self.inputs['start'] -
MILK/trunk/milk_server/milk_server/controllers/browse/retrieve.py
r4984 r4992 1 1 ''' 2 Class representing pylons controller for the retrieval of metadata records - and 3 records associated with these 4 5 @author: B Lawrence?, C Byrom, Tessella Sep 2008 6 ''' 2 7 import logging 3 8 from paste.request import parse_querystring … … 6 11 from milk_server.lib import Utilities 7 12 from milk_server.lib.ndgInterface import ndgInterface 8 from ndg.common.src.lib.ETxmlView import et2 text, et2html13 from ndg.common.src.lib.ETxmlView import et2html 9 14 from ndg.common.src.models import stubB, DIF, ndgObject 10 15 from ndg.common.src.models.ndgObject import ndgObject … … 14 19 15 20 class RetrieveController(BaseController): 16 ''' Provides the pylons controller for retrieving NDG documents. The simple model 21 ''' 22 Provides the pylons controller for retrieving NDG documents. The simple model 17 23 is now that an attempt to retrieve/uri will parse the uri, read the config file, 18 and if the local server name is not the same as the uri server name. ''' 24 and if the local server name is not the same as the uri server name, attempt 25 to retrieve the doc remotely. 26 ''' 19 27 20 28 def __setup(self,uri): … … 51 59 52 60 interface = ndgInterface() 53 status,x=interface.GetXML(uri,outputSchema=self.outputSchema) 54 if status: 55 #(the return object x is an ET object) 56 c.xml = et2text(x) 61 status,x = interface.GetXML(uri,outputSchema=self.outputSchema) 62 c.xml = x 63 if status: 57 64 response.headers['Content-Type'] = 'application/xml' 58 65 response.write(c.xml) 59 66 else: 60 67 e=404 61 if x.startswith('<p> Access'): e=401 68 if x.startswith('<p> Access'): 69 e=401 62 70 response.status_code = e 63 71 return render('error') 72 64 73 65 74 def viewAssociatedData(self, type, uri): … … 130 139 131 140 132 133 141 def view(self,uri): 134 142 ''' Returns either an html marked up version of the xml, or a properly laid … … 169 177 name=str(self.uri) 170 178 if self.format=='xml': 171 c.xml = et2html( x)179 c.xml = et2html(ET.fromstring(x)) 172 180 renderTemplate = 'content' 173 181 c.tab='Details' 174 182 175 183 elif self.format=='raw': 176 c.xml = et2text(x)184 c.xml = x 177 185 response.headers['Content-Type'] = 'application/xml' 178 186 return response.write(c.xml) -
MILK/trunk/milk_server/milk_server/controllers/trackback/trackback.py
r4984 r4992 48 48 payload='<trackback><uri>%s</uri></trackback>'%uri 49 49 50 # make sure we have both url and title50 # make sure we have both url and title 51 51 if 'url' not in keys and 'title' not in keys: 52 52 err='Incomplete trackback, need both url and title at the every least' … … 54 54 payload+='<%s>%s</%s>'%(key,incoming[key],key) 55 55 56 # now get server and trackback recipient.56 # now get server and trackback recipient. 57 57 self.cf=request.environ['ndgConfig'] 58 58 -
MILK/trunk/milk_server/milk_server/lib/ndgInterface.py
r4959 r4992 10 10 from csml_cache import CSMLExtractCache 11 11 import os, logging 12 from ndg.common.src.dal.ndgRetrieve import ndgRetrieve12 from ndg.common.src.dal.ndgRetrieve import NDGRetrieve 13 13 from ndg.common.src.models.ndgObject import ndgObject 14 14 from xml.etree import ElementTree as ET … … 50 50 else: 51 51 self.CSMLDataCache=CSMLExtractCache( 52 request.environ['paste.config']['app_conf']['tmp_dir'],max_size=10) 52 request.environ['paste.config']['app_conf']['tmp_dir'], 53 max_size=10) 53 54 54 55 if csmlDocCache: 55 56 self.CSMLDocCache = csmlDocCache 56 57 else: 57 self.CSMLDocCache =Cache(max_size=10)58 self.CSMLDocCache = Cache(max_size=10) 58 59 59 60 if xmlHCache: 60 61 self.XMLHCache = xmlHCache 61 62 else: 62 self.XMLHCache =Cache(max_size=10)63 self.XMLHCache = Cache(max_size=10) 63 64 logging.info("Finished setting up caches") 64 65 65 66 66 def GetXML(self, uri,outputSchema='', useCache=True):67 def GetXML(self, uri, outputSchema = None, useCache = True): 67 68 ''' 68 69 This method provides a secure interface to the server … … 71 72 files except via the CSML api 72 73 @param uri: ndg format uri to locate doc from 73 @keyword outputSchema: format to return doc in 74 @keyword outputSchema: format to return doc in. Default = None => 75 return doc in its original format 74 76 @keyword useCache: check for data in the cache and use this, if set to 75 77 True (the default) 78 @return doc in string format 76 79 ''' 77 80 # Note that this method should not be used to obtain 78 81 #unsecured discovery documents, these are called directly 79 82 #in the retrieve controller! 80 logging.info("Getting XML from uri, '%s' (outputschema: '%s')" \ 81 %(uri, outputSchema)) 83 logging.info("Getting XML from uri, '%s'" %uri) 84 if outputSchema: 85 logging.info("- return doc in new format: '%s'" %outputSchema) 86 82 87 try: 83 ndgO =ndgObject(uri)88 ndgObj = ndgObject(uri) 84 89 localFile=0 85 90 except ValueError: 86 91 ''' It's a local file not an ndg identifier ''' 87 92 logging.info("File appears to be local - look for it there...") 88 ndgO =uri93 ndgObj=uri 89 94 localFile=1 90 95 … … 94 99 cleared=None 95 100 101 retrieveClient = NDGRetrieve(request.environ['ndgConfig'], 102 useDiscovery = g.standalone) 103 104 # if we're requesting doc to be returned in a new format, or if 105 # the 'useCache' flag isn't set, do a new lookup of data 96 106 if outputSchema or not useCache: 97 #bypass the cache ... 98 status,xmlh=ndgRetrieve(ndgO, 99 request.environ['ndgConfig'], 100 output=outputSchema, 101 discovery=g.standalone) 107 status, xmlh = retrieveClient.retrieveDoc(ndgObj, 108 outputFormat = outputSchema) 109 102 110 else: 103 111 try: … … 105 113 self.SetupCaches() 106 114 115 # NB, there doesn't appear to be a nice way to check if things 116 # are in the cache - either they are or an exception is thrown... 107 117 xmlh=self.XMLHCache[uri] 108 118 status=1 … … 112 122 if localFile: 113 123 status,xmlH=self.__getLocal(uri) 114 else: 115 status,xmlh=ndgRetrieve(ndgO,116 request.environ['ndgConfig'],117 output=outputSchema,118 discovery=g.standalone)119 if status:120 self.XMLHCache[uri] =xmlh124 else: 125 logging.info("Attempt to lookup document directly") 126 status, xmlh = retrieveClient.retrieveDoc(ndgObj, 127 outputFormat = outputSchema) 128 if status: 129 logging.info("Document retrieved successfully - adding to cache") 130 self.XMLHCache[uri] = xmlh 121 131 122 if not status: return status,xmlh 132 if not status: 133 return status,xmlh 123 134 124 135 # valid values of the return objects SHOULD BE … … 126 137 # exceptions, status=0, xmlh='Exception(e)' 127 138 128 status,xmlh=self.__gatekeep(ndgO ,xmlh)139 status,xmlh=self.__gatekeep(ndgObj,xmlh) 129 140 if status: 130 141 if cleared is None: … … 164 175 165 176 def __getLocal(self,uri): 166 ''' Returns a local csml file (used for testing) ''' 177 ''' 178 Returns a local csml file (used for testing) 179 ''' 180 logging.info("Attempt to retrieve doc locally - from %s" %uri) 167 181 csml_dir = request.environ['paste.config']['app_conf']['csml_dir'] 168 182 path = os.path.join(csml_dir, file) … … 172 186 f = path +'.xml' 173 187 else: 188 logging.info("- cannot find file") 174 189 return 0, '<p>Cannot find CSML file %s</p>' % file 175 190 r=f.read() 191 logging.info("- returning file contents") 176 192 return 1,r
Note: See TracChangeset
for help on using the changeset viewer.