Changeset 7589 for cowsserver


Ignore:
Timestamp:
11/10/10 14:24:27 (9 years ago)
Author:
astephen
Message:

Updated changes to be compatible with:

  • python 2.6
  • pylons 1.0
Location:
cowsserver/trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • cowsserver/trunk/buildout/buildout.cfg

    r6506 r7589  
    44develop =  
    55  ../ 
     6find-links = http://ndg.nerc.ac.uk/dist 
    67 
    78[cowsserver] 
     
    910interpreter = py 
    1011eggs = 
    11   geoplot 
    12   basemap 
    13   matplotlib 
    1412  numpy==1.3.0 
    15   image_utils 
    16   decorator==3.0.1 
    17   Pylons==0.9.6.1 
    18   cdat_lite 
    19   Paste 
    20   PasteScript 
    21   Genshi 
    22   csml=2.7.9 
    23   cows 
    24   nose 
    25   mock 
    26   setuptools 
    27   cowsserver 
    28   simplejson 
    29   Shapely 
    30   WebHelpers==0.6.4 
    31 # used for testing 
    32   libxml2dom 
    33   owslib  
     13  pycairo==1.2.2 
     14  PIL==1.1.7 
     15  Shapely==1.2.5   
     16  cdat-lite==5.2-1 
     17  geoplot>=0.4.0 
     18  csml==2.7.13   
     19  Pylons==1.0 
     20  Beaker==1.5.4 
     21  decorator==3.2.0  
     22  FormEncode==1.2.3dev 
     23  Mako==0.3.4 
     24  MarkupSafe==0.11   
     25  nose==0.11.4   
     26  Paste==1.7.5.1 
     27  PasteDeploy==1.3.4 
     28  PasteScript==1.7.3 
     29  Routes==1.12.3 
     30  simplejson==2.1.1 
     31  Tempita==0.5dev 
     32  WebError==0.10.2 
     33  WebHelpers==1.2 
     34  WebOb==1.0 
     35  WebTest==1.2.2  
     36  Genshi==0.6 
     37  OWSLib==0.3.1      
     38  matplotlib==1.0.0   
     39  basemap==1.0 
     40  mock==0.7.0b2 
     41  wsgiref==0.1.2   
     42  cows>=1.6.0 
     43  cowsserver>=1.6.0 
     44   
     45# For testing only 
     46#  libxml2-python==2.6.21 
     47#  libxml2dom==0.4.7 
     48 
  • cowsserver/trunk/lib/cowsserver/config/environment.py

    r6072 r7589  
    22import os 
    33 
    4 from pylons import config 
     4from pylons.configuration import PylonsConfig 
     5from genshi.template import TemplateLoader 
    56 
    67import cowsserver.lib.app_globals as app_globals 
     
    1415    object 
    1516    """ 
     17    config = PylonsConfig() 
     18 
    1619    # Pylons paths 
    1720    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 
     
    2225 
    2326    # Initialize config with the basic options 
    24     config.init_app(global_conf, app_conf, package='cowsserver', 
    25                     template_engine='genshi', paths=paths) 
     27    config.init_app(global_conf, app_conf, package='cowsserver', paths=paths) 
     28    config['pylons.strict_c'] = False 
     29    config['pylons.c_attach_args'] = True 
    2630 
    27     config['routes.map'] = make_map() 
    28     config['pylons.g'] = app_globals.Globals() 
     31    config['routes.map'] = make_map(config) 
     32    config['pylons.app_globals'] = app_globals.Globals(config) 
    2933    config['pylons.h'] = cowsserver.lib.helpers 
    3034 
    31     # Customize templating options via this variable 
    32     tmpl_options = config['buffet.template_options'] 
     35    import pylons 
     36    pylons.cache._push_object(config['pylons.app_globals'].cache) 
     37 
     38    config['pylons.app_globals'].genshi_loader = TemplateLoader( 
     39        paths['templates'], auto_reload=True) 
    3340 
    3441    # CONFIGURATION OPTIONS HERE (note: all config options will override 
    3542    # any Pylons config options) 
    36     configCSML() 
     43    config['pylons.strict_tmpl_context'] = False 
     44    configCSML(config) 
     45 
     46    return config 
     47 
  • cowsserver/trunk/lib/cowsserver/config/middleware.py

    r6072 r7589  
    11"""Pylons middleware initialization""" 
     2from beaker.middleware import SessionMiddleware 
    23from paste.cascade import Cascade 
    34from paste.registry import RegistryManager 
    45from paste.urlparser import StaticURLParser 
    56from paste.deploy.converters import asbool 
    6  
    7 from pylons import config 
    8 from pylons.error import error_template 
    9 from pylons.middleware import error_mapper, ErrorDocuments, ErrorHandler, \ 
    10     StaticJavascripts 
     7from pylons.middleware import ErrorHandler, StatusCodeRedirect 
    118from pylons.wsgiapp import PylonsApp 
    12  
    13 from pylons import __version__ as pylons_version 
    14 if pylons_version >= '0.9.7': 
    15     from beaker.middleware import CacheMiddleware, SessionMiddleware 
    16     from routes.middleware import RoutesMiddleware 
    17  
     9from routes.middleware import RoutesMiddleware 
    1810 
    1911from cowsserver.config.environment import load_environment 
    2012 
    21  
    22 def make_app(global_conf, full_stack=True, **app_conf): 
     13def make_app(global_conf, full_stack=True, static_files=True, **app_conf): 
    2314    """Create a Pylons WSGI application and return it 
    2415 
     
    2819 
    2920    ``full_stack`` 
    30         Whether or not this application provides a full WSGI stack (by 
    31         default, meaning it handles its own exceptions and errors). 
    32         Disable full_stack when this application is "managed" by 
    33         another WSGI middleware. 
     21        Whether this application provides a full WSGI stack (by default, 
     22        meaning it handles its own exceptions and errors). Disable 
     23        full_stack when this application is "managed" by another WSGI 
     24        middleware. 
     25 
     26    ``static_files`` 
     27        Whether this application serves its own static files; disable 
     28        when another web server is responsible for serving them. 
    3429 
    3530    ``app_conf`` 
    36         The application's local configuration. Normally specified in the 
    37         [app:<name>] section of the Paste ini file (where <name> 
     31        The application's local configuration. Normally specified in 
     32        the [app:<name>] section of the Paste ini file (where <name> 
    3833        defaults to main). 
     34 
    3935    """ 
     36 
    4037    # Configure the Pylons environment 
    41     load_environment(global_conf, app_conf) 
     38    config = load_environment(global_conf, app_conf) 
    4239 
    4340    # The Pylons WSGI app 
    44     app = PylonsApp() 
     41    app = PylonsApp(config=config) 
     42 
     43    # Routing/Session Middleware 
     44    app = RoutesMiddleware(app, config['routes.map'], singleton=False) 
     45    app = SessionMiddleware(app, config) 
    4546 
    4647    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) 
    47      
    48     if pylons_version >= '0.9.7': 
    49         app = RoutesMiddleware(app, config['routes.map']) 
    50         app = SessionMiddleware(app, config) 
    51         app = CacheMiddleware(app, config) 
    5248 
    5349    if asbool(full_stack): 
    5450        # Handle Python exceptions 
    55         app = ErrorHandler(app, global_conf, error_template=error_template, 
    56                            **config['pylons.errorware']) 
     51        app = ErrorHandler(app, global_conf, **config['pylons.errorware']) 
    5752 
    5853        # Display error documents for 401, 403, 404 status codes (and 
    5954        # 500 when debug is disabled) 
    60         app = ErrorDocuments(app, global_conf, mapper=error_mapper, **app_conf) 
     55        if asbool(config['debug']): 
     56            app = StatusCodeRedirect(app) 
     57        else: 
     58            app = StatusCodeRedirect(app, [400, 401, 403, 404, 500]) 
    6159 
    6260    # Establish the Registry for this application 
    6361    app = RegistryManager(app) 
    6462 
    65     # Static files 
    66     javascripts_app = StaticJavascripts() 
    67     static_app = StaticURLParser(config['pylons.paths']['static_files']) 
    68     app = Cascade([static_app, javascripts_app, app]) 
     63    if asbool(static_files): 
     64        # Serve static files 
     65        static_app = StaticURLParser(config['pylons.paths']['static_files']) 
     66        app = Cascade([static_app, app]) 
     67    app.config = config 
     68 
    6969    return app 
  • cowsserver/trunk/lib/cowsserver/config/routing.py

    r6101 r7589  
    88from routes import Mapper 
    99 
    10 def make_map(): 
     10def make_map(config): 
    1111    """Create, configure and return the routes Mapper""" 
    1212    map = Mapper(directory=config['pylons.paths']['controllers'], 
    1313                 always_scan=config['debug']) 
    1414 
     15    # We need minization switched on 
     16    map.minimization = True 
     17    map.explicit = False 
     18 
    1519    # The ErrorController route (handles 404/500 error pages); it should 
    1620    # likely stay at the top, ensuring it can always be resolved 
    17     map.connect('error/:action/:id', controller='error') 
     21    map.connect('/error/{action}', controller='error') 
     22    map.connect('/error/{action}/{id}', controller='error') 
    1823 
    1924    # CUSTOM ROUTES HERE 
    20     map.connect('coastwms', controller='coastwms') 
     25    map.connect('/{fileoruri}/wms', controller='csmlwms', action='index') 
     26    map.connect('/{fileoruri}/wms2', controller='csmlwms_csml', action='index') 
     27     
    2128 
    22     map.connect(':fileoruri/wms', controller='csmlwms') 
    23     map.connect(':fileoruri/wms2', controller='csmlwms_csml')     
    24      
    25     map.connect('wcsroute', ':fileoruri/wcs', controller='csmlwcs') #wcsroute is a named route. 
    26      
    27     map.connect(':fileoruri/wfs', controller='csmlwfs') 
    28     #filestore - used for fetching files referenced by (csml) StorageDescriptors (WFS), and  'store' in wcs if implemented 
    29     map.connect('filestore/:file', controller='fetch', action='fetchFile') 
    30     map.connect(':fileoruri/demo', controller='demo') 
    31     map.connect('', controller='catalogue') 
     29## NOTE: Should the following two have action='index'? 
     30    # "wcsroute" is a named route 
     31    map.connect('wcsroute', '{fileoruri}/wcs', controller='csmlwcs') 
     32    
     33    # Not sure about this route  
     34    map.connect('{fileoruri}/wfs', controller='csmlwfs') 
    3235 
    33  
    34     map.connect(':controller/:action/:id') 
    35     map.connect('*url', controller='template', action='view') 
     36    # "filestore" - used for fetching files referenced by (csml)  
     37    # StorageDescriptors (WFS), and  'store' in wcs if implemented 
     38    map.connect('filestore/{file}', controller='fetch', action='fetchFile') 
     39    map.connect('{fileoruri}/demo', controller='demo') 
     40    map.connect('/', controller='catalogue', action='index') 
    3641 
    3742    return map 
  • cowsserver/trunk/lib/cowsserver/controllers/coastwms.py

    r6506 r7589  
    1313from cows.exceptions import InvalidParameterValue 
    1414 
    15 from routes import url_for 
    1615from cows.model.wms import WmsDatasetSummary 
    1716from cowsserver.lib.wms_request_log_utils import buildLogString, wms_request_logger 
     
    126125                bboxObjs.append(BoundingBox(bbox[:2], bbox[2:], crs=crs)) 
    127126                 
    128  
    129                  
    130             #URL to WCS - uses named route 'wcsroute' 
    131             #TODO: Allow for a WCS blacklist to opt out of providing dataurls for certain datasets? 
    132             #TODO: How to make this more configurable - what if WCS is not coupled with WMS? 
    133 #            try: 
    134 #                version='1.0.0' #wcs version 
    135 #                wcsbaseurl=url_for('wcsroute', fileoruri=c.fileoruri,qualified=True)+'?' 
    136 #                dataURLs=[DataURL(format='WCS:CoverageDescription', onlineResource='%sService=WCS&Request=DescribeCoverage&Coverage=%s&Version=%s'%(wcsbaseurl, layerName, version))] 
    137 #            except GenerationException: 
    138 #                log.info("dataURLs not populated: could not generate WCS url with url_for('wcsroute', filedoruri=%s,qualified=True)"%c.fileoruri) 
    139 #                dataURLs=[] 
    140              
    141127            onlineRes = OnlineResource(self._getIndexActionURL() +\ 
    142128                                    "?request=GetDisplayOptions&layers=%s" % layerName) 
     
    421407        """ 
    422408                 
    423         indexURL = url_for(qualified=True, action='index') 
     409        indexURL = pylons.url(qualified=True, action='index') 
    424410        return indexURL     
  • cowsserver/trunk/lib/cowsserver/controllers/demo.py

    r6072 r7589  
    1010        c.featureCollection = globalCSMLConnector.getCsmlDoc(fileoruri) 
    1111        c.fcName = fileoruri 
    12         return render('demo') 
     12        return render('demo.html') 
  • cowsserver/trunk/lib/cowsserver/lib/base.py

    r6395 r7589  
    44utilized by Controllers. 
    55""" 
    6 from pylons import c, cache, config, g, request, response, session 
     6from pylons import cache, config, app_globals, request, response, session 
     7from pylons import tmpl_context as c 
    78from pylons.controllers import WSGIController 
    8 from pylons.controllers.util import abort, etag_cache, redirect_to 
     9from pylons.controllers.util import abort, etag_cache, redirect 
    910from pylons.decorators import jsonify, validate 
    1011from pylons.i18n import _, ungettext, N_ 
    11 from pylons.templating import render 
     12from pylons.templating import render_genshi as render 
    1213 
    1314import cowsserver.lib.helpers as h 
  • cowsserver/trunk/lib/cowsserver/lib/helpers.py

    r5403 r7589  
    44available to Controllers. This module is available to both as 'h'. 
    55""" 
    6 from webhelpers import * 
    7 from webhelpers.rails import * 
     6 
  • cowsserver/trunk/lib/cowsserver/templates/catalogue.xml

    r6101 r7589  
    66from routes import url_for 
    77from pylons import config,request    
     8 
    89if 'cows.cowsclienturl' in config: 
    910    cowsclient = True 
  • cowsserver/trunk/lib/cowsserver/templates/demo.html

    r5734 r7589  
    55 
    66<?python 
    7  
     7import pylons 
    88 
    99?> 
     
    1313 
    1414<script src="http://www.openlayers.org/api/OpenLayers.js" type="text/javascript"></script > 
    15 <script src="${h.url_for('/demo.js', qualified=True)}" type="text/javascript"></script> 
     15<script src="${pylons.url('/demo.js', qualified=True)}" type="text/javascript"></script> 
    1616 
    1717<script type="text/javascript"> 
    18 var fcURL = "${h.url_for(controller='csmlwms', fileoruri=c.fcName)}"; 
     18var fcURL = "${pylons.url(controller='csmlwms', fileoruri=c.fcName)}"; 
    1919</script> 
    2020 
  • cowsserver/trunk/lib/cowsserver/tests/__init__.py

    r6096 r7589  
    1313from unittest import TestCase 
    1414 
    15 import pkg_resources 
    16 import paste.fixture 
    17 import paste.script.appinstall 
    1815from paste.deploy import loadapp 
    19 from routes import url_for 
     16from paste.script.appinstall import SetupCommand 
     17from pylons import url 
     18from routes.util import URLGenerator 
     19from webtest import TestApp 
    2020 
    21 __all__ = ['url_for', 'TestController'] 
     21import pylons.test 
    2222 
    23 conf_dir = None 
     23__all__ = ['environ', 'url', 'TestController'] 
    2424 
    25 def setup_tests(): 
    26     global conf_dir 
    27      
    28     here_dir = os.path.dirname(os.path.abspath(__file__)) 
    29     conf_dir = os.path.dirname(os.path.dirname(os.path.dirname(here_dir))) 
    30      
    31     sys.path.insert(0, conf_dir) 
    32     pkg_resources.working_set.add_entry(conf_dir) 
    33     pkg_resources.require('Paste') 
    34     pkg_resources.require('PasteScript') 
    35      
    36     test_file = os.path.join(conf_dir, 'test.ini') 
    37     cmd = paste.script.appinstall.SetupCommand('setup-app') 
    38     cmd.run([test_file]) 
     25# Invoke websetup with the current config file 
     26SetupCommand('setup-app').run([pylons.test.pylonsapp.config['__file__']]) 
     27 
     28environ = {} 
    3929 
    4030class TestController(TestCase): 
    4131 
    4232    def __init__(self, *args, **kwargs): 
    43         wsgiapp = loadapp('config:test.ini', relative_to=conf_dir) 
    44         self.app = paste.fixture.TestApp(wsgiapp) 
     33        wsgiapp = pylons.test.pylonsapp 
     34        config = wsgiapp.config 
     35        self.app = TestApp(wsgiapp) 
     36        url._push_object(URLGenerator(config['routes.map'], environ)) 
    4537        TestCase.__init__(self, *args, **kwargs) 
     38 
  • cowsserver/trunk/lib/cowsserver/tests/functional/test_catalogue.py

    r6072 r7589  
    77 
    88    def test_index(self): 
    9         response = self.app.get(url_for(controller='catalogue')) 
     9        response = self.app.get(url(controller='catalogue')) 
    1010        # Test response... 
  • cowsserver/trunk/lib/cowsserver/tests/functional/test_coastwms.py

    r6072 r7589  
    99                  'version':'1.1.3'} 
    1010         
    11         response = self.app.get(url_for(controller='coastwms'), params=params) 
     11        response = self.app.get(url(controller='coastwms'), params=params) 
    1212         
    1313        print dir(response) 
  • cowsserver/trunk/lib/cowsserver/tests/functional/test_csmlwcs.py

    r6072 r7589  
    55 
    66    def test_index(self): 
    7         response = self.app.get(url_for(controller='coastwms')) 
     7        response = self.app.get(url(controller='coastwms')) 
    88        # Test response... 
  • cowsserver/trunk/lib/cowsserver/tests/functional/test_csmlwfs.py

    r6072 r7589  
    55 
    66    def test_index(self): 
    7         response = self.app.get(url_for(controller='csmlwfs')) 
     7        response = self.app.get(url(controller='csmlwfs')) 
    88        # Test response... 
  • cowsserver/trunk/lib/cowsserver/tests/functional/test_csmlwms.py

    r6072 r7589  
    44 
    55    def test_index(self): 
    6         response = self.app.get(url_for(controller='csmlwms')) 
     6        response = self.app.get(url(controller='csmlwms')) 
    77        # Test response... 
  • cowsserver/trunk/lib/cowsserver/tests/functional/test_demon.py

    r6072 r7589  
    55 
    66    def test_index(self): 
    7         response = self.app.get(url_for(controller='demo')) 
     7        response = self.app.get(url(controller='demo')) 
    88        # Test response... 
  • cowsserver/trunk/lib/cowsserver/websetup.py

    r6072 r7589  
    22import logging 
    33 
    4 from paste.deploy import appconfig 
    5 from pylons import config 
     4import pylons.test 
    65 
    76from cowsserver.config.environment import load_environment 
     
    98log = logging.getLogger(__name__) 
    109 
    11 def setup_config(command, filename, section, vars): 
    12     """Place any commands to setup your server here""" 
    13     conf = appconfig('config:' + filename) 
    14     load_environment(conf.global_conf, conf.local_conf) 
     10def setup_app(command, conf, vars): 
     11    """Place any commands to setup notcows here""" 
     12    # Don't reload the app if it was loaded under the testing environment 
     13    if not pylons.test.pylonsapp: 
     14        load_environment(conf.global_conf, conf.local_conf) 
  • cowsserver/trunk/setup.py

    r6535 r7589  
    88setup( 
    99    name='cowsserver', 
    10     version='1.5.1', 
     10    version='1.6.0', 
    1111    #description='', 
    1212    #author='', 
     
    1414    #url='', 
    1515    find_links=['http://ndg.nerc.ac.uk/dist'], 
    16     install_requires=["Pylons>=0.9.6.1", 'csml', 'genshi'], 
     16    install_requires=['Pylons>=1.0', 'genshi>=0.6', 'numpy==1.3.0', 'cdat_lite>=5.2', 'csml>=2.7', 
     17                      'pycairo>=1.2', 'Shapely>=1.2.5', 'PIL>=1.1.7', 
     18                      'matplotlib==1.0.0', 'basemap==1.0.0', 
     19                      'mock>=1.7', 'owslib==0.3.1', 'geoplot>=0.4.0', 'image_utils>=1.1.0'], 
    1720 
    1821    packages=find_packages('lib'), 
Note: See TracChangeset for help on using the changeset viewer.