Changeset 8355 for mauRepo/HPFos
- Timestamp:
- 17/06/12 09:44:57 (9 years ago)
- Location:
- mauRepo/HPFos/trunk/src
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
mauRepo/HPFos/trunk/src/HPFos/molesSessionMiddleware.py
r8348 r8355 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 9 Jan 2012 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 33 from libs.commons_db import DbManager -
mauRepo/HPFos/trunk/src/HPFos/osImpl/hpfos_conf.py
r8354 r8355 41 41 os_short_name = "Web Search" 42 42 os_description = "A default description" 43 os = OpenSearchRequest(query, [atomResponse], os_short_name, \ 44 os_description) 45 return OSEngine(os, 'http://localhost:8000') 43 os = OpenSearchRequest(query, [atomResponse], os_short_name, os_description) 44 return OSEngine(os) -
mauRepo/HPFos/trunk/src/HPFos/osImpl/myimpl.py
r8354 r8355 74 74 75 75 76 def generateResponse(self, result, queries, os path, **kwargs):76 def generateResponse(self, result, queries, osHostURL, **kwargs): 77 77 """ 78 78 @param result: a Result instance 79 79 @param queries: 80 @param os path:80 @param osHostURL: 81 81 @param kwargs: 82 82 """ 83 83 id = "" 84 ospath = self.generateLinkHref(os path, result.id, self.extension, rel = None)84 ospath = self.generateLinkHref(osHostURL, result.id, self.extension, rel = None) 85 85 86 86 #Generates the ATOM document -
mauRepo/HPFos/trunk/src/HPFos/urls.py
r8352 r8355 19 19 ) 20 20 21 urlpatterns += patterns('HPFos.view. testview',22 (r' test$', 'doSearch'),21 urlpatterns += patterns('HPFos.view.view', 22 (r'$', 'getHome'), 23 23 ) 24 24 -
mauRepo/HPFos/trunk/src/HPFos/view/view.py
r8352 r8355 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 1 Nov 2011 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 33 from django.shortcuts import render_to_response 7 34 from django.core.context_processors import csrf 8 35 from django.utils.safestring import mark_safe 9 from osImpl.myimpl import COLLECTION, OBSERVATION, RESULT 10 from settings import os_engine 36 from HPFos.settings import os_engine 37 from HPFos.osImpl.myimpl import COLLECTION, OBSERVATION, RESULT 38 39 hostURL = 'http://localhost:8000' 40 41 def _buildHostURL(request): 42 if request.is_secure(): 43 return 'https://%s' % (request.get_host()) 44 else: 45 return 'http://%s' % (request.get_host()) 46 47 def getHome(request): 48 context = {} 49 context['hostURL'] = _buildHostURL(request) 50 return _dispatchResponse(request, 'homeTemplate', context) 11 51 12 52 def getDescription(request, collection_guid = None, observation_guid = None, result_guid = None): 13 53 ospath = _buildDescriptionOsPath(collection_guid, observation_guid, result_guid) 14 54 response = os_engine.getDescription(ospath) 15 return _dispatchResponse(request, response) 55 context = {} 56 context['response'] = mark_safe(response) 57 return _dispatchResponse(request, 'responseTemplate', context) 16 58 17 def _doSearch(request, format, collection_guid = None, observation_guid = None, result_guid = None): 59 def _doSearch(request, iformat, collection_guid = None, observation_guid = None, result_guid = None): 60 host = _buildHostURL(request) 18 61 #params = {'q': ['ice', 'snow']} 19 62 params = request.GET.copy() … … 25 68 params[RESULT] = result_guid 26 69 27 response = os_engine.doSearch(format, params_values = params, moles3EPB = request.moles3EPB) 28 return _dispatchResponse(request, response) 70 response = os_engine.doSearch(hostURL, iformat, params_values = params, moles3EPB = request.moles3EPB) 71 context = {} 72 context['response'] = mark_safe(response) 73 return _dispatchResponse(request, 'responseTemplate', context) 29 74 30 def doSearchL0(request, format): 31 #params = {'q': ['ice', 'snow']} 32 return _doSearch(request, format) 75 def doSearchL0(request, iformat): 76 return _doSearch(request, iformat) 33 77 34 def doSearchL1(request, collection_guid, format):35 return _doSearch(request, format, collection_guid)78 def doSearchL1(request, collection_guid, iformat): 79 return _doSearch(request, iformat, collection_guid) 36 80 37 def doSearchL2(request, collection_guid, observation_guid, format):38 return _doSearch(request, format, collection_guid, observation_guid)81 def doSearchL2(request, collection_guid, observation_guid, iformat): 82 return _doSearch(request, iformat, collection_guid, observation_guid) 39 83 40 def doSearchL3(request, collection_guid, observation_guid, result_guid, format):41 return _doSearch(request, format, collection_guid, observation_guid, result_guid)84 def doSearchL3(request, collection_guid, observation_guid, result_guid, iformat): 85 return _doSearch(request, iformat, collection_guid, observation_guid, result_guid) 42 86 43 87 def _buildDescriptionOsPath(collection_guid = None, observation_guid = None, result_guid = None): 44 ospath = "%s/search/" % ( os_engine.ospath)88 ospath = "%s/search/" % (hostURL) 45 89 if collection_guid: 46 90 ospath = "%s%s/" % (ospath, collection_guid) … … 51 95 return ospath 52 96 53 def _dispatchResponse(request, response): 54 c = {} 55 c['response'] = mark_safe(response) 56 c.update(csrf(request)) 57 return render_to_response('responseTemplate', c) 97 def _dispatchResponse(request, template, context): 98 context.update(csrf(request)) 99 return render_to_response(template, context) -
mauRepo/HPFos/trunk/src/libs/commons_db.py
r8353 r8355 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 17 Nov 2011 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 33 from sqlalchemy import MetaData, create_engine -
mauRepo/HPFos/trunk/src/libs/epb.py
r8346 r8355 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 10 Jan 2012 3 30 4 @author: mnagni31 @author: Maurizio Nagni 5 32 ''' 6 33 from sqlalchemy.orm import subqueryload -
mauRepo/HPFos/trunk/src/markup/opensearch/os_engine.py
r8352 r8355 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 24 May 2012 3 30 4 @author: kusanagi31 @author: Maurizio Nagni 5 32 ''' 6 33 … … 23 50 ''' 24 51 25 def __init__(self, osRequest, os path, osEngineHelper = OSEngineHelper()):52 def __init__(self, osRequest, osEngineHelper = OSEngineHelper()): 26 53 ''' 27 54 Constructor … … 31 58 ''' 32 59 self.osRequest = osRequest 33 self.os path = ospath34 self.os EngineHelper = osEngineHelper60 self.osEngineHelper = osEngineHelper 61 self.osHostURL = 'http://localhost' 35 62 36 def doSearch(self, mimetype, params_values, **kwargs): 63 def doSearch(self, hostURL, mimetype, params_values, **kwargs): 64 self.osHostURL = hostURL 37 65 response = None 38 66 for item in self.osRequest.responses: … … 42 70 kwargs['params_values'] = params_values 43 71 queries = QueryTag.queryWithRoleRequest(mimetype, self.osRequest.query.params_model, params_values) 44 return response.generateResponse(self.osRequest.query.doSearch(**kwargs), [queries], self.os path, **kwargs)72 return response.generateResponse(self.osRequest.query.doSearch(**kwargs), [queries], self.osHostURL, **kwargs) 45 73 return None 46 74 -
mauRepo/HPFos/trunk/src/markup/opensearch/query.py
r8346 r8355 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 24 May 2012 3 30 4 @author: kusanagi31 @author: Maurizio Nagni 5 32 ''' 6 33 from xml.etree.ElementTree import Element -
mauRepo/HPFos/trunk/src/markup/template/atom.py
r8346 r8355 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 5 May 2012 3 30 4 @author: kusanagi31 @author: Maurizio Nagni 5 32 ''' 6 33 from markup.template.osresponse import OSResponse -
mauRepo/HPFos/trunk/src/markup/template/osresponse.py
r8352 r8355 1 1 ''' 2 BSD Licence 3 Copyright (c) 2012, Science & Technology Facilities Council (STFC) 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without modification, 7 are permitted provided that the following conditions are met: 8 9 * Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 * Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 * Neither the name of the Science & Technology Facilities Council (STFC) 15 nor the names of its contributors may be used to endorse or promote 16 products derived from this software without specific prior written permission. 17 18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 2 29 Created on 21 May 2012 3 30 4 @author: kusanagi31 @author: Maurizio Nagni 5 32 ''' 6 33 from abc import abstractmethod
Note: See TracChangeset
for help on using the changeset viewer.