Django

Code

Changeset 3875

Show
Ignore:
Timestamp:
09/27/06 20:56:02 (2 years ago)
Author:
adrian
Message:

Changed BaseHandler?.get_response() to take a single parameter (an HttpRequest object) rather than a URL and the HttpRequest object, which is redundant

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/handlers/base.py

    r3411 r3875  
    4949                self._exception_middleware.insert(0, mw_instance.process_exception) 
    5050 
    51     def get_response(self, path, request): 
     51    def get_response(self, request): 
    5252        "Returns an HttpResponse object for the given HttpRequest" 
    5353        from django.core import exceptions, urlresolvers 
     
    6363        resolver = urlresolvers.RegexURLResolver(r'^/', settings.ROOT_URLCONF) 
    6464        try: 
    65             callback, callback_args, callback_kwargs = resolver.resolve(path) 
     65            callback, callback_args, callback_kwargs = resolver.resolve(request.path) 
    6666 
    6767            # Apply view middleware 
     
    106106                receivers = dispatcher.send(signal=signals.got_request_exception) 
    107107                # When DEBUG is False, send an error message to the admins. 
    108                 subject = 'Error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS and 'internal' or 'EXTERNAL'), getattr(request, 'path', '')
     108                subject = 'Error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS and 'internal' or 'EXTERNAL'), request.path
    109109                try: 
    110110                    request_repr = repr(request) 
  • django/trunk/django/core/handlers/modpython.py

    r3866 r3875  
    151151        try: 
    152152            request = ModPythonRequest(req) 
    153             response = self.get_response(req.uri, request) 
     153            response = self.get_response(request) 
    154154 
    155155            # Apply response middleware 
  • django/trunk/django/core/handlers/wsgi.py

    r3820 r3875  
    7575        self.environ = environ 
    7676        self.path = environ['PATH_INFO'] 
    77         self.META = environ  
     77        self.META = environ 
    7878        self.method = environ['REQUEST_METHOD'].upper() 
    7979 
     
    187187        try: 
    188188            request = WSGIRequest(environ) 
    189             response = self.get_response(request.path, request
     189            response = self.get_response(request
    190190 
    191191            # Apply response middleware 
  • django/trunk/django/test/client.py

    r3707 r3875  
    99class ClientHandler(BaseHandler): 
    1010    """ 
    11     A HTTP Handler that can be used for testing purposes.  
     11    A HTTP Handler that can be used for testing purposes. 
    1212    Uses the WSGI interface to compose requests, but returns 
    1313    the raw HttpResponse object 
     
    2525        try: 
    2626            request = WSGIRequest(environ) 
    27             response = self.get_response(request.path, request
     27            response = self.get_response(request
    2828 
    2929            # Apply response middleware 
     
    3333        finally: 
    3434            dispatcher.send(signal=signals.request_finished) 
    35          
     35 
    3636        return response 
    3737 
     
    4545    A simple method for encoding multipart POST data from a dictionary of 
    4646    form values. 
    47      
     47 
    4848    The key will be used as the form data name; the value will be transmitted 
    4949    as content. If the value is a file, the contents of the file will be sent 
     
    7070                str(value) 
    7171            ]) 
    72          
     72 
    7373    lines.extend([ 
    7474        '--' + boundary + '--', 
     
    7979class Client: 
    8080    """ 
    81     A class that can act as a client for testing purposes.  
    82        
     81    A class that can act as a client for testing purposes. 
     82 
    8383    It allows the user to compose GET and POST requests, and 
    8484    obtain the response that the server gave to those requests. 
     
    8989    Client objects are stateful - they will retain cookie (and 
    9090    thus session) details for the lifetime of the Client instance. 
    91      
     91 
    9292    This is not intended as a replacement for Twill/Selenium or 
    9393    the like - it is here to allow testing against the 
     
    9999        self.defaults = defaults 
    100100        self.cookie = SimpleCookie() 
    101          
     101 
    102102    def request(self, **request): 
    103103        """ 
    104         The master request method. Composes the environment dictionary  
     104        The master request method. Composes the environment dictionary 
    105105        and passes to the handler, returning the result of the handler. 
    106106        Assumes defaults for the query environment, which can be overridden 
     
    113113            'QUERY_STRING':      '', 
    114114            'REQUEST_METHOD':    'GET', 
    115             'SCRIPT_NAME':       None,  
     115            'SCRIPT_NAME':       None, 
    116116            'SERVER_NAME':       'testserver', 
    117117            'SERVER_PORT':       80, 
    118118            'SERVER_PROTOCOL':   'HTTP/1.1', 
    119         }         
     119        } 
    120120        environ.update(self.defaults) 
    121         environ.update(request)         
     121        environ.update(request) 
    122122 
    123123        # Curry a data dictionary into an instance of 
     
    126126        on_template_render = curry(store_rendered_templates, data) 
    127127        dispatcher.connect(on_template_render, signal=signals.template_rendered) 
    128          
     128 
    129129        response = self.handler(environ) 
    130          
     130 
    131131        # Add any rendered template detail to the response 
    132         # If there was only one template rendered (the most likely case),  
     132        # If there was only one template rendered (the most likely case), 
    133133        # flatten the list to a single element 
    134134        for detail in ('template', 'context'): 
     
    140140            else: 
    141141                setattr(response, detail, None) 
    142          
     142 
    143143        if response.cookies: 
    144144            self.cookie.update(response.cookies) 
    145145 
    146146        return response 
    147          
     147 
    148148    def get(self, path, data={}, **extra): 
    149149        "Request a response from the server using GET." 
     
    156156        } 
    157157        r.update(extra) 
    158          
     158 
    159159        return self.request(**r) 
    160      
     160 
    161161    def post(self, path, data={}, **extra): 
    162162        "Request a response from the server using POST." 
    163          
     163 
    164164        BOUNDARY = 'BoUnDaRyStRiNg' 
    165165 
     
    174174        } 
    175175        r.update(extra) 
    176          
     176 
    177177        return self.request(**r) 
    178178 
     
    181181        A specialized sequence of GET and POST to log into a view that 
    182182        is protected by a @login_required access decorator. 
    183          
     183 
    184184        path should be the URL of the page that is login protected. 
    185          
    186         Returns the response from GETting the requested URL after  
     185 
     186        Returns the response from GETting the requested URL after 
    187187        login is complete. Returns False if login process failed. 
    188188        """ 
    189         # First, GET the page that is login protected.  
     189        # First, GET the page that is login protected. 
    190190        # This page will redirect to the login page. 
    191191        response = self.get(path) 
    192192        if response.status_code != 302: 
    193193            return False 
    194              
     194 
    195195        login_path, data = response['Location'].split('?') 
    196196        next = data.split('=')[1] 
     
    200200        if response.status_code != 200: 
    201201            return False 
    202              
     202 
    203203        # Last, POST the login data. 
    204204        form_data = {