首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >django鸡蛋模板加载器错误

django鸡蛋模板加载器错误
EN

Stack Overflow用户
提问于 2011-03-03 05:29:11
回答 1查看 1.6K关注 0票数 1

我正在尝试根据他们的文档安装dajax/dajaxice,他们的文档建议我在我的settings.py中取消对鸡蛋模板加载器(下面的元组中的第三个)的注释。

代码语言:javascript
复制
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
    'django.template.loaders.eggs.Loader',
)

但是,这会使我的站点停止在我的开发机器上使用"IOError at /: sys.stdin access restricted by mod_wsgi“。当我查看错误出现的地方时,它出现在与此项目无关的python蛋中(我没有使用可能会有所帮助的virtualenv )(甚至是django),当我再次注释掉这一行时,它就消失了。(当鸡蛋加载器被注释掉时,它所寻找的模板很容易在TEMPLATES_DIR中找到)。

回溯是:

代码语言:javascript
复制
Environment:

Request Method: GET
Request URL: http://[redacted URL]/
Django Version: 1.2.5
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'debug_toolbar',
 'registration',
 'dajaxice',
 'dajax',
 'south',
 '[redacted app name].study_registration',
 'profiles']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'audit_log.middleware.UserLoggingMiddleware')



Traceback:
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.5-py2.6.egg/django/core/handlers/base.py" in get_response
  100.                     response = callback(request, *callback_args, **callback_kwargs)
File "/home/[redacted user name]/django/[redacted app name]/study_registration/views.py" in menu
  671.     template = loader.get_template('study_registration/menu.html')
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.5-py2.6.egg/django/template/loader.py" in get_template
  157.     template, origin = find_template(template_name)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.5-py2.6.egg/django/template/loader.py" in find_template
  128.             loader = find_template_loader(loader_name)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.5-py2.6.egg/django/template/loader.py" in find_template_loader
  95.             mod = import_module(module)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.5-py2.6.egg/django/utils/importlib.py" in import_module
  35.     __import__(name)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.5-py2.6.egg/django/template/loaders/eggs.py" in <module>
  4.     from pkg_resources import resource_string
File "/usr/lib/python2.6/dist-packages/pkg_resources.py" in <module>
  2675. add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.6/dist-packages/pkg_resources.py" in subscribe
  662.             callback(dist)
File "/usr/lib/python2.6/dist-packages/pkg_resources.py" in <lambda>
  2675. add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.6/dist-packages/pkg_resources.py" in activate
  2180.             map(declare_namespace, self._get_metadata('namespace_packages.txt'))
File "/usr/lib/python2.6/dist-packages/pkg_resources.py" in declare_namespace
  1784.             _handle_ns(packageName, path_item)
File "/usr/lib/python2.6/dist-packages/pkg_resources.py" in _handle_ns
  1755.         loader.load_module(packageName); module.__path__ = path
File "/usr/lib/python2.6/pkgutil.py" in load_module
  238.             mod = imp.load_module(fullname, self.file, self.filename, self.etc)
File "/usr/local/lib/python2.6/dist-packages/glumpy-0.1.0-py2.6.egg/glumpy/__init__.py" in <module>
  15. from window import Window, active_window
File "/usr/local/lib/python2.6/dist-packages/glumpy-0.1.0-py2.6.egg/glumpy/window.py" in <module>
  16. import IPython
File "/usr/lib/pymodules/python2.6/IPython/__init__.py" in <module>
  58.     __import__(name,glob,loc,[])
File "/usr/lib/pymodules/python2.6/IPython/ipstruct.py" in <module>
  17. from IPython.genutils import list2dict2
File "/usr/lib/pymodules/python2.6/IPython/genutils.py" in <module>
  49. from IPython.Itpl import Itpl,itpl,printpl
File "/usr/lib/pymodules/python2.6/IPython/Itpl.py" in <module>
  99.     itpl_encoding = sys.stdin.encoding or 'ascii'

Exception Type: IOError at /
Exception Value: sys.stdin access restricted by mod_wsgi

我的问题是,无论如何都有启用鸡蛋模板加载器,但只检查通过INSTALLED_APPS的鸡蛋?我不想切换到virtualenv。这些蛋也出现在我的python路径中:

代码语言:javascript
复制
['/usr/local/lib/python2.6/dist-packages/Unidecode-0.04.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/pygooglechart-0.3.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Graphy-1.0.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/virtualenv-1.5.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/glumpy-0.1.0-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_debug_toolbar-0.8.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Pympler-0.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_profiles-0.2-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_form_utils-0.1.8-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_audit_log-0.2.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_autocomplete-0.3.dev-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Babel-0.9.5-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Genshi-0.6-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Trac-0.12.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/collective.ordereddict-0.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/ordereddict-1.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_ajax_selects-1.1.4-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/openpyxl-1.2.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_dynamic_choices-0.1.3-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Django-1.2.5-py2.6.egg', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode', '/usr/local/lib/python2.6/dist-packages', '/home/[redacted user name]/django', '/usr/lib/python2.6/site-packages/django/', '/home/[redacted user name]/django/[redacted app name]/', '/usr/lib/pymodules/python2.6/IPython/Extensions']
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-03-03 06:12:00

升级到mod_wsgi 3.3。不要使用mod_wsgi 2.X。请阅读:

http://blog.dscpl.com.au/2009/04/wsgi-and-printing-to-standard-output.html

简而言之,Python代码正在尝试使用sys.stdin,这在技术上意味着代码不能在所有WSGI实现上移植使用。较早的mod_wsgi版本试图强调这一点,以迫使人们编写可移植的代码。在mod_wsgi 3.3中不再进行这样的检查,它允许人们编写不可移植的代码。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5173726

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档