Apache/Windows/mod_wsgi 上的多个 django 站点 - win32 的问题 [英] Multiple django sites on Apache / Windows / mod_wsgi - problem with win32

查看:23
本文介绍了Apache/Windows/mod_wsgi 上的多个 django 站点 - win32 的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个 django 站点,它们使用相同的数据库并共享一些代码.主要的父站点是员工和承包商的外联网,而第二个站点向我们的一些合作伙伴公开一些数据.

I have two django sites that use the same database and share some of the code. The main parent site is an extranet for staff and contractors, while the second site exposes some of the data to a few of our partners.

我已设法设置站点以使其正常工作,但发现如果我启动 Apache 并进入主站点,则合作站点将无法工作,并返回内部服务器错误".如果我重新启动并进入合作伙伴站点,则主站点将无法运行.

I have managed to set up sites to work but found that if I launched Apache and went into the main site, then the partner site wouldn't work, returning an "Internal Server Error". If I restarted and went into the partner site, then the main site wouldn't work.

所以我猜他们在资源上存在冲突.

So I guess they are conflicting over resources.

服务器日志(见底部)显示 win32/lib/pywintypes.py 模块有问题,第 114 行.在其他地方,建议将这些行注释掉(见下文).所以我试过这个并且它有效.

The server log (see bottom) shows that it is a problem with the win32/lib/pywintypes.py module, line 114. Elsewhere, it's been suggested to comment out these lines (see below). So I've tried this and it works.

我真的不明白代码中发生了什么,以及注释掉它是否只会在以后给我带来问题.所以问题是:

I don't really understand what is going on in the code and whether commenting it out is just going to cause me problems later. So the question is:

是否还有其他原因可能导致这种情况?这种软糖安全"吗?

# 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:\\Python26\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 241, in __call__
    response = self.get_response(request)
File "C:\\Python26\\lib\\site-packages\\django\\core\\handlers\\base.py", line 73, in get_response              
        response = middleware_method(request)               
ile "C:\\Python26\\lib\\site-packages\\django\\contrib\\sessions\\middleware.py", line 10, in process_request               
        engine = import_module(settings.SESSION_ENGINE)             
File "C:\\Python26\\lib\\site-packages\\django\\utils\\importlib.py", line 35, in import_module             
        __import__(name)                
File "C:\\Python26\\lib\\site-packages\\django\\contrib\\sessions\\backends\\db.py", line 2, in <module>                
    from django.contrib.sessions.models import Session              
File "C:\\Python26\\lib\\site-packages\\django\\contrib\\sessions\\models.py", line 4, in <module>              
    from django.db import models                
File "C:\\Python26\\lib\\site-packages\\django\\db\\models\\__init__.py", line 12, in <module>              
    from django.db.models.fields.files import FileField, ImageField             
File "C:\\Python26\\lib\\site-packages\\django\\db\\models\\fields\\files.py", line 8, in <module>              
        from django.core.files.storage import default_storage               
File "C:\\Python26\\lib\\site-packages\\django\\core\\files\\storage.py", line 7, in <module>               
    from django.core.files import locks, File               
File "C:\\Python26\\lib\\site-packages\\django\\core\\files\\locks.py", line 25, in <module>                
    import pywintypes               
File "C:\\Python26\\lib\\site-packages\\win32\\lib\\pywintypes.py", line 124, in <module>               
    __import_pywin32_system_module__("pywintypes", globals())               
File "C:\\Python26\\lib\\site-packages\\win32\\lib\\pywintypes.py", line 114, in __import_pywin32_system_module__               
    assert sys.modules[modname   is old_mod         
AssertionError              

推荐答案

安装 pywin32 #212 解决了问题.

Installing pywin32 #212 solved the problem.

这篇关于Apache/Windows/mod_wsgi 上的多个 django 站点 - win32 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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