Traceback (most recent call last):
File "c:\opt\Python25\Lib\site-packages\django\core\handlers\base.py" in get_response
77. response = callback(request, *callback_args, **callback_kwargs)
File "c:\opt\Python25\lib\site-packages\django\contrib\databrowse_jm\sites.py" in root
120. return self.index(request)
File "c:\opt\Python25\Lib\site-packages\django\contrib\auth\decorators.py" in _checklogin
16. if test_func(request.user):
AttributeError at /databrowse/
'DatabrowseSite' object has no attribute 'user'This is because the decorator is for a view function, which has
"request" as the first argument, whereas DatabrowseSite.root() takes a
DatabrowseSite instance as its first argument.
You could possibly write a custom version of the decorator that looked
at the second argument.
Or you could subclass DatabrowseSite -- in your own code somewhere; no
need to even modify the source -- and override the root() method to do
an auth-check first and then call DatabrowseSite.root(). Then you
replace databrowse.sites with an instance of your subclass.
Python is really cool like this: since everything's a first-class
object, you can happily import databrowse.main and then just set
databrowse.main.site to whatever you want.
That is all completely untested of course (in the sense that I haven't
actually written the code), but it should be possibly with a bit of
attention to detail and error messages.
Regards,
Malcolm
Or you could subclass DatabrowseSite -- in your own code somewhere; no
need to even modify the source -- and override the root() method to do
an auth-check first and then call DatabrowseSite.root(). Then you
replace databrowse.sites with an instance of your subclass.
Looks very sensible and clean. Nice solution. :-)
Cheers,
Malcolm
>