Changeset 2677
- Timestamp:
- 02/07/07 09:27:38 (14 years ago)
- Location:
- TI05-delivery/ows_framework/trunk/ows_server/ows_server
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/csml_wcs.py
r2674 r2677 30 30 from email import encoders 31 31 32 from ows_server.controllers.status import StatusController33 from ows_server.models import ndgObject,ndgRetrieve34 from ows_server.controllers.retrieve import RetrieveController35 36 32 class CsmlWcsController(OwsController): 37 33 _ows_parameters = { … … 39 35 'ExceptionFormat': make_domain(['text/xml']), 40 36 } 41 42 def _get_csml_document(self,fileoruri):43 """44 Gets a csml document from file or exist when passed a file name or uri - this should make 'get_csml_doc' obselete45 """46 if string.find(fileoruri,'__NDG-A0__') == -1:47 #it's a local file not an identifier48 file=fileoruri49 csml_dir = request.environ['paste.config']['app_conf']['csml_dir']50 path = os.path.join(csml_dir, file)51 if os.path.exists(path+'.csml'):52 f = path+'.csml'53 elif os.path.exists(path+'.xml'):54 f = path +'.xml'55 else:56 raise ValueError("Cannot find CSML file %s" % file)57 58 d = csml.parser.Dataset()59 d.parse(f)60 61 else:62 #it's an NDG identifier, get the document from exist.63 uri=fileoruri64 uri='badc.nerc.ac.uk__NDG-A0__ReMryRVA'65 uriN=ndgObject.ndgObject(uri)66 self.cf=request.environ['ndgConfig']67 self.requestor=request.environ['REMOTE_ADDR']68 print 'session',session69 if 'ndgSec' in session:70 securityTokens=session['ndgSec']71 else: securityTokens=None72 print securityTokens73 status,x=ndgRetrieve.ndgRetrieve(74 uriN,self.cf,requestor=self.requestor,75 securityTokens=securityTokens)76 print 'output from retrieve controller: ',x77 print type(x)78 #TODO, need to parse this output into a csml Dataset object, d79 80 return d81 37 82 38 … … 172 128 """ 173 129 # Populate the context object with information required by the template 174 c.dataset = self._get_csml_document(fileoruri)130 #c.dataset = get_csml_document(fileoruri) 175 131 176 132 #get doc from cache or disk: 177 #c.dataset = csmlCache[fileoruri]133 c.dataset = csmlCache[fileoruri] 178 134 return self._renderCapabilities('ows/wcs_capabilities') 179 135 -
TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/base.py
r2675 r2677 13 13 from ows_common.get_capabilities import ServiceMetadata 14 14 import ows_common.xml 15 import string 16 15 17 16 18 try: -
TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/csml_util.py
r2674 r2677 10 10 from pylons import Response, c, g, cache, request, session 11 11 import csml, cdms 12 import os 12 import os, string 13 13 import zipfile 14 14 import tempfile 15 from ows_server.models import ndgObject,ndgRetrieve 15 16 17 def get_csml_doc(fileoruri): 18 """ 19 Gets a csml document from file or exist when passed a file name or uri 20 21 Note, access control is not implemented on file access, only on exist access. 22 23 """ 24 if string.find(fileoruri,'__NDG-A0__') == -1: 25 #it's a local file not an identifier 26 file=fileoruri 27 csml_dir = request.environ['paste.config']['app_conf']['csml_dir'] 28 path = os.path.join(csml_dir, file) 29 if os.path.exists(path+'.csml'): 30 f = path+'.csml' 31 elif os.path.exists(path+'.xml'): 32 f = path +'.xml' 33 else: 34 raise ValueError("Cannot find CSML file %s" % file) 35 36 d = csml.parser.Dataset() 37 d.parse(f) 38 39 else: 40 #it's an NDG identifier, get the document from exist. 41 uri=fileoruri 42 uri='badc.nerc.ac.uk__NDG-A0__ReMryRVA' 43 uriN=ndgObject.ndgObject(uri) 44 cf=request.environ['ndgConfig'] 45 requestor=request.environ['REMOTE_ADDR'] 46 if 'ndgSec' in session: 47 securityTokens=session['ndgSec'] 48 else: securityTokens=None 49 status,x=ndgRetrieve.ndgRetrieve( 50 uriN,cf,requestor=requestor, 51 securityTokens=securityTokens) 52 d=csml.parser.Dataset() 53 d.parseElemTree(x.tree) 54 return d 16 55 56 #this version of get_csml_doc can be deleted now if no problems found with new version: 57 #def get_csml_doc(file): 58 #""" 59 #A trivial document retrieval function. 17 60 18 def get_csml_doc(file): 19 """20 A trivial document retrieval function.61 #This could be replaced with a proper csml server object that supports 62 #multiple stores (filesystem, exist) and cache's the results for 63 #performance. 21 64 22 This could be replaced with a proper csml server object that supports 23 multiple stores (filesystem, exist) and cache's the results for 24 performance. 25 26 """ 27 csml_dir = request.environ['paste.config']['app_conf']['csml_dir'] 28 path = os.path.join(csml_dir, file) 29 if os.path.exists(path+'.csml'): 30 f = path+'.csml' 31 elif os.path.exists(path+'.xml'): 32 f = path +'.xml' 33 else: 34 raise ValueError("Cannot find CSML file %s" % file) 65 #""" 66 #csml_dir = request.environ['paste.config']['app_conf']['csml_dir'] 67 #path = os.path.join(csml_dir, file) 68 #if os.path.exists(path+'.csml'): 69 #f = path+'.csml' 70 #elif os.path.exists(path+'.xml'): 71 #f = path +'.xml' 72 #else: 73 #raise ValueError("Cannot find CSML file %s" % file) 35 74 36 d = csml.parser.Dataset()37 d.parse(f)75 #d = csml.parser.Dataset() 76 #d.parse(f) 38 77 39 return d78 #return d 40 79 41 80
Note: See TracChangeset
for help on using the changeset viewer.