Changeset 7340


Ignore:
Timestamp:
18/08/10 15:55:52 (9 years ago)
Author:
spascoe
Message:

Starting a branch for migrating COWSserver to Pylons-1.0 and Python-2.6.

Several necessary changes from trunk are included in this commit.

Location:
cowsserver/branches/migrate-py26-pylons10
Files:
9 edited
1 copied

Legend:

Unmodified
Added
Removed
  • cowsserver/branches/migrate-py26-pylons10/buildout/buildout.cfg

    r6506 r7340  
    44develop =  
    55  ../ 
     6find-links = http://ndg.nerc.ac.uk/dist 
    67 
    78[cowsserver] 
     
    1415  numpy==1.3.0 
    1516  image_utils 
    16   decorator==3.0.1 
    17   Pylons==0.9.6.1 
     17  Pylons==1.0 
    1818  cdat_lite 
    1919  Paste 
    2020  PasteScript 
    2121  Genshi 
    22   csml=2.7.9 
     22  csml 
    2323  cows 
    2424  nose 
     
    2828  simplejson 
    2929  Shapely 
    30   WebHelpers==0.6.4 
    3130# used for testing 
    3231  libxml2dom 
  • cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/config/environment.py

    r6072 r7340  
    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 
     
    2223 
    2324    # Initialize config with the basic options 
    24     config.init_app(global_conf, app_conf, package='cowsserver', 
    25                     template_engine='genshi', paths=paths) 
     25    config.init_app(global_conf, app_conf, package='cowsserver', paths=paths) 
    2626 
    27     config['routes.map'] = make_map() 
    28     config['pylons.g'] = app_globals.Globals() 
     27    config['routes.map'] = make_map(config) 
     28    config['pylons.app_globals'] = app_globals.Globals(config) 
    2929    config['pylons.h'] = cowsserver.lib.helpers 
    3030 
    31     # Customize templating options via this variable 
    32     tmpl_options = config['buffet.template_options'] 
     31    import pylons 
     32    pylons.cache._push_object(config['pylons.app_globals'].cache) 
     33 
     34    config['pylons.app_globals'].genshi_loader = TemplateLoader( 
     35        paths['templates'], auto_reload=True) 
    3336 
    3437    # CONFIGURATION OPTIONS HERE (note: all config options will override 
    3538    # any Pylons config options) 
    3639    configCSML() 
     40 
     41    return config 
     42 
     43config = PylonsConfig() 
  • cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/config/middleware.py

    r6072 r7340  
    66 
    77from pylons import config 
    8 from pylons.error import error_template 
    9 from pylons.middleware import error_mapper, ErrorDocuments, ErrorHandler, \ 
    10     StaticJavascripts 
     8from pylons.middleware import ErrorHandler, StatusCodeRedirect 
    119from pylons.wsgiapp import PylonsApp 
    1210 
    1311from pylons import __version__ as pylons_version 
    14 if pylons_version >= '0.9.7': 
    15     from beaker.middleware import CacheMiddleware, SessionMiddleware 
     12 
     13def is_096(): 
     14    parts = pylons_version.split('.') 
     15    return parts[:3] == ['0', '9', '6'] 
     16         
     17 
     18if not is_096(): 
     19    from beaker.middleware import SessionMiddleware 
    1620    from routes.middleware import RoutesMiddleware 
    1721 
     
    3842        defaults to main). 
    3943    """ 
     44 
     45    if is_096(): 
     46        return make_app_096(global_conf, fullstack, **app_conf) 
     47 
     48    # Configure the Pylons environment 
     49    config = load_environment(global_conf, app_conf) 
     50 
     51    # The Pylons WSGI app 
     52    app = PylonsApp(config=config) 
     53 
     54    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) 
     55    app = RoutesMiddleware(app, config['routes.map']) 
     56    app = SessionMiddleware(app, config) 
     57 
     58    if asbool(full_stack): 
     59        # Handle Python exceptions 
     60        app = ErrorHandler(app, global_conf, **config['pylons.errorware']) 
     61 
     62        if asbool(config['debug']): 
     63            app = StatusCodeRedirect(app) 
     64        else: 
     65            app = StatusCodeRedirect(app, [401, 403, 404, 500]) 
     66 
     67    # Establish the Registry for this application 
     68    app = RegistryManager(app) 
     69 
     70    # Static files 
     71    static_app = StaticURLParser(config['pylons.paths']['static_files']) 
     72    app = Cascade([static_app, app]) 
     73    return app 
     74 
     75 
     76def make_app_096(global_conf, full_stack=True, **app_conf): 
     77    """Create a Pylons WSGI application and return it 
     78 
     79    Legacy app config for Pylons 0.9.6 
     80    """ 
     81 
     82    from pylons.middleware import StaticJavascripts 
     83 
    4084    # Configure the Pylons environment 
    4185    load_environment(global_conf, app_conf) 
     
    4690    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) 
    4791     
    48     if pylons_version >= '0.9.7': 
    49         app = RoutesMiddleware(app, config['routes.map']) 
    50         app = SessionMiddleware(app, config) 
    51         app = CacheMiddleware(app, config) 
    52  
    5392    if asbool(full_stack): 
    5493        # Handle Python exceptions 
    55         app = ErrorHandler(app, global_conf, error_template=error_template, 
    56                            **config['pylons.errorware']) 
    57  
    58         # Display error documents for 401, 403, 404 status codes (and 
    59         # 500 when debug is disabled) 
    60         app = ErrorDocuments(app, global_conf, mapper=error_mapper, **app_conf) 
     94        app = ErrorHandler(app, global_conf, **config['pylons.errorware']) 
    6195 
    6296    # Establish the Registry for this application 
  • cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/config/routing.py

    r6101 r7340  
    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'], 
     
    1515    # The ErrorController route (handles 404/500 error pages); it should 
    1616    # likely stay at the top, ensuring it can always be resolved 
    17     map.connect('error/:action/:id', controller='error') 
     17    map.connect('error/{action}/{id}', controller='error') 
    1818 
    1919    # CUSTOM ROUTES HERE 
    20     map.connect('coastwms', controller='coastwms') 
     20    #map.connect('coastwms', controller='coastwms') 
    2121 
    22     map.connect(':fileoruri/wms', controller='csmlwms') 
    23     map.connect(':fileoruri/wms2', controller='csmlwms_csml')     
     22    map.connect('/{fileoruri}/wms', controller='csmlwms', action='index') 
     23    map.connect('/{fileoruri}/wms2', controller='csmlwms_csml', action='index') 
    2424     
    2525    map.connect('wcsroute', ':fileoruri/wcs', controller='csmlwcs') #wcsroute is a named route. 
    2626     
    27     map.connect(':fileoruri/wfs', controller='csmlwfs') 
     27    map.connect('{fileoruri}/wfs', controller='csmlwfs') 
    2828    #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    map.connect('filestore/{file}', controller='fetch', action='fetchFile') 
     30    map.connect('{fileoruri}/demo', controller='demo') 
     31    map.connect('/', controller='catalogue', action='index') 
    3232 
    3333 
    34     map.connect(':controller/:action/:id') 
    35     map.connect('*url', controller='template', action='view') 
     34    #map.connect('{controller}/{action}/{id}') 
     35    #map.connect('*url', controller='template', action='view') 
    3636 
    3737    return map 
  • cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/lib/app_globals.py

    r5403 r7340  
    11"""The application's Globals object""" 
    22from pylons import config 
     3 
     4from beaker.cache import CacheManager 
     5from beaker.util import parse_cache_config_options 
    36 
    47class Globals(object): 
     
    710    """ 
    811 
    9     def __init__(self): 
     12    def __init__(self, config): 
    1013        """One instance of Globals is created during application 
    1114        initialization and is available during requests via the 'g' 
    1215        variable 
    1316        """ 
    14         pass 
     17        self.cache = CacheManager(**parse_cache_config_options(config)) 
     18 
  • cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/lib/base.py

    r6395 r7340  
    44utilized by Controllers. 
    55""" 
    6 from pylons import c, cache, config, g, request, response, session 
     6from pylons import cache, config, g, request, response, session 
     7from pylons import tmpl_context as c 
    78from pylons.controllers import WSGIController 
    89from pylons.controllers.util import abort, etag_cache, redirect_to 
  • cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/lib/helpers.py

    r5403 r7340  
    44available to Controllers. This module is available to both as 'h'. 
    55""" 
    6 from webhelpers import * 
    7 from webhelpers.rails import * 
     6from routes import url_for 
     7 
  • cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/templates/catalogue.xml

    r6101 r7340  
    44 
    55from genshi import QName 
    6 from routes import url_for 
     6from pylons import url 
    77from pylons import config,request    
    88if 'cows.cowsclienturl' in config: 
     
    2727     
    2828      <?python 
    29         wms_url = url_for(controller='csmlwms', fileoruri=fc, id=None, 
    30                         request='GetCapabilities', service='WMS',  
     29        wms_url = url(controller='csmlwms', fileoruri=fc, id=None, 
     30                      request='GetCapabilities', service='WMS',  
     31                      action='index', 
     32                      qualified=True) 
     33 
     34        wcs_url = url(controller='csmlwcs', fileoruri=fc, id=None, 
     35                        request='GetCapabilities', service='WCS',  
     36                      action='index', 
    3137                        qualified=True) 
    3238 
    33         wcs_url = url_for(controller='csmlwcs', fileoruri=fc, id=None, 
    34                         request='GetCapabilities', service='WCS',  
    35                         qualified=True) 
    36  
    37         wfs_url = url_for(controller='csmlwfs', fileoruri=fc, id=None,  
     39        wfs_url = url(controller='csmlwfs', fileoruri=fc, id=None,  
    3840                        request='GetCapabilities', service='WFS',  
     41                      action='index', 
    3942                        qualified=True) 
    4043      ?> 
     
    4750                    
    4851        <py:if test="cowsclient==True"> 
    49           [<a href="${url_for(cowsclienturl) + 'ENDPOINT=' + wms_url}">Visualize</a>] 
     52          [<a href="${url(cowsclienturl) + 'ENDPOINT=' + wms_url}">Visualize</a>] 
    5053        </py:if> 
    5154         
    5255        <py:if test="cowsclient!=True"> 
    53           [<a href="${url_for(controller='demo', fileoruri=fc, qualified=True, host=c.host)}">Demo</a>] 
     56          [<a href="${url(controller='demo', fileoruri=fc, qualified=True, host=c.host)}">Demo</a>] 
    5457        </py:if> 
    5558      </li> 
     
    5861    <ul  py:for="fc, fc_name in c.wfsonly"> 
    5962      <li >${fc_name} 
    60         [<a href="${url_for(controller='csmlwfs', fileoruri=fc, id=None,  
     63        [<a href="${url(controller='csmlwfs', fileoruri=fc, id=None,  
    6164                        request='GetCapabilities', service='WFS', 
    6265                        qualified=True)}" 
  • cowsserver/branches/migrate-py26-pylons10/setup.py

    r6535 r7340  
    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", 'csml', 'genshi'], 
    1717 
    1818    packages=find_packages('lib'), 
Note: See TracChangeset for help on using the changeset viewer.