在Apache上使用mod_auth_sspi和mod_wsgi运行两个Django应用程序 [英] Running two Django Apps on Apache with mod_auth_sspi and mod_wsgi

查看:349
本文介绍了在Apache上使用mod_auth_sspi和mod_wsgi运行两个Django应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



Apache / 2.2.21(Win32)mod_wsgi / 3.3 Python / 2.7.2 mod_auth_sspi / 1.0.4



问题是,我不能添加第二个使用相同模块的Django应用程序,因为我想使用单点登录也是如果我添加第二个应用程序,Apache只会验证第一个请求的应用程序。第二个会抛出错误500 - 内部服务器错误。如果我重新启动Apache,并尝试首先请求第二个应用程序,它可以工作。但是当我请求第一个应用程序时,它会抛出错误500(与第一个错误相同)。



error.log:

  mod_wsgi(pid = 4724):异常发生处理WSGI脚本'C:/www/app2/app2.wsgi'。 
[Tue Feb 28 09:57:48 2012] [错误] [客户端192.168.1.121]追溯(最近的最后一次呼叫):
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]文件C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\\django\\\ \\ core \\\handlers\\wsgi.py,第272行,__call__
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] response = self.get_response (请求)
[Tue Feb 28 09:57:48 2012] [错误] [客户端192.168.1.121]文件C:\\\Python\\lib\\site- packages\ \django-1.3.1-py2.7.egg\\django\\core\\handlers\\base,第169行,get_response
[二月28日09:57:48 2012] [error] [client 192.168.1.121] response = self.handle_uncaught_exception(request,resolver,sys.exc_info())
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]文件C:\\Python\\lib\\site- package_\\\django-1.3.1-py2.7.egg\\django\\core\\handlers\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] return debug.technical_500_response(request,* exc_info)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168 .1.121]文件C:\\Python\\lib\\\\site-packages\\django-1.3.1-py2.7.egg\\django\\views\\ \\\debug.py,第59行,在technical_500_response
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] html = reporter.get_traceback_html()
[Tue 2月28日09:57:48 2012] [错误] [客户端192.168.1.121]文件C:\\\Python\\lib\\site-packages\\django-1.3.1-py2 .7.egg\\django\\views\\debug.py,第151行,在get_traceback_html
[Tue Feb 28 09:57:48 2012] [error] [client 192.168。 1.121] return t.render(c)
[Tue Feb 28 09:57:48 2012] [错误] [客户端192.168.1.121]文件C:\\\Python\\lib\\site-packages\\django-1.3.1-py2.7 .egg\\django\\template\\base.py,第123行,呈现
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] return self._render(context)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]文件C:\\Python\\lib\\site -packages\\django-1.3.1-py2.7.egg\\\django\\template\\base.py,第117行,_render
[Tue Feb 28 09 :57:48 2012] [error] [client 192.168.1.121] return self.nodelist.render(context)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] File C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\template\\base。 py,line 744,in render
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] bits.append(se lf.render_node(node,context))
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]文件C:\\Python\\lib\\\ \\ site-packages\\django-1.3.1-py2.7.egg\\django\\template\\\\debug.py,第73行,render_node
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] result = node.render(context)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] File C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\template\\debug .py,第90行,在render
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] output = self.filter_expression.resolve(context)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]文件C:\\\Python\\lib\\site-packages\\django-1.3.1-py2。 7.egg\\\django\\template\\base.py,第536行,解析
[2月2日8 09:57:48 2012] [error] [client 192.168.1.121] new_obj = func(obj,* arg_vals)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]文件C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\template\\ defaultfilters.py,第695行,日期
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] return format(value,arg)
[Tue Feb 28 09 :57:48 2012] [error] [client 192.168.1.121]文件C:\\\Python\\lib\\site-packages\\django-1.3.1-py2.7。第285行,格式为
[Tue Feb 28 09:57:48 2012] [错误] [客户端192.168.1.121]返回df.format(format_string)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]文件C:\\Python\\lib\\\\site- packages\\django-1.3.1-py2.7.egg\\django\\utils\\dateformat.p y,第30行,格式为
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] pieces.append(force_unicode(getattr(self,piece)()))
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]文件C:\\Python\\lib\\\\site-packages\\django-1.3 .1-py2.7.egg\\\django\\utils\\dateformat.py,第191行,r
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] return self.format('D,j MYH:i:s O')
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]文件C :\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\dateformat.py ,第30行,格式为
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] pieces.append(force_unicode(getattr(self,piece)()))
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]文件C:\\Python\\lib\\site- packages\ \django-1.3.1-py2.7.egg\\django\\utils\\\\cncoding.py,第71行,在force_unicode
[Tue Feb 28 09:57:48 2012] [错误] [客户端192.168.1.121] s = unicode
[Tue Feb 28 09:57:48 2012] [错误] [客户端192.168.1.121]文件C:\\Python \\lib\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ __unicode_cast
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] return self .__ func(* self .__ args,** self .__ kw)
[Tue Feb 28 09 :57:48 2012] [error] [client 192.168.1.121]文件C:\\\Python\\lib\\site-packages\\django-1.3.1-py2.7。蛋\\ d o o \\ \\ ut ut it it it it client client client client client client client client client client client client client client client client client client client client client client client client client client client client client client client client client 192.168.1.121] return _trans.ugettext(message)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]文件C:\\Python\\\\\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\\\翻译\转发,第286行,ugettext
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] return do_translate(message,'ugettext')
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]文件C:\\Python\\lib\\\\site-packages\\django-1.3 .1-py2.7.egg\\django\\ut;\\\\\\trans_real.py,第276行,do_translate
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] _default = translation(settings.LANGUAGE_CODE)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]文件C:\\\ \\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\translation\\trans_real。 py,第185行,翻译
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] default_translation = _fetch(settings.LANGUAGE_CODE)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] File C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\translation \\trans_real.py,第162行,在_fetch
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] app = import_module(appname)
[Tue 2月28日09:57:48 2012] [错误] [客户端192.168.1.121]文件C:\\\Python\\lib\\site-packages\\django-1.3.1-py2第35行import_module
[Tue Feb 28 09:57:48 2012] [错误] [客户端192.168。 1.121] __import __(name)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]文件C:\\Python\\lib\\site- packages\\django-1.3.1-py2.7.egg\\django\ \contrib\\admin\\__init __。py,第3行,在< module>
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
[Tue Feb 28 09:57:48 2012] [错误] [客户端192.168.1.121]文件C:\\\Python\\lib\\site-packages\\django- 1.3.1-py2.7.egg\\django\\ \\\contrib\\admin\\helpers.py,第3行在< module>
[tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] from django.contrib.admin.util import(flatten_fieldsets,lookup_field,
[Tue Feb 28 09:57: 48 2012] [error] [client 192.168.1.121]文件C:\\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\ \django\\control\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 192.168.1.121]从django.db导入模型
[Tue Feb 28 09:57:48 2012] [错误] [客户端192.168.1.121]文件C:\\\Python\\lib\ \site-packages\\django-1.3.1-py2.7.egg\\\django\\db\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\模块>
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] from django.db.models.fields.files import FileField,ImageField
[Tue Feb 28 09: 57:48 2012] [error] [client 192.168.1.121]文件C:\\Python\ \\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\db\\models\\fields\\files。 py,第9行,< module>
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] from django.core.files.storage import default_storage
[ Tue Feb 28 09:57:48 2012] [错误] [客户端192.168.1.121]文件C:\\\Python\\lib\\\\site-packages\\django-1.3.1- py2.7.egg\\django\\core\\files\\storage.py,第9行在< module>
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] from django.core.files import locks,File
[Tue Feb 28 09:57:48 2012] [错误] [客户端192.168.1.121]文件C:\\\Python\\lib\\site-packages\\django- 1.3.1-py2.7.egg\\django\\ \\\core\\files\\lockspy,第25行,< module>
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] import pywintypes
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]文件C:\\\Python\\lib\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] __import_pywin32_system_module __(pywintypes,globals())
[Tue Feb 28 09:57:48 2012] [错误] [客户端192.168.1.121]文件C:\\\Python\\lib\\\\site-packages\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ,__import_pywin32_system_module__
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] assert sys.modules [modname]是old_mod
[Tue Feb 28 09:57:48 2012 ] [error] [client 192.168.1.121] TemplateSyntaxError:在渲染时捕获AssertionError:

