Apache / Windows / mod上的多个django站点
我有两个Django站点使用相同的数据库并共享部分代码。 主要父母网站是员工和承包商的外联网,而第二个网站向少数我们的合作伙伴公开了一些数据。
我设法设置了网站,但发现如果我启动了Apache并进入主站点,那么合作伙伴网站将无法工作,并返回“内部服务器错误”。 如果我重新启动并进入合作伙伴网站,那么主网站将无法工作。
所以我猜他们在资源方面存在冲突。
服务器日志(见底部)显示它是win32 / lib / pywintypes.py模块的第114行的问题。在其他地方,建议将这些行注释掉(见下文)。 所以我试过这个,它的工作原理。
我不太了解代码中发生了什么,评论它是否会在稍后导致我的问题。 所以问题是:
是否还有其他事情可能导致这种情况? 这个巧克力'安全'吗?
# py2k and py3k differences:
# On py2k, after doing "imp.load_module('pywintypes')", sys.modules
# is unchanged - ie, sys.modules['pywintypes'] still refers to *this*
# .py module - but the module's __dict__ has *already* need updated
# with the new module's contents.
# However, on py3k, sys.modules *is* changed - sys.modules['pywintypes']
# will be changed to the new module object.
# SO: * on py2k don't need to update any globals.
# * on py3k we update our module dict with the new module's dict and
# copy its globals to ours.
old_mod = sys.modules[modname]
# Python can load the module
mod = imp.load_dynamic(modname, found)
# Check the sys.modules[] behaviour we describe above is true...
if sys.version_info < (3,0):
#The fudge bit !!!!!!!!!!!!!!!!!
#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__)
追溯
mod_wsgi (pid=7164): Exception occurred processing WSGI script 'E:/Programming/django_site/extranet_site/apache/django.wsgi'.
Traceback (most recent call last):
File "C:Python26libsite-packagesdjangocorehandlerswsgi.py", line 241, in __call__
response = self.get_response(request)
File "C:Python26libsite-packagesdjangocorehandlersbase.py", line 73, in get_response
response = middleware_method(request)
ile "C:Python26libsite-packagesdjangocontribsessionsmiddleware.py", line 10, in process_request
engine = import_module(settings.SESSION_ENGINE)
File "C:Python26libsite-packagesdjangoutilsimportlib.py", line 35, in import_module
__import__(name)
File "C:Python26libsite-packagesdjangocontribsessionsbackendsdb.py", line 2, in <module>
from django.contrib.sessions.models import Session
File "C:Python26libsite-packagesdjangocontribsessionsmodels.py", line 4, in <module>
from django.db import models
File "C:Python26libsite-packagesdjangodbmodels__init__.py", line 12, in <module>
from django.db.models.fields.files import FileField, ImageField
File "C:Python26libsite-packagesdjangodbmodelsfieldsfiles.py", line 8, in <module>
from django.core.files.storage import default_storage
File "C:Python26libsite-packagesdjangocorefilesstorage.py", line 7, in <module>
from django.core.files import locks, File
File "C:Python26libsite-packagesdjangocorefileslocks.py", line 25, in <module>
import pywintypes
File "C:Python26libsite-packageswin32libpywintypes.py", line 124, in <module>
__import_pywin32_system_module__("pywintypes", globals())
File "C:Python26libsite-packageswin32libpywintypes.py", line 114, in __import_pywin32_system_module__
assert sys.modules[modname is old_mod
AssertionError
安装pywin32#212解决了这个问题。
在删除pywin32并使用WSGIScriptAlias“/ aliasname”“c:/wamp/www/project/django.wsgi”之后,它对我有效。在httpd.config中也使用第一个参数的引号。
我在版本217上遇到了这个问题,但我需要pywin32。 从这里实施修复https://stackoverflow.com/a/10928148/80516似乎工作。
错误报告,但没有解决:
https://sourceforge.net/tracker/?func=detail&aid=2905909&group_id=78018&atid=551954
临时解决方案在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__)
链接地址: http://www.djcxy.com/p/6911.html