2

我正在尝试使用 Amara 库使用 django 视图进行 Web 服务调用。

但是,无论何时我这样做import amara(通过简单地导入它!)并在导入的情况下调用 django 视图,我都会收到这样的错误:

Environment:

Request Method: GET
Request URL: http://127.0.0.1:4444/test
Django Version: 1.2.1
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',
 'azula.epgdb',
 'django_extensions']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
  80.                     response = middleware_method(request)
File "/usr/local/lib/python2.6/dist-packages/django/middleware/common.py" in process_request
  58.                     _is_valid_path("%s/" % request.path_info, urlconf)):
File "/usr/local/lib/python2.6/dist-packages/django/middleware/common.py" in _is_valid_path
  143.         urlresolvers.resolve(path, urlconf)
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py" in resolve
  301.     return get_resolver(urlconf).resolve(path)
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py" in resolve
  216.                     sub_match = pattern.resolve(new_path)
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py" in resolve
  123.             return self.callback, args, kwargs
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py" in _get_callback
  129.             self._callback = get_callable(self._callback_str)
File "/usr/local/lib/python2.6/dist-packages/django/utils/functional.py" in wrapper
  124.         result = func(*args)
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py" in get_callable
  56.                 lookup_view = getattr(import_module(mod_name), func_name)
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py" in import_module
  35.     __import__(name)
File "/home/uluc/azula/epgdb/views.py" in <module>
  4. from azula.epgdb.utils import EventSet
File "/home/uluc/azula/epgdb/utils.py" in <module>
  6. import amara
File "/usr/lib/pymodules/python2.6/amara/__init__.py" in <module>
  11. import binderytools
File "/usr/lib/pymodules/python2.6/amara/binderytools.py" in <module>
  13. from Ft.Xml import InputSource
File "/usr/lib/python2.6/dist-packages/Ft/Xml/InputSource.py" in <module>
  355. DefaultFactory = InputSourceFactory(catalog=GetDefaultCatalog())
File "/usr/lib/python2.6/dist-packages/Ft/Xml/Catalog.py" in GetDefaultCatalog
  579.                 catalog = Catalog(uri, quiet)
File "/usr/lib/python2.6/dist-packages/Ft/Xml/Catalog.py" in __init__
  95.             self._parseXmlCat(data)
File "/usr/lib/python2.6/dist-packages/Ft/Xml/Catalog.py" in _parseXmlCat
  372.         from Ft.Xml.Sax import CreateParser
File "/usr/lib/python2.6/dist-packages/Ft/Xml/Sax.py" in <module>
  242. class SaxPrinter(ContentHandler):
File "/usr/lib/python2.6/dist-packages/Ft/Xml/Sax.py" in SaxPrinter
  247.     def __init__(self, printer=XmlPrinter(sys.stdout, 'utf-8')):
File "/usr/lib/python2.6/dist-packages/Ft/Xml/Lib/XmlPrinter.py" in __init__
  39.         self.stream = sw = cStreamWriter.StreamWriter(stream, encoding)

Exception Type: TypeError at /test
Exception Value: argument must have 'write' attribute

如何解决?我在 Debian Lenny 和 Ubuntu 10.04 下尝试过这个,但通过 Django SVN 版本和 Amara 1

我怀疑一些字符编码问题。

4

1 回答 1

2

将“WSGIRestrictStdout Off”放到我的 apache 中解决了这里所说的问题。

于 2010-07-22T08:34:10.287 回答