librelist archives

« back to archive

Flask-Admin without flask-sqlalchemy

Flask-Admin without flask-sqlalchemy

From:
Larry Tjoelker
Date:
2012-06-26 @ 17:47
In a fairly recent thread: 
http://librelist.com/browser//flask/2012/5/29/re-flask-admin/#fb20075721edeb0ee6cdff72cfcd00ab
, Serge Koval suggested a way to use flask-admin with sqlalchemy's 
declarative syntax and without flask-sqlalchemy.  The suggested code 
resulted in WTF bailing for the next respondent, and it does the same for 
me.  Unfortunately the thread ended without clarifying what might be 
wrong.  

Here's the last bit of my error output:

[ . . . ]
    File 
"/home/publish/.virtualenvs/deploy4/lib/python2.7/site-packages/WTForms-1.0.2-py2.7.egg/wtforms/ext/sqlalchemy/orm.py",
line 239, in model_fields
    field_args.get(name), db_session)
TypeError: convert() takes exactly 5 arguments (6 given)

Any suggestions?   Thanks in advance.

-larry

Re: [flask] Flask-Admin without flask-sqlalchemy

From:
Larry Tjoelker
Date:
2012-06-26 @ 19:57
Serge writes:
> As a short term solution, open flask-admin sources, navigate to 
flask_admin/contrib
> /sqlamodel/form.py and add *args to the `convert` method. 

Works perfectly.  Thank you Serge.

-larry
 
 

Re: [flask] Flask-Admin without flask-sqlalchemy

From:
Serge S. Koval
Date:
2012-06-26 @ 18:09
Here's perfectly working flask-admin without using flask-sqlalchemy
extension:  https://gist.github.com/2997550

Exception you're seeing is happening inside of the wtforms form conversion
logic. Reason why it is failing for you: you're using wtforms 1.0.2, which
changed SQLAlchemy form conversion logic. In pre-1.0.2 `convert` method was
accepting 5 parameters, in 1.0.2 - there's additional session parameter.

I did not verify flask-admin with wtforms 1.0.2, as it is not out yet, but
will take a look.

As a short term solution, open flask-admin sources, navigate to
flask_admin/contrib/sqlamodel/form.py and add *args to the `convert` method.

Serge.

On Tue, Jun 26, 2012 at 8:47 PM, Larry Tjoelker
<larry_tjoelker@dot.ca.gov>wrote:

> In a fairly recent thread:
> 
http://librelist.com/browser//flask/2012/5/29/re-flask-admin/#fb20075721edeb0ee6cdff72cfcd00ab,
Serge Koval suggested a way to use flask-admin with sqlalchemy's
> declarative syntax and without flask-sqlalchemy.  The suggested code
> resulted in WTF bailing for the next respondent, and it does the same for
> me.  Unfortunately the thread ended without clarifying what might be wrong.
>
> Here's the last bit of my error output:
>
> [ . . . ]
>    File
> 
"/home/publish/.virtualenvs/deploy4/lib/python2.7/site-packages/WTForms-1.0.2-py2.7.egg/wtforms/ext/sqlalchemy/orm.py",
> line 239, in model_fields
>    field_args.get(name), db_session)
> TypeError: convert() takes exactly 5 arguments (6 given)
>
> Any suggestions?   Thanks in advance.
>
> -larry
>