buxeasywork / django-rosetta

Automatically exported from code.google.com/p/django-rosetta
MIT License
0 stars 0 forks source link

TypeError in resolving settings.LOGIN_URL #82

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If you set LOGIN_URL = lazy(reverse, unicode)('login'), rosetta will fling a 
TypeError:

=======================>
File "~\src\rosetta\rosetta\views.py", line 18, in <module>
    resolve(settings.LOGIN_URL)
  File "~\src\django\django\core\urlresolvers.py", line 336, in resolve
    return get_resolver(urlconf).resolve(path)
  File "~\src\django\django\core\urlresolvers.py", line 246, in resolve
    match = self.regex.search(path)
TypeError: expected string or buffer
<=======================

The offending code block is in views.py:

=======================>
try:
    resolve(settings.LOGIN_URL)
except Resolver404:
    try:
        resolve('/admin/')
    except Resolver404:
        raise Exception('Rosetta cannot log you in!\nYou must define a LOGIN_URL in your settings if you don\'t run the Django admin site at a standard URL.')
    else:
        LOGIN_URL = '/admin/'
else:
    LOGIN_URL = settings.LOGIN_URL
<=======================

The LOGIN_URL is used for calling the user_passes_test decorator. This is how 
the decorator reverses the login url:

=======================>
if not login_url:
        from django.conf import settings
        login_url = settings.LOGIN_URL
<=======================

I think the LOGIN_URL should either not be resolved (rely on what's already in 
settings.LOGIN_URL, as Django does), or do another check to see if the 
LOGIN_URL is a Promise object and run it through force_unicode.

Original issue reported on code.google.com by filip.du...@gmail.com on 20 Aug 2010 at 4:15

GoogleCodeExporter commented 9 years ago
Fixed in r102. 

LOGIN_URL must be resolved as Django provides a rather unorthodox default 
value, IMO.

Original comment by mbonetti on 20 Aug 2010 at 10:10

GoogleCodeExporter commented 9 years ago
Thanks for the quick response! Much appreciated!

Original comment by filip.du...@gmail.com on 20 Aug 2010 at 2:43