Ignore:
Location:
cowsserver/branches/migrate-py26-pylons10/lib/cowsserver
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/tests/functional/test_csmlwcs.py

    r6072 r7345  
    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/branches/migrate-py26-pylons10/lib/cowsserver/tests/functional/test_csmlwfs.py

    r6072 r7345  
    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/branches/migrate-py26-pylons10/lib/cowsserver/tests/functional/test_coastwms.py

    r6072 r7345  
    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/branches/migrate-py26-pylons10/lib/cowsserver/tests/functional/test_demon.py

    r6072 r7345  
    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/branches/migrate-py26-pylons10/lib/cowsserver/tests/functional/test_catalogue.py

    r6072 r7345  
    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/branches/migrate-py26-pylons10/lib/cowsserver/tests/functional/test_csmlwms.py

    r6072 r7345  
    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/branches/migrate-py26-pylons10/lib/cowsserver/tests/__init__.py

    r6096 r7345  
    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/branches/migrate-py26-pylons10/lib/cowsserver/config/middleware.py

    r7340 r7482  
    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 
    87from pylons.middleware import ErrorHandler, StatusCodeRedirect 
    98from pylons.wsgiapp import PylonsApp 
    10  
    11 from pylons import __version__ as pylons_version 
    12  
    13 def is_096(): 
    14     parts = pylons_version.split('.') 
    15     return parts[:3] == ['0', '9', '6'] 
    16          
    17  
    18 if not is_096(): 
    19     from beaker.middleware import SessionMiddleware 
    20     from routes.middleware import RoutesMiddleware 
    21  
     9from routes.middleware import RoutesMiddleware 
    2210 
    2311from cowsserver.config.environment import load_environment 
    2412 
    25  
    26 def make_app(global_conf, full_stack=True, **app_conf): 
     13def make_app(global_conf, full_stack=True, static_files=True, **app_conf): 
    2714    """Create a Pylons WSGI application and return it 
    2815 
     
    3219 
    3320    ``full_stack`` 
    34         Whether or not this application provides a full WSGI stack (by 
    35         default, meaning it handles its own exceptions and errors). 
    36         Disable full_stack when this application is "managed" by 
    37         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. 
    3829 
    3930    ``app_conf`` 
    40         The application's local configuration. Normally specified in the 
    41         [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> 
    4233        defaults to main). 
     34 
    4335    """ 
    44  
    45     if is_096(): 
    46         return make_app_096(global_conf, fullstack, **app_conf) 
    4736 
    4837    # Configure the Pylons environment 
     
    5241    app = PylonsApp(config=config) 
    5342 
     43    # Routing/Session Middleware 
     44    app = RoutesMiddleware(app, config['routes.map'], singleton=False) 
     45    app = SessionMiddleware(app, config) 
     46 
    5447    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) 
    55     app = RoutesMiddleware(app, config['routes.map']) 
    56     app = SessionMiddleware(app, config) 
    5748 
    5849    if asbool(full_stack): 
     
    6051        app = ErrorHandler(app, global_conf, **config['pylons.errorware']) 
    6152 
     53        # Display error documents for 401, 403, 404 status codes (and 
     54        # 500 when debug is disabled) 
    6255        if asbool(config['debug']): 
    6356            app = StatusCodeRedirect(app) 
    6457        else: 
    65             app = StatusCodeRedirect(app, [401, 403, 404, 500]) 
     58            app = StatusCodeRedirect(app, [400, 401, 403, 404, 500]) 
    6659 
    6760    # Establish the Registry for this application 
    6861    app = RegistryManager(app) 
    6962 
    70     # Static files 
    71     static_app = StaticURLParser(config['pylons.paths']['static_files']) 
    72     app = Cascade([static_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 
    7369    return app 
    74  
    75  
    76 def 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  
    84     # Configure the Pylons environment 
    85     load_environment(global_conf, app_conf) 
    86  
    87     # The Pylons WSGI app 
    88     app = PylonsApp() 
    89  
    90     # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) 
    91      
    92     if asbool(full_stack): 
    93         # Handle Python exceptions 
    94         app = ErrorHandler(app, global_conf, **config['pylons.errorware']) 
    95  
    96     # Establish the Registry for this application 
    97     app = RegistryManager(app) 
    98  
    99     # Static files 
    100     javascripts_app = StaticJavascripts() 
    101     static_app = StaticURLParser(config['pylons.paths']['static_files']) 
    102     app = Cascade([static_app, javascripts_app, app]) 
    103     return app 
  • cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/config/environment.py

    r7340 r7483  
    1515    object 
    1616    """ 
     17    config = PylonsConfig() 
     18 
    1719    # Pylons paths 
    1820    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 
     
    2426    # Initialize config with the basic options 
    2527    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 
    2731    config['routes.map'] = make_map(config) 
     
    3741    # CONFIGURATION OPTIONS HERE (note: all config options will override 
    3842    # any Pylons config options) 
    39     configCSML() 
     43    config['pylons.strict_tmpl_context'] = False 
     44    configCSML(config) 
    4045 
    4146    return config 
    4247 
    43 config = PylonsConfig() 
  • cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/config/routing.py

    r7340 r7484  
    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') 
    21  
    2225    map.connect('/{fileoruri}/wms', controller='csmlwms', action='index') 
    2326    map.connect('/{fileoruri}/wms2', controller='csmlwms_csml', action='index') 
    2427     
    25     map.connect('wcsroute', ':fileoruri/wcs', controller='csmlwcs') #wcsroute is a named route. 
    26      
     28 
     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  
    2734    map.connect('{fileoruri}/wfs', controller='csmlwfs') 
    28     #filestore - used for fetching files referenced by (csml) StorageDescriptors (WFS), and  'store' in wcs if implemented 
     35 
     36    # "filestore" - used for fetching files referenced by (csml)  
     37    # StorageDescriptors (WFS), and  'store' in wcs if implemented 
    2938    map.connect('filestore/{file}', controller='fetch', action='fetchFile') 
    3039    map.connect('{fileoruri}/demo', controller='demo') 
    3140    map.connect('/', controller='catalogue', action='index') 
    3241 
    33  
    34     #map.connect('{controller}/{action}/{id}') 
    35     #map.connect('*url', controller='template', action='view') 
    36  
    3742    return map 
  • cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/websetup.py

    r6072 r7486  
    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/branches/migrate-py26-pylons10/lib/cowsserver/controllers/coastwms.py

    r6506 r7487  
    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/branches/migrate-py26-pylons10/lib/cowsserver/controllers/demo.py

    r6072 r7488  
    1010        c.featureCollection = globalCSMLConnector.getCsmlDoc(fileoruri) 
    1111        c.fcName = fileoruri 
    12         return render('demo') 
     12        return render('demo.html') 
  • cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/lib/base.py

    r7340 r7343  
    44utilized by Controllers. 
    55""" 
    6 from pylons import cache, config, g, request, response, session 
     6from pylons import cache, config, app_globals, request, response, session 
    77from pylons import tmpl_context as c 
    88from pylons.controllers import WSGIController 
    9 from pylons.controllers.util import abort, etag_cache, redirect_to 
     9from pylons.controllers.util import abort, etag_cache, redirect 
    1010from pylons.decorators import jsonify, validate 
    1111from pylons.i18n import _, ungettext, N_ 
    12 from pylons.templating import render 
     12from pylons.templating import render_genshi as render 
    1313 
    1414import cowsserver.lib.helpers as h 
  • cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/lib/helpers.py

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

    r7340 r7485  
    66from pylons import url 
    77from pylons import config,request    
     8 
    89if 'cows.cowsclienturl' in config: 
    910    cowsclient = True 
  • cowsserver/branches/migrate-py26-pylons10/lib/cowsserver/templates/demo.html

    r5734 r7489  
    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 
Note: See TracChangeset for help on using the changeset viewer.