conf / wsgi。 conf:

  WSGIScriptAlias / app1C:/www/app1/app1.wsgi

< ;目录C:/ www / app1>
允许从
#AllowOverride AuthConfig
< / Directory>

<位置/ app1>
AuthNameserver
AuthType SSPI
SSPIAuth On
SSPIAuthoritative On
SSPIUsernameCase lower
#SSPIDomain DOMAIN
require valid-user
< /位置>

WSGIScriptAlias / app2C:/www/app2/app2.wsgi

<目录C:/ www / app2>
允许从
#AllowOverride AuthConfig
< / Directory>

< Location / app2>
AuthNameserver
AuthType SSPI
SSPIAuth On
SSPIAuthoritative On
SSPIUsernameCase lower
#SSPIDomain DOMAIN
require valid-user
< /位置>

别名/静态/c:/ static-root /
<目录c:/ static-root />
订单允许,拒绝
允许从所有
< / Directory>

c:/www/app2/app2.wsgi(app1.wsgi是相似的):

  import os 
import sys

path ='c:/ www /'
如果路径不在sys.path中:
sys.path.append(路径)
如果apps_path不在sys.path中:
sys.path.append(apps_path)

os.environ ['DJANGO_SETTINGS_MODULE'] ='app2.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

你知道该怎么做使用单一登录功能可以同时使用这两个应用程序吗?我不知道,如果是Django的错,mod_wsgi的错误或者mod_auth_sspi的错误。你可以帮助我吗?



