我的生产服务器出现如下错误:
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 89, in get_response
response = middleware_method(request)
File "myproject/middleware.py", line 31, in process_request
if not any(m.match(path) for m in EXEMPT_URLS):
NameError: global name 'any' is not defined
服务器正在运行Python 2.6,在开发过程中没有出现此错误。有问题的代码位于middleware.py
文件中:
...
if not request.user.is_authenticated():
path = request.path_info.lstrip('/')
if not any(m.match(path) for m in EXEMPT_URLS):
return HttpResponseRedirect(settings.LOGIN_URL)
我需要将这个"any"函数改写以解决问题吗?
any
。 - Michael Mior