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

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

问题描述

我有使用相同的数据库,并分享一些code两个Django的网站。主父站点是为工作人员和承包商外部网,而第二个站点公开一些数据的几个我们的合作伙伴。

我已成功地建立了网站工作,但发现,如果我启动Apache和进入主站点,那么合作伙伴网站是行不通的,返回一个内部服务器错误。如果我重新启动,并进入合作伙伴网站,那么主站点是行不通的。

所以我猜他们是矛盾的对资源。

服务器日志(参见下图)表明,它是与Win32 / lib中/ pywintypes.py模块出了问题,线114在其他地方,它被建议注释掉这些行(见下文)。所以,我已经试过这和它的作品。

我真的不明白什么是在code回事,是否注释掉它只是要在以后导致了我的问题。所以,问题是:

有什么别的事情,可能会导致这?难道这忽悠'安全'办?

 #py2k和py3k差异:
#在py2k,做imp.load_module('pywintypes')之后,sys.modules中
#是不变的 - 即下,sys.modules ['pywintypes']仍然指向*此*
#的.py模块 - 但该模块的__dict__已经* *已经更新的需要
#与新的模块的内容。
#然而,py3k下,sys.modules *为*改变 - sys.modules中['pywintypes']
#将变更为新模块的对象。
#SO:*上py2k不需要更新任何全局。
#*在py3k我们更新与新模块的字典模块和快译通
#全局其复制到我们的。
old_mod = sys.modules中[的modname]
#Python可以加载模块
MOD = imp.load_dynamic(的modname,发现)
#检查我们上面描述这个sys.modules []的行为是真实的...
如果sys.version_info< (3,0):
    #系统软糖位!!!!!!!!!!!!!!!!!
    #assert sys.modules中[的modname]是old_mod
    #assert MOD为old_mod
    通过
其他:
    断言sys.modules中[的modname]未old_mod
    断言sys.modules中[的modname]是MOD
    #如上 - 重新复位到* *旧模块对象然后更新水珠。
    sys.modules中[的modname] = old_mod
    globs.update(MOD .__ dict__)

回溯

 的mod_wsgi(PID = 7164):发生异常处理WSGI脚本'E:/Programming/django_site/extranet_site/apache/django.wsgi。
回溯(最近通话最后一个):
文件C:\\\\ Python26 \\\\ \\\\ lib目录站点包\\\\ \\\\的Django核心\\\\ \\\\处理wsgi.py,241线,在__call__
    响应= self.get_response(要求)
文件C:\\\\ Python26 \\\\ \\\\ lib目录站点包\\\\ \\\\的Django核心\\\\ \\\\处理base.py,73行,在get_response
        响应= middleware_method(要求)
ILEC:\\\\ Python26 \\\\ \\\\ lib目录站点包\\\\ \\\\的Django的contrib \\\\ \\\\会话middleware.py,10号线,在process_request
        发动机= import_module(settings.SESSION_ENGINE)
文件C:\\\\ Python26 \\\\ \\\\ lib目录站点包\\\\ \\\\的Django \\\\ utils的importlib.py35行,在import_module
        __import __(姓名)
文件C:\\\\ Python26 \\\\ \\\\ lib目录站点包\\\\ \\\\的Django的contrib \\\\ \\\\会话后端\\\\ db.py,2号线,上述<&模块GT;
    从django.contrib.sessions.models导入会话
文件C:\\\\ Python26 \\\\ \\\\ lib目录站点包\\\\ \\\\的Django的contrib \\\\ \\\\会话models.py,4号线,上述<&模块GT;
    从django.db进口车型
文件C:\\\\ Python26 \\\\ \\\\ lib目录站点包\\\\ \\\\的Django DB \\\\ \\\\车型__ init__.py,12号线,上述<&模块GT;
    从django.db.models.fields.files进口的FileField,ImageField的
文件C:\\\\ Python26 \\\\ \\\\ lib目录站点包\\\\ \\\\的Django DB \\\\ \\\\车型领域\\\\ files.py,8号线,上述<&模块GT;
        从django.core.files.storage进口default_storage
文件C:\\\\ Python26 \\\\ \\\\ lib目录站点包\\\\ \\\\的Django核心\\\\ \\\\文件storage.py,7号线,上述<&模块GT;
    从django.core.files进口锁,文件
文件C:\\\\ Python26 \\\\ \\\\ lib目录站点包\\\\ \\\\的Django核心\\\\ \\\\文件locks.py25行,上述<&模块GT;
    进口pywintypes
文件C:\\\\ Python26 \\\\ \\\\ lib目录站点包\\\\ \\\\的win32 \\\\ lib目录pywintypes.py,124线,上述<&模块GT;
    __import_pywin32_system_module __(pywintypes,全局())
文件C:\\\\ Python26 \\\\ \\\\ lib目录站点包\\\\ \\\\的win32 \\\\ lib目录pywintypes.py,线114,在__import_pywin32_system_module__
    断言sys.modules中[的modname是old_mod
Asse田


解决方案

安装pywin32#212解决了这个问题。

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.

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.

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:

Is there something else going on that may be causing this? Is this fudge 'safe' to do?

# 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__)

Traceback

    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              

解决方案

Installing pywin32 #212 solved the problem.

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

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