编辑:
看起来,它不依赖于mod_auth_sspi模块。

解决方案

似乎是一个pywin32错误,在这里回答:
Apache / Windows / mod_wsgi上的多个django站点 - win32的问题



有一些python版本检查,它做了一些模块和加注:

  AssertionError:assert sys.modules [modname ]是old_mod 

报告错误但未解决:



https:// sourceforge。 net / tracker /?func = detail& aid = 2905909& group_id = 78018& atid = 551954



https://sourceforge.net/tracker/?func=detail&aid=3496224&group_id=78018&atid=551954



临时解决方案在 win32 / lib / pywintypes.py 中注释两行:

 如果sys.version_info< (3,0):
#next两行有问题!!!!!
#assert sys.modules [modname] is old_mod
#assert mod is old_mod
pass
else:
assert sys.modules [modname]不是old_mod
assert sys.modules [modname]是mod
#如上所述 - 重新重新设置为* old *模块对象,然后更新globs。
sys.modules [modname] = old_mod
globs.update(mod .__ dict__)


I've been running one Django app with Single Sign-On enabled by mod_auth_sspi using mod_wsgi.

Apache/2.2.21 (Win32) mod_wsgi/3.3 Python/2.7.2 mod_auth_sspi/1.0.4

Problem is, that I can't add second Django app, which uses the same modules, because I want to use Single Sign-On too. If I add second app, Apache authenticates only the first requested app. The second one throws Error 500 - Internal server error. If I restart Apache and try to request second app at first, it works. But then when I request the first app, it throws error 500 (same error as the first).

error.log:

