我有一个构建实例pass .plugins.sqlalchemy。它出现在安装列表中,但在安装时导致错误。
下面是ZCML的定义:
<configure xmlns="http://namespaces.zope.org/zope" xmlns:db="http://namespaces.zope.org/db">
<include package="z3c.saconfig" file="meta.zcml" />
<db:engine xmlns="http://namespaces.zope.org/db" name="pas" url="mysql://webadmin:password@rcs-mysql-dev/estep" />
<db:session xmlns="http://namespaces.zope.org/db" name="pas.plugins.sqlalchemy" engine="pas" />
</configure>
回溯是:
Traceback (innermost last):
Module ZPublisher.Publish, line 127, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 47, in call_object
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 575, in installProducts
Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 512, in installProduct
- __traceback_info__: ('pas.plugins.sqlalchemy',)
Module Products.GenericSetup.tool, line 330, in runAllImportStepsFromProfile
- __traceback_info__: profile-pas.plugins.sqlalchemy:install
Module Products.GenericSetup.tool, line 1085, in _runImportStepsFromContext
Module Products.GenericSetup.tool, line 999, in _doRunImportStep
- __traceback_info__: pas.plugins.sqlalchemy.install
Module pas.plugins.sqlalchemy.setuphandlers, line 46, in install
Module sqlalchemy.schema, line 2148, in create_all
Module sqlalchemy.engine.base, line 1698, in create
Module sqlalchemy.engine.base, line 1740, in _run_visitor
Module sqlalchemy.sql.visitors, line 83, in traverse_single
Module sqlalchemy.engine.ddl, line 42, in visit_metadata
Module sqlalchemy.sql.visitors, line 83, in traverse_single
Module sqlalchemy.engine.ddl, line 58, in visit_table
Module sqlalchemy.engine.base, line 1191, in execute
Module sqlalchemy.engine.base, line 1241, in _execute_ddl
Module sqlalchemy.sql.expression, line 1413, in compile
Module sqlalchemy.engine.base, line 702, in compile
Module sqlalchemy.engine.base, line 715, in process
Module sqlalchemy.sql.visitors, line 54, in _compiler_dispatch
Module sqlalchemy.sql.compiler, line 1152, in visit_create_table
Module sqlalchemy.dialects.mysql.base, line 1282, in get_column_specification
Module sqlalchemy.engine.base, line 761, in process
Module sqlalchemy.sql.visitors, line 54, in _compiler_dispatch
Module sqlalchemy.sql.compiler, line 1450, in visit_string
Module sqlalchemy.dialects.mysql.base, line 1520, in visit_VARCHAR
InvalidRequestError: VARCHAR requires a length when rendered on MySQL
您需要指定所有字符串的长度。这意味着:字符串(n)而不是简单的字符串。因此,在 pass .plugins.sqlalchemy.model. user
login = Column(String, unique=True)
是
login = Column(String(100), unique=True)
等等…
我没有MySQL安装,pass .plugins.sqlalchemy对我来说在postgresql上工作得很好,但似乎作者对varchars做了一个假设。假设这不是SQLAlchemy应该自己处理的事情(如果SQLAlchemy的MySQL方言能够为无界的varchar选择适当的最大大小,那将是非常好的),我将看看我是否可以在今晚提交一个修复。
快速浏览一下代码就会发现,除了User表中的Login、name和password和Group表中的name之外,所有的"String"(被数据库视为varchar)字段都有最大长度,并且没有很好的理由说明为什么这些字段应该不同。Update:从subversion中检查https://svn.plone.org/svn/collective/PASPlugins/pas.plugins.sqlalchemy/branches/auspex。这是我的pass .plugins.sqlalchemy版本,支持IGroupCapability接口(允许用户添加和删除也存储在rdb中的组),并且我还为所有无界字符串字段添加了长度。
如果您不知道如何在构建中使用subversion签出,请参阅:http://pypi.python.org/pypi/mr.developer/