3

I have a buildout instance with pas.plugins.sqlalchemy. It appears in installation list but when installing it results in an error.

Here's the ZCML definition:

<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 is:

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
Davi Lima
  • 800
  • 1
  • 6
  • 20
webbyfox
  • 1,049
  • 10
  • 22
  • Look at the line above the diagnostic: "Module sqlalchemy.dialects.mysql.base, line 1520, in visit_VARCHAR". Is "visit_VARCHAR" really the legal name of some component? Or is there a typographical error hiding somewhere in an input file? – Pete Wilson Apr 06 '11 at 17:05

2 Answers2

7

you need to specify lengths for all Strings. That means: String(n) instead of simply String. So, in pas.plugins.sqlalchemy.model.User

 login = Column(String, unique=True)

becomes

 login = Column(String(100), unique=True)

etc...

Rigel Di Scala
  • 3,150
  • 2
  • 17
  • 23
  • That's obviously true - but not something that webbyfox is in a position to fix. It's a bug in pas.plugins.sqlalchemy – Auspex Apr 08 '11 at 01:11
  • Well, that's mighty polite of you. I've just **fixed** the package for you, and you accept somebody else's answer. It **doesn't** fix the error, because next time a new version of the package is released, it will overwrite your changes. – Auspex Apr 08 '11 at 13:30
2

I don't have a MySQL installation, and pas.plugins.sqlalchemy works fine on postgresql for me, but it would seem that the authors have made an assumption about varchars. Assuming it's not something that SQLAlchemy should be handling itself (it would be really nice if the MySQL dialect for SQLalchemy would select an appropriate maximum size for unbounded varchars), I'll see if I can commit a fix this evening.

A quick glance at the code shows that all "String" (treated as varchar by the database) fields have maximum lengths except Login, name and password in the User table and name in the Group table, and there's no good reason why these should be different.

Update: Check out https://svn.plone.org/svn/collective/PASPlugins/pas.plugins.sqlalchemy/branches/auspex from subversion. It's my version of pas.plugins.sqlalchemy with support for the IGroupCapability interface (lets users be added to and removed from groups that are also stored in the rdb), and I've also added lengths to all unbounded String fields.

If you don't know how to use subversion checkouts in buildout, see: http://pypi.python.org/pypi/mr.developer/

Auspex
  • 2,175
  • 15
  • 35
  • OKie, I will have a look at code as well. Do send me any suggestion you have – webbyfox Apr 06 '11 at 19:32
  • I've done according result is same. I'm not sure my instance is using your latest version of plugin or not as I've old version still in buildout-cache eggs folder. here is my buildout.cfg http://www.pastie.org/1766909 . Do I need to update anything in buildout configuration for pointing to new version of plugin. Thanks very much for your time and help – webbyfox Apr 07 '11 at 11:17
  • As I said - you need to get it from subversion. It's nowhere near ready for release. Feel free to contact me directly for help with mr.developer – Auspex Apr 07 '11 at 13:44
  • Thanks for that, Just wondering the changes you suggested has been adopted by my instance or not. as I can still see my old copy there althought there is new copy in the src folder at root level of site. – webbyfox Apr 07 '11 at 14:30
  • Well, your pastie looks right. Run your instance in "debug" mode (bin/instance debug), import pas.plugins.sqlalchemy, and check its `__path__` attribute if you don't think you're getting the right version – Auspex Apr 08 '11 at 01:06
  • I've created an issue for this at https://github.com/auspex/pas.plugins.sqlalchemy/issues/#issue/1. It's probably best to add anything else there. – Auspex Apr 08 '11 at 02:16
  • Hi Aspex, I think your SVN version was fine only change I've made is introduce length for password field too which fix the installation error. Thanks very much for your time and help. – webbyfox Apr 08 '11 at 13:25