Search code examples
pythonwebturbogears2

problematic dot in url


I got a url parameter which contains 3 dots named token. suppose it is 'boo.foo.joo'. my controller's method which is supposed to handle request only takes the first two parts ('boo.foo'). however I can see the remaining part in my request.response_ext. what is response_ext? is this behavior coming from my web framework or is it a universal convention?

from tg import request

def recover_password(self, token):
    print(token) # outputs > 'boo.foo'
    print(request.response_ext) # outputs > '.joo'

Solution

  • It's a feature of your framework :

    base_config.disable_request_extensions – by default this is false. This means that TG will take the request, and strip anything off the end of the last element in the URL that follows ”.”. It will then take this information, and assign an appropriate mime-type and store the data in the tg.request.response_type and tg.request.response_ext variables. By enabling this flag, you disable this behavior, rendering TG unable to determine the mime-type that the user is requesting automatically.

    In your case, you may want to it to true to disable this behavior.