Changeset 2484


Ignore:
Timestamp:
16/05/07 10:46:44 (12 years ago)
Author:
spascoe
Message:

Created a dummy controller for testing the ows parameter parsing
features. It works :-)

Location:
TI05-delivery/ows_framework/trunk/ows_server
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/development.ini

    r2476 r2484  
    1313use = egg:Paste#http 
    1414host = 0.0.0.0 
    15 port = 5000 
     15port = 8080 
    1616 
    1717[app:main] 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server.egg-info/PKG-INFO

    r2476 r2484  
    11Metadata-Version: 1.0 
    22Name: ows-server 
    3 Version: 0.0.0dev 
     3Version: 0.0.0dev-r2479 
    44Summary: UNKNOWN 
    55Home-page: UNKNOWN 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server.egg-info/SOURCES.txt

    r2476 r2484  
    11README.txt 
     2development.ini 
    23setup.cfg 
    34setup.py 
     5test.ini 
     6ez_setup/README.txt 
    47ez_setup/__init__.py 
     8ez_setup/__init__.pyc 
    59ows_server/__init__.py 
    610ows_server/websetup.py 
     
    1014ows_server.egg-info/entry_points.txt 
    1115ows_server.egg-info/paste_deploy_config.ini_tmpl 
     16ows_server.egg-info/paster_plugins.txt 
    1217ows_server.egg-info/requires.txt 
    1318ows_server.egg-info/top_level.txt 
     
    1722ows_server/config/routing.py 
    1823ows_server/controllers/__init__.py 
     24ows_server/controllers/dummy.py 
    1925ows_server/controllers/error.py 
    2026ows_server/controllers/template.py 
     27ows_server/docs/index.txt 
    2128ows_server/i18n/__init__.py 
    2229ows_server/lib/__init__.py 
     
    2532ows_server/lib/helpers.py 
    2633ows_server/models/__init__.py 
     34ows_server/public/index.html 
     35ows_server/templates/__init__.py 
     36ows_server/templates/autohandler 
     37ows_server/templates/exception_report.kid 
    2738ows_server/tests/__init__.py 
    2839ows_server/tests/test_models.py 
    2940ows_server/tests/functional/__init__.py 
     41ows_server/tests/functional/test_dummy.py 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/config/middleware.py

    r2479 r2484  
    3030    # Load our Pylons configuration defaults 
    3131    config = load_environment(global_conf, app_conf) 
    32     config.init_app(global_conf, app_conf, package='ows_server') 
     32    config.init_app(global_conf, app_conf, package='ows_server', 
     33                    template_engine='kid') 
    3334         
    3435    # Load our default Pylons WSGI app and make g available 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/base.py

    r2479 r2484  
    1313    def __call__(self, environ, start_response): 
    1414 
     15        # All OWS parameter names are case insensitive. 
     16        req = request._current_obj() 
     17        self.ows_params = {} 
     18        for k in req.params: 
     19            self.ows_params[k.lower()] = req.params[k]         
     20 
    1521        try: 
    1622            self._fix_ows_action(environ) 
    1723            return WSGIController.__call__(self, environ, start_response)   
    1824        except OwsError, e: 
    19             return render_response('exception_report', report=e.report) 
     25            return render_response('exception_report', report=e.report, 
     26                                   format='xml') 
    2027             
    2128  
    2229    def _fix_ows_action(self, environ): 
    23         # Override the Routes action from the REQUEST query parameter 
    24         req = pylons.request._current_obj() 
     30        # Override the Routes action from the request query parameter 
    2531        try: 
    26             action = req.params['REQUEST'] 
     32            action = self.ows_params['request'] 
    2733        except KeyError: 
    28             raise OwsError('MissingParameterValue', 'REQUEST parameter not specified', 'REQUEST') 
     34            raise OwsError('MissingParameterValue', 'request parameter not specified', 'request') 
    2935 
    3036        # Check action is a method in self 
    3137        if not getattr(self, action): 
    32             raise OwsError('InvalidParameterValue', 'REQUEST=%s not supported' % action, 'REQUEST') 
     38            raise OwsError('InvalidParameterValue', 'request=%s not supported' % action, 'request') 
    3339 
    34         # override routes action with REQUEST 
    35         environ['pylons.routes_dict'] = action 
    36         del req.params['REQUEST'] 
     40        # override routes action with request 
     41        environ['pylons.routes_dict']['action'] = action 
     42        del self.ows_params['request'] 
    3743 
    3844    def _get_method_args(self): 
    3945        """Extends Controller._get_method_args to retrieve arguments from the query string. 
    40         Each query string parameter is converted to lower case before adding it to the method arguments. 
    4146 
    4247        See the docstring for Controller._get_method_args for details. 
     
    4449        """ 
    4550 
    46         # extract query string arguments 
    47         req = pylons.request._current_obj() 
    48         D = {} 
    49         for key in req.params: 
    50             D[key.lower()] = req.params[key] 
    51  
    5251        # Get the method arguments and add the query string arguments 
    5352        kargs = WSGIController._get_method_args(self) 
    54         kargs.update(D) 
     53        kargs.update(self.ows_params) 
    5554 
    5655        return kargs 
Note: See TracChangeset for help on using the changeset viewer.