Re: [flask] FormAlchemy
- From:
- Francisco Souza
- Date:
- 2010-11-09 @ 00:11
>
> On Mon, Nov 8, 2010 at 7:48 PM, Sebastian Matias Alvarez <
> sebastianmalvarez@gmail.com> wrote:
> Hey,
> Is there any good doc to learn how to well-use formalchemy with flask?
> What do you guys think about this piece of code, I'm not sure I'm
> using formalchemy correctly
>
> @users.route('/add', methods=['GET', 'POST'])
> def add():
> if request.method == 'POST':
> try:
> user = User(request.form['User--name'
>>
>> ],
>> request.form['User--username'], request.form['User--email'],
>> request.form['User--password'])
>> db.session.add(user)
>> db.session.commit()
>> flash('User Added')
>> except IntegrityError, error:
>> flash('Integrity Error')
>> return redirect(url_for('add'))
>> return redirect(url_for('login'))
>> fs = FieldSet(User())
>> fs.configure(options=[fs.password.password()])
>> return render_template('users/add.html', form=fs.render())
>
>
I can't respond to your question, but it would be nice to see a FormAlchemy
extension for Flask :)
Cheers,
Francisco Souza
Software developer at Giran and also full time
Open source evangelist at full time
English: http://www.franciscosouza.net
Portuguese: http://www.franciscosouza.com.br
Twitter: @franciscosouza
+55 27 3026 0264
On Mon, Nov 8, 2010 at 7:48 PM, Sebastian Matias Alvarez <
sebastianmalvarez@gmail.com> wrote:
> Hey,
> Is there any good doc to learn how to well-use formalchemy with flask?
> What do you guys think about this piece of code, I'm not sure I'm
> using formalchemy correctly
>
> @users.route('/add', methods=['GET', 'POST'])
> def add():
> if request.method == 'POST':
> try:
> user = User(request.form['User--name'],
> request.form['User--username'], request.form['User--email'],
> request.form['User--password'])
> db.session.add(user)
> db.session.commit()
> flash('User Added')
> except IntegrityError, error:
> flash('Integrity Error')
> return redirect(url_for('add'))
> return redirect(url_for('login'))
> fs = FieldSet(User())
> fs.configure(options=[fs.password.password()])
> return render_template('users/add.html', form=fs.render())
>
> --
> Sebastián M. Alvarez
> Website: http://aseba.com.ar
> Skype: sebaalvarez
> Córdoba - Argentina
>