mod_wsgi (pid=4724): Exception occurred processing WSGI script 'C:/www/app2/app2.wsgi'.
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] Traceback (most recent call last):
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\core\\handlers\\wsgi.py", line 272, in __call__
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     response = self.get_response(request)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\core\\handlers\\base.py", line 169, in get_response
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\core\\handlers\\base.py", line 203, in handle_uncaught_exception
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     return debug.technical_500_response(request, *exc_info)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\views\\debug.py", line 59, in technical_500_response
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     html = reporter.get_traceback_html()
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\views\\debug.py", line 151, in get_traceback_html
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     return t.render(c)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\template\\base.py", line 123, in render
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     return self._render(context)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\template\\base.py", line 117, in _render
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     return self.nodelist.render(context)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\template\\base.py", line 744, in render
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     bits.append(self.render_node(node, context))
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\template\\debug.py", line 73, in render_node
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     result = node.render(context)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\template\\debug.py", line 90, in render
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     output = self.filter_expression.resolve(context)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\template\\base.py", line 536, in resolve
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     new_obj = func(obj, *arg_vals)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\template\\defaultfilters.py", line 695, in date
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     return format(value, arg)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\dateformat.py", line 285, in format
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     return df.format(format_string)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\dateformat.py", line 30, in format
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     pieces.append(force_unicode(getattr(self, piece)()))
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\dateformat.py", line 191, in r
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     return self.format('D, j M Y H:i:s O')
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\dateformat.py", line 30, in format
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     pieces.append(force_unicode(getattr(self, piece)()))
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\encoding.py", line 71, in force_unicode
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     s = unicode(s)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\functional.py", line 206, in __unicode_cast
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     return self.__func(*self.__args, **self.__kw)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\translation\\__init__.py", line 81, in ugettext
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     return _trans.ugettext(message)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\translation\\trans_real.py", line 286, in ugettext
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     return do_translate(message, 'ugettext')
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\translation\\trans_real.py", line 276, in do_translate
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     _default = translation(settings.LANGUAGE_CODE)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\translation\\trans_real.py", line 185, in translation
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     default_translation = _fetch(settings.LANGUAGE_CODE)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\translation\\trans_real.py", line 162, in _fetch
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     app = import_module(appname)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\utils\\importlib.py", line 35, in import_module
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     __import__(name)
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\contrib\\admin\\__init__.py", line 3, in <module>
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\contrib\\admin\\helpers.py", line 3, in <module>
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     from django.contrib.admin.util import (flatten_fieldsets, lookup_field,
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\contrib\\admin\\util.py", line 1, in <module>
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     from django.db import models
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\db\\models\\__init__.py", line 12, in <module>
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     from django.db.models.fields.files import FileField, ImageField
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\db\\models\\fields\\files.py", line 9, in <module>
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     from django.core.files.storage import default_storage
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\core\\files\\storage.py", line 9, in <module>
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     from django.core.files import locks, File
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\django-1.3.1-py2.7.egg\\django\\core\\files\\locks.py", line 25, in <module>
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     import pywintypes
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\win32\\lib\\pywintypes.py", line 124, in <module>
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     __import_pywin32_system_module__("pywintypes", globals())
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]   File "C:\\Python\\lib\\site-packages\\win32\\lib\\pywintypes.py", line 114, in __import_pywin32_system_module__
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121]     assert sys.modules[modname] is old_mod
[Tue Feb 28 09:57:48 2012] [error] [client 192.168.1.121] TemplateSyntaxError: Caught AssertionError while rendering:

conf/wsgi.conf:

WSGIScriptAlias /app1 "C:/www/app1/app1.wsgi"

<Directory "C:/www/app1">
  Allow from all
#  AllowOverride AuthConfig
</Directory>

<Location /app1>
  AuthName "server"
  AuthType SSPI
  SSPIAuth On
  SSPIAuthoritative On
  SSPIUsernameCase lower
#  SSPIDomain DOMAIN
  require valid-user
</Location>

WSGIScriptAlias /app2 "C:/www/app2/app2.wsgi"

<Directory "C:/www/app2">
  Allow from all
#  AllowOverride AuthConfig
</Directory>

<Location /app2>
  AuthName "server"
  AuthType SSPI
  SSPIAuth On
  SSPIAuthoritative On
  SSPIUsernameCase lower
#  SSPIDomain DOMAIN
  require valid-user
</Location>

Alias /static/ "c:/static-root/"
<Directory "c:/static-root/">
  Order Allow,Deny
  Allow from all
</Directory>

c:/www/app2/app2.wsgi (app1.wsgi is similar):

import os
import sys

path = 'c:/www/'
apps_path = 'c:/www/app2/'
if path not in sys.path:
  sys.path.append(path)
if apps_path not in sys.path:
  sys.path.append(apps_path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'app2.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Do you know what to do to get both apps work with Single Sign-On? I don't know, if it is Django's fault, mod_wsgi fault or mod_auth_sspi fault. Can you help me, please?

EDIT: It looks, that it doesn't depend on mod_auth_sspi module.

解决方案

It seem to be a pywin32 error, answered here: Multiple django sites on Apache / Windows / mod_wsgi - problem with win32

There is some python version check, which does something with modules and raises:

AssertionError: assert sys.modules[modname] is old_mod

Bug is reported, but not resolved:

https://sourceforge.net/tracker/?func=detail&aid=2905909&group_id=78018&atid=551954

https://sourceforge.net/tracker/?func=detail&aid=3496224&group_id=78018&atid=551954

Temporary solution is comment out two lines in win32/lib/pywintypes.py:

if sys.version_info < (3,0):
    #next two lines are problematic!!!!!
    #assert sys.modules[modname] is old_mod 
    #assert mod is old_mod
    pass
else:
    assert sys.modules[modname] is not old_mod
    assert sys.modules[modname] is mod
    # as above - re-reset to the *old* module object then update globs.
    sys.modules[modname] = old_mod
    globs.update(mod.__dict__)

这篇关于在Apache上使用mod_auth_sspi和mod_wsgi运行两个Django应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