私は自分たちの問題について検索しましたが、解決策を見つけることができませんでした。
仮想環境にmysqlconnectorをインストールしました。また、接続文字列を、sqlliteを使用して接続するピラミッドのsqlalchemyスキャフォールドから、mysqlconnectorを使用する接続文字列に変更しました。
sqlalchemy.url = mysql+mysqlconnector://admin:admin@127.0.0.1:3306/tetten
このコードを使用してデータベースを初期化します。
class Page(Base):
""" The SQLAlchemy declarative model class for a Page object. """
__tablename__ = 'pages'
id = Column(Integer, primary_key=True)
name = Column(String(40, convert_unicode=True), unique=True)
data = Column(String(40, convert_unicode=True))
def __init__(self, name, data):
self.name = name
self.data = data
class RootFactory(object):
__acl__ = [ (Allow, Everyone, 'view'),
(Allow, 'group:editors', 'edit') ]
def __init__(self, request):
pass
テーブル'pages'はデータベースに作成され、適切なデータで埋められます。ブラウザにアクセスすると、次のエラーが発生します。
**builtins.TypeError**
TypeError: embedded NUL character
この出力で:
Traceback (most recent call last):
File "c:\env\pyramid_debugtoolbar-1.0.4-py3.3.egg\pyramid_debugtoolbar\panels\performance.py", line 69, in noresource_timer_handler
result = handler(request)
File "C:\env\lib\site-packages\pyramid-1.4-py3.3.egg\pyramid\tweens.py", line 21, in excview_tween
response = handler(request)
File "C:\env\lib\site-packages\pyramid_tm-0.7-py3.3.egg\pyramid_tm\__init__.py", line 82, in tm_tween
reraise(*exc_info)
File "C:\env\lib\site-packages\pyramid_tm-0.7-py3.3.egg\pyramid_tm\compat.py", line 13, in reraise
raise value
File "C:\env\lib\site-packages\pyramid_tm-0.7-py3.3.egg\pyramid_tm\__init__.py", line 63, in tm_tween
response = handler(request)
File "C:\env\lib\site-packages\pyramid-1.4-py3.3.egg\pyramid\router.py", line 161, in handle_request
response = view_callable(context, request)
File "C:\env\lib\site-packages\pyramid-1.4-py3.3.egg\pyramid\config\views.py", line 367, in rendered_view
context)
File "C:\env\lib\site-packages\pyramid-1.4-py3.3.egg\pyramid\renderers.py", line 531, in render_view
return self.render_to_response(response, system, request=request)
File "C:\env\lib\site-packages\pyramid-1.4-py3.3.egg\pyramid\renderers.py", line 561, in render_to_response
result = self.render(value, system_values, request=request)
File "C:\env\lib\site-packages\pyramid-1.4-py3.3.egg\pyramid\renderers.py", line 557, in render
result = renderer(value, system_values)
File "C:\env\lib\site-packages\pyramid-1.4-py3.3.egg\pyramid\chameleon_zpt.py", line 42, in __call__
result = self.template(**system)
File "C:\env\lib\site-packages\chameleon-2.11-py3.3.egg\chameleon\template.py", line 125, in __call__
return self.render(**kwargs)
File "C:\env\lib\site-packages\chameleon-2.11-py3.3.egg\chameleon\zpt\template.py", line 257, in render
return super(PageTemplate, self).render(**vars)
File "C:\env\lib\site-packages\chameleon-2.11-py3.3.egg\chameleon\template.py", line 169, in render
self.cook_check()
File "C:\env\lib\site-packages\chameleon-2.11-py3.3.egg\chameleon\template.py", line 293, in cook_check
self.cook(body)
File "C:\env\lib\site-packages\chameleon-2.11-py3.3.egg\chameleon\template.py", line 147, in cook
program = self._cook(body, digest, names)
File "C:\env\lib\site-packages\chameleon-2.11-py3.3.egg\chameleon\template.py", line 218, in _cook
source = self._make(body, builtins)
File "C:\env\lib\site-packages\chameleon-2.11-py3.3.egg\chameleon\template.py", line 249, in _make
program = self.parse(body)
File "C:\env\lib\site-packages\chameleon-2.11-py3.3.egg\chameleon\zpt\template.py", line 202, in parse
trim_attribute_space=self.trim_attribute_space,
File "C:\env\lib\site-packages\chameleon-2.11-py3.3.egg\chameleon\zpt\program.py", line 145, in __init__
super(MacroProgram, self).__init__(*args, **kwargs)
File "C:\env\lib\site-packages\chameleon-2.11-py3.3.egg\chameleon\program.py", line 32, in __init__
node = self.visit(kind, args)
File "C:\env\lib\site-packages\chameleon-2.11-py3.3.egg\chameleon\program.py", line 38, in visit
return visitor(*args)
File "C:\env\lib\site-packages\chameleon-2.11-py3.3.egg\chameleon\zpt\program.py", line 270, in visit_element
STATIC_ATTRIBUTES = self._create_static_attributes(prepared)
File "C:\env\lib\site-packages\chameleon-2.11-py3.3.egg\chameleon\zpt\program.py", line 790, in _create_static_attributes
return Static(parse(repr(static_attrs)).body)
File "C:\env\lib\site-packages\chameleon-2.11-py3.3.egg\chameleon\astutil.py", line 48, in parse
return compile(source, '', mode, ast.PyCF_ONLY_AST)
TypeError: embedded NUL character
anny1には私の問題の解決策がありますか?
編集:
このリンクはPythonのバグセクションで見つかりました。バグではないと思いますが、これは私の問題に関係しているのかもしれません。それがどのようにタフに機能するかを理解できないようです。 http://bugs.python.org/issue13617