from flask.ext.wtf import * raises Exception #50

Closed
rhyek opened this Issue Aug 27, 2012 · 5 comments

Comments

Projects
None yet
3 participants

rhyek commented Aug 27, 2012

Trying that will raise:

Traceback (most recent call last):
File "", line 1, in
TypeError: Item in ``from list'' not a string

But doing

from flask.ext.wtf import Form

works fine. This is using Flask 0.9, WTForms 1.0.2 and Flask-WTF 0.8 on Debian 6 with python 2.6.

Doing

from flask.ext.wtf import *

on Windows 7 with Python 2.7 does work, though.

rhyek commented Aug 28, 2012

Right, so in case anyone else ran into this, I had to modify flask_wtf/init.py at line 51 with:

__all__ += [str(v) for v in validators.__all__]
__all__ += [str(f) for f in (fields.__all__ if hasattr(fields, '__all__') else fields.core.__all__)]
__all__ += [str(w) for w in (widgets.__all__ if hasattr(widgets, '__all__') else widgets.core.__all__)]

Apparently, all those WTForms modules have the statement

from __future__ import unicode_literals

which was making all contain unicode strings instead of plain str. It seems importing doest not work well with unicode strings.

My solution is probably not the best, so if anyone has any input on this I'd appreciate it.

rhyek closed this Aug 28, 2012

Hi rhyek,

Why did we close this issue? I still have this issue. Can we just fix it?
I think this is important for all users.

Thanks!

rhyek commented Sep 26, 2012

Sorry, you're right. Not exactly sure why I decided to close the issue. You can just go ahead and apply the change I mentioned if you want.

rhyek reopened this Sep 26, 2012

Thank you, rhyek.
As you already have solution for this issue, can we just fix it and merge it into mainline?
Or, I am sorry did I miss something?

@ajford ajford added a commit that referenced this issue Dec 15, 2012

@ajford ajford Force unicode literals to str as per #50.
Implements str cast as suggested by rhyek in issue #50
47fd803
Collaborator

ajford commented Dec 15, 2012

Should be fixed. Thanks for the suggestions and sorry for the delay.

ajford closed this Dec 15, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment