From henadzi.tsaryk at gmail.com Tue Apr 5 14:40:15 2016 From: henadzi.tsaryk at gmail.com (Hendzi Tsaryk) Date: Tue, 05 Apr 2016 18:40:15 +0000 Subject: [Flask] Flask Snippets: Login Fails Message-ID: Hi all, I wanted to submit a code snippet at http://flask.pocoo.org/snippets/ but I failed to login. The login doesn't seem to work. I clicked on the Google login link and got redirected to the same page with the error message "Error: The OpenID was invalid". Is it working for anyone else? Thanks, Henadzi -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Tue Apr 5 15:02:10 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Tue, 5 Apr 2016 15:02:10 -0400 Subject: [Flask] Flask Snippets: Login Fails In-Reply-To: References: Message-ID: So if I'm not mistaken, Google has shutdown OpenID authentication in favor of OAuth. I don't think the snippets backend has been updated since then. At least going by https://github.com/mitsuhiko/flask-website/commit/6d3fedc2f77eb3aaade857211ab5841b79cd8146 I don't know if there's a planned upgrade with the migration to Pallets Project. Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Tue, Apr 5, 2016 at 2:40 PM, Hendzi Tsaryk wrote: > Hi all, > > I wanted to submit a code snippet at http://flask.pocoo.org/snippets/ but > I failed to login. The login doesn't seem to work. I clicked on the Google > login link and got redirected to the same page with the error message > "Error: The OpenID was invalid". > > Is it working for anyone else? > > Thanks, > Henadzi > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidism at gmail.com Tue Apr 5 15:09:42 2016 From: davidism at gmail.com (David Lord) Date: Tue, 5 Apr 2016 12:09:42 -0700 Subject: [Flask] Flask Snippets: Login Fails In-Reply-To: References: Message-ID: <57040D76.7090101@gmail.com> Google most likely changed something about their OpenID service. The snippets app hasn?t been updated in a long time. If you have a Stack Overflow account, |https://openid.stackexchange.com/| works as a provider. Other providers should work as well. On 04/05/2016 11:40 AM, Hendzi Tsaryk wrote: > Hi all, > > I wanted to submit a code snippet at > http://flask.pocoo.org/snippets/ but I failed to login. The login > doesn't seem to work. I clicked on the Google login link and got > redirected to the same page with the error message "Error: The OpenID > was invalid". > > Is it working for anyone else? > > Thanks, > Henadzi > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas.dorfner at stud.hs-regensburg.de Wed Apr 6 01:53:50 2016 From: andreas.dorfner at stud.hs-regensburg.de (Andreas Dorfner) Date: Wed, 6 Apr 2016 07:53:50 +0200 Subject: [Flask] Problems with a flask tutorial Message-ID: <5704A46E.8020700@stud.hs-regensburg.de> Hi all, to save the data in a database, I'm trying to use flask. For my first steps with flask, I'm working with the following online tutorial: http://flask.pocoo.org/docs/0.10/tutorial/dbinit/ The web server on Beaglebone Black (with running Debian on it) is still working, but I have problems with "Step3: Creating the Database". By doing the online tutorial step by step, normally it should be possible to create a database by starting up a Python shell and import and call a function like that: Running a python shell: root at beaglebone:~/flaskr# python >>> from flaskr import init_db >>> init_db() By doing so, I get the following error message: Traceback (most recent call last): File "", line 1, in File "flaskr.py", line 28, in init_db with closing(connect_db()) as db: File "flaskr.py", line 23, in connect_db return sqlite3.connect(app.config['DATABASE']) KeyError: 'DATABASE' Does anybody have an idea why I get this error? Attached you can find the source code and the database schema. Many thanks for your help. Andreas --- Diese E-Mail wurde von Avast Antivirus-Software auf Viren gepr?ft. https://www.avast.com/antivirus -------------- next part -------------- #all the imports import sqlite3 from flask import Flask, request, session, g, redirect, url_for, \ abort, render_template, flash from contextlib import closing # configuration DATABASE = '/temp/flaskr.db' DEBUG = True SECRET_KEY = 'development key' USERNAME = 'admin' PASSWORD = 'default' #--------------------------------------------------------------------------- # create our little application :) app = Flask(__name__) app.config.from_envvar('FLASKR_SETTINGS', silent=True) #app.config.from_object(__name__) #--------------------------------------------------------------------------- #connects to the specific database def connect_db(): return sqlite3.connect(app.config['DATABASE']) #--------------------------------------------------------------------------- #initializes the database def init_db(): with closing(connect_db()) as db: with app.open_resource('schema.sql', mode='r') as f: db.cursor().executescript(f.read()) db.commit() #--------------------------------------------------------------------------- #Run the file as a standalone application on IP address 192.168.7.2 (BBB) #at Port 5000. if __name__ == '__main__': app.run(host = '192.168.7.2') #--------------------------------------------------------------------------- #open the database before each request #@app.before_request #def before_request(): # g.db = connect_db() #--------------------------------------------------------------------------- #shut down the database afterwards #@app.teardown_request #def teardown_request(exception): # db = getattr(g, 'db', None) # if db is not None: # db.close() #--------------------------------------------------------------------------- #That function pass the entries as dicts to the show_entries.html template #and return the broadcasted one. #@app.route('/') #def show_entries(): # cur = g.db.execute('select title, text from entries order by id desc') # entries = [dict(title=row[0], text=row[1]) for row in cur.fetchall()] # return render_template('show_entries.html', entries=entries) #--------------------------------------------------------------------------- #This view lets the user add new entries if they are logged in. There is a check #here if the user is logged in as well. #@app.route('/add', methods=['POST']) #def add_entry(): # if not session.get('logged_in'): # abort(401) # g.db.execute('insert into entries (title, text) values (?, ?)', # [request.form['title'], request.form['text']]) # g.db.commit() # flash('New entry was successfully posted') # return redirect(url_for('show_entries')) #--------------------------------------------------------------------------- #Login function #@app.route('/login', methods=['GET', 'POST']) #def login(): # error = None # if request.method == 'POST': # if request.form['username'] != app.config['USERNAME']: # error = 'Invalid username' # elif request.form['password'] != app.config['PASSWORD']: # error = 'Invalid password' # else: # session['logged_in'] = True # flash('You were logged in') # return redirect(url_for('show_entries')) # return render_template('login.html', error=error) #--------------------------------------------------------------------------- #Logout function #@app.route('/logout') #def logout(): # session.pop('logged_in', None) # flash('You were logged out') # return redirect(url_for('show_entries')) #--------------------------------------------------------------------------- -------------- next part -------------- drop table if exists entries; create table entries ( id integer primary key autoincrement, title text not null, text text not null ); From alejoar at gmail.com Wed Apr 6 03:44:20 2016 From: alejoar at gmail.com (Alejo Arias) Date: Wed, 6 Apr 2016 09:44:20 +0200 Subject: [Flask] Problems with a flask tutorial In-Reply-To: <5704A46E.8020700@stud.hs-regensburg.de> References: <5704A46E.8020700@stud.hs-regensburg.de> Message-ID: Hi Andreas, I just quickly checked your code: you have to uncomment line 18 and comment out line 17, as you are defining the app's config variables inside the same file: app = Flask(__name__) > app.config.from_object(__name__) Also, be careful with your DATABASE config setting, as you set it to '/temp/flaskr.db' and the tutorial uses '/tmp/flaskr.db'. Hope that helps. Regards, Alejo On 6 April 2016 at 07:53, Andreas Dorfner < andreas.dorfner at stud.hs-regensburg.de> wrote: > Hi all, > > to save the data in a database, I'm trying to use flask. For my first > steps with flask, I'm working with the following online tutorial: > > http://flask.pocoo.org/docs/0.10/tutorial/dbinit/ > > The web server on Beaglebone Black (with running Debian on it) is still > working, but I have problems with "Step3: Creating the Database". By doing > the online tutorial step by step, normally it should be possible to create > a database by starting up a Python shell and import and call a function > like that: > > Running a python shell: > root at beaglebone:~/flaskr# python > > >>> from flaskr import init_db > >>> init_db() > > By doing so, I get the following error message: > > Traceback (most recent call last): > File "", line 1, in > File "flaskr.py", line 28, in init_db > with closing(connect_db()) as db: > File "flaskr.py", line 23, in connect_db > return sqlite3.connect(app.config['DATABASE']) > KeyError: 'DATABASE' > > Does anybody have an idea why I get this error? > Attached you can find the source code and the database schema. > > Many thanks for your help. > Andreas > > > > > --- > Diese E-Mail wurde von Avast Antivirus-Software auf Viren gepr?ft. > https://www.avast.com/antivirus > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nashef at gmail.com Wed Apr 6 11:03:01 2016 From: nashef at gmail.com (nash) Date: Wed, 6 Apr 2016 08:03:01 -0700 Subject: [Flask] Problems with a flask tutorial In-Reply-To: <5704A46E.8020700@stud.hs-regensburg.de> References: <5704A46E.8020700@stud.hs-regensburg.de> Message-ID: Your app.config isn't setup, so initdb() can't setup the sqlite database. It's looking for app.config['DATABASE'] to contain a filename. From the flaskr tutorial: http://flask.pocoo.org/docs/0.10/tutorial/setup/ I think you will want to go through most of the bits on that page. --nash On Tue, Apr 5, 2016 at 10:53 PM, Andreas Dorfner < andreas.dorfner at stud.hs-regensburg.de> wrote: > Hi all, > > to save the data in a database, I'm trying to use flask. For my first > steps with flask, I'm working with the following online tutorial: > > http://flask.pocoo.org/docs/0.10/tutorial/dbinit/ > > The web server on Beaglebone Black (with running Debian on it) is still > working, but I have problems with "Step3: Creating the Database". By doing > the online tutorial step by step, normally it should be possible to create > a database by starting up a Python shell and import and call a function > like that: > > Running a python shell: > root at beaglebone:~/flaskr# python > > >>> from flaskr import init_db > >>> init_db() > > By doing so, I get the following error message: > > Traceback (most recent call last): > File "", line 1, in > File "flaskr.py", line 28, in init_db > with closing(connect_db()) as db: > File "flaskr.py", line 23, in connect_db > return sqlite3.connect(app.config['DATABASE']) > KeyError: 'DATABASE' > > Does anybody have an idea why I get this error? > Attached you can find the source code and the database schema. > > Many thanks for your help. > Andreas > > > > > --- > Diese E-Mail wurde von Avast Antivirus-Software auf Viren gepr?ft. > https://www.avast.com/antivirus > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From berthe.ed at gmail.com Wed Apr 6 23:35:43 2016 From: berthe.ed at gmail.com (Edouard BERTHE) Date: Thu, 07 Apr 2016 03:35:43 +0000 Subject: [Flask] Flask-Security : Default Inactive User Message-ID: Hello everyone !! I'm using Flask-Security to handle the users/roles management of my app. I have a REALLY simple problem, and I cannot figure how to solve it! Instead of sending confirmation emails, I would like that my users would be declare as "inactive" by default when there are created, so as an administrator could later manually "activate" it. The only way I found is : - overwrite the "UserDatastore" into a MyUserDatastore - overwrite the "_prepare_create_user_args" function to change 'active' to False in the kwargs - Then overwrite SQLAlchemyUserDatastore into a MySQLAlchemyUserDatastore which extends SQLAlchemyDatastore AND MyUserDatastore, and overwrite the __init__ method.. It's really complicated! (and furthermore it doesn't work for me currrently..). Would you know a better solution? Thank you! Edouard -- Edouard Berthe Quantitative Analyst, Covalis Capital +61 435 828 906 | +33 6 69 60 78 46 berthe.ed at gmail.com Skype: berthe.edouard -------------- next part -------------- An HTML attachment was scrubbed... URL: From henadzi.tsaryk at gmail.com Thu Apr 7 02:50:53 2016 From: henadzi.tsaryk at gmail.com (Hendzi Tsaryk) Date: Thu, 07 Apr 2016 06:50:53 +0000 Subject: [Flask] Flask Snippets: Login Fails In-Reply-To: <57040D76.7090101@gmail.com> References: <57040D76.7090101@gmail.com> Message-ID: Thanks, David! The StackExchange provider worked for me! Thanks, Henadzi On Tue, Apr 5, 2016 at 10:09 PM David Lord wrote: > Google most likely changed something about their OpenID service. The > snippets app hasn?t been updated in a long time. If you have a Stack > Overflow account, https://openid.stackexchange.com/ works as a provider. > Other providers should work as well. > > On 04/05/2016 11:40 AM, Hendzi Tsaryk wrote: > > Hi all, > > I wanted to submit a code snippet at > http://flask.pocoo.org/snippets/ but I failed to login. The login doesn't > seem to work. I clicked on the Google login link and got redirected to the > same page with the error message "Error: The OpenID was invalid". > > Is it working for anyone else? > > Thanks, > Henadzi > > > _______________________________________________ > Flask mailing listFlask at python.orghttps://mail.python.org/mailman/listinfo/flask > > ? > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nik.gen at gmx.de Fri Apr 8 10:28:28 2016 From: nik.gen at gmx.de (Nikolaus Neusser) Date: Fri, 8 Apr 2016 16:28:28 +0200 Subject: [Flask] Flask vor webbased GUI (2) Message-ID: An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Fri Apr 8 10:39:20 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Fri, 8 Apr 2016 10:39:20 -0400 Subject: [Flask] Flask vor webbased GUI (2) In-Reply-To: References: Message-ID: Sounds very doable. I suggest you work through Michael Grinberg's Flask book which will get you going on the Flask/UI part. On Fri, Apr 8, 2016 at 10:28 AM, Nikolaus Neusser wrote: > Hi everyone, > > Sorry, last time i sent the eMail using another (not registered) eMail > adress. > > i hope this ist the right place to ask my question, if not please let me > know. > > I am wondering if flask is the right web framework to use for my private > project. > > I am running a python program (app) on my raspberry pi in my local home > network. > I would like to add a webbased GUI, that can control my app. > My python program is based on a QT QTimer object that runs a state machine > every second. > The state machine itself runs lots of other functions. > > - the gui content would be (mainly) static html and css using text, > checkboxes, buttons and a listview > - data has to be sent from the gui to my app, i.e. text, current state of > checkboxes and buttons > - data has to be sent from the app to the gui, i.e. text, required state of > checkboxes, data for listview > - sent and received data should directly interact with the state machine. > > Do you think that can be realized using flask? > > Thanks a lot for your answers. > > Nik > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > From hsysinfo at gmail.com Sat Apr 9 01:22:00 2016 From: hsysinfo at gmail.com (Chukwudi Nwachukwu) Date: Sat, 9 Apr 2016 06:22:00 +0100 Subject: [Flask] Flask Digest, Vol 10, Issue 4 In-Reply-To: References: Message-ID: @Nikolau, I've done something with PySide and Flask and ran it on Rocket Web server to make it fast. One thing I sure know is that Python threads and Qt do not work together, I stand to be corrected on this though. You would have to make sure that the Qt application would be the one to spin the thread that would run the server that would power Flask. If you ask me, Flask is capable of doing all you want and much more. However, you have to figure out a way to make them interact properly. iChux? http://bit.ly/iscrape *Behind every no entry sign, there is a door.* On 8 April 2016 at 17:00, wrote: > Send Flask mailing list submissions to > flask at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.python.org/mailman/listinfo/flask > or, via email, send a message with subject or body 'help' to > flask-request at python.org > > You can reach the person managing the list at > flask-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Flask digest..." > > Today's Topics: > > 1. Flask vor webbased GUI (2) (Nikolaus Neusser) > 2. Re: Flask vor webbased GUI (2) (Corey Boyle) > > > ---------- Forwarded message ---------- > From: Nikolaus Neusser > To: flask at python.org > Cc: > Date: Fri, 8 Apr 2016 16:28:28 +0200 > Subject: [Flask] Flask vor webbased GUI (2) > Hi everyone, > > Sorry, last time i sent the eMail using another (not registered) eMail > adress. > > i hope this ist the right place to ask my question, if not please let me > know. > > I am wondering if flask is the right web framework to use for my private > project. > > I am running a python program (app) on my raspberry pi in my local home > network. > I would like to add a webbased GUI, that can control my app. > My python program is based on a QT QTimer object that runs a state machine > every second. > The state machine itself runs lots of other functions. > > - the gui content would be (mainly) static html and css using text, > checkboxes, buttons and a listview > - data has to be sent from the gui to my app, i.e. text, current state of > checkboxes and buttons > - data has to be sent from the app to the gui, i.e. text, required state > of checkboxes, data for listview > - sent and received data should directly interact with the state machine. > > Do you think that can be realized using flask? > > Thanks a lot for your answers. > > Nik > > > ---------- Forwarded message ---------- > From: Corey Boyle > To: Nikolaus Neusser > Cc: flask at python.org > Date: Fri, 8 Apr 2016 10:39:20 -0400 > Subject: Re: [Flask] Flask vor webbased GUI (2) > Sounds very doable. > > I suggest you work through Michael Grinberg's Flask book which will > get you going on the Flask/UI part. > > On Fri, Apr 8, 2016 at 10:28 AM, Nikolaus Neusser wrote: > > Hi everyone, > > > > Sorry, last time i sent the eMail using another (not registered) eMail > > adress. > > > > i hope this ist the right place to ask my question, if not please let me > > know. > > > > I am wondering if flask is the right web framework to use for my private > > project. > > > > I am running a python program (app) on my raspberry pi in my local home > > network. > > I would like to add a webbased GUI, that can control my app. > > My python program is based on a QT QTimer object that runs a state > machine > > every second. > > The state machine itself runs lots of other functions. > > > > - the gui content would be (mainly) static html and css using text, > > checkboxes, buttons and a listview > > - data has to be sent from the gui to my app, i.e. text, current state of > > checkboxes and buttons > > - data has to be sent from the app to the gui, i.e. text, required state > of > > checkboxes, data for listview > > - sent and received data should directly interact with the state machine. > > > > Do you think that can be realized using flask? > > > > Thanks a lot for your answers. > > > > Nik > > > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > > > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew.pashkin at gmx.co.uk Sat Apr 9 08:58:33 2016 From: andrew.pashkin at gmx.co.uk (Andrew Pashkin) Date: Sat, 9 Apr 2016 15:58:33 +0300 Subject: [Flask] Should extension use an app instance if it's passed to constructor or just always use flask.current_app? Message-ID: <5708FC79.1080103@gmx.co.uk> Hello, everybody! I'm reading about extensions development and it says: As you noticed, |init_app| does not assign |app| to |self|. This is intentional! *Class based Flask extensions must only store the application on the object when the application was passed to the constructor.* This tells the extension: I am not interested in using multiple applications. *When the extension needs to find the current application and it does not have a reference to it, it must either use the **|current_app| * context local or change the API in a way that you can pass the application explicitly. But the example extension , just uses flask.current_app, without checking whether an application instance was attached to the extension instance: ... def connect(self): return sqlite3.connect(*current_app*.config['SQLITE3_DATABASE']) ... So, where is the truth? What extension should really do - always use flask.current_app, or use it only if application instance wasn't passed to the constructor? -- With kind regards, Andrew Pashkin. cell phone - +7 (985) 898 57 59 Skype - waves_in_fluids e-mail - andrew.pashkin at gmx.co.uk -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidism at gmail.com Sat Apr 9 10:51:52 2016 From: davidism at gmail.com (David Lord) Date: Sat, 9 Apr 2016 07:51:52 -0700 Subject: [Flask] Should extension use an app instance if it's passed to constructor or just always use flask.current_app? In-Reply-To: <5708FC79.1080103@gmx.co.uk> References: <5708FC79.1080103@gmx.co.uk> Message-ID: <57091708.90508@gmail.com> If the app is passed in, you can optionally choose to use it. See Flask-SQLAlchemy for an example of how to check multiple sources for the app. It?s probably better to always rely on |current_app|, because then instructions for using the extension are consistent: it must always be in a valid app context. People following instructions that assume the app was passed in is a common source of questions on Stack Overflow. The tradeoff is that you have to remember to push an app context (or use a shell from Flask-Script, etc. that does that for you), you can?t just use the extension directly. On 04/09/2016 05:58 AM, Andrew Pashkin wrote: > Hello, everybody! > > I'm reading about extensions development > and it says: > > As you noticed, |init_app| does not assign |app| to |self|. This > is intentional! *Class based Flask extensions must only store the > application on the object when the application was passed to the > constructor.* This tells the extension: I am not interested in > using multiple applications. > > *When the extension needs to find the current application and it > does not have a reference to it, it must either use the > **|current_app| > * context > local or change the API in a way that you can pass the application > explicitly. > > But the example extension > , > just uses flask.current_app, without checking whether an application > instance was attached to the extension instance: > > ... def connect(self): > return sqlite3.connect(*current_app*.config['SQLITE3_DATABASE']) > ... > > So, where is the truth? What extension should really do - always use > flask.current_app, or use it only if application instance wasn't > passed to the constructor? > -- > With kind regards, Andrew Pashkin. > cell phone - +7 (985) 898 57 59 > Skype - waves_in_fluids > e-mail -andrew.pashkin at gmx.co.uk > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From nik.gen at gmx.de Sun Apr 10 07:59:59 2016 From: nik.gen at gmx.de (nik.gen at gmx.de) Date: Sun, 10 Apr 2016 13:59:59 +0200 Subject: [Flask] Flask vor webbased GUI (2) Message-ID: An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Sun Apr 10 08:39:40 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Sun, 10 Apr 2016 08:39:40 -0400 Subject: [Flask] Flask vor webbased GUI (2) In-Reply-To: References: Message-ID: On Apr 10, 2016 8:00 AM, wrote: > > Ok, thanks. > Seems like Flask is the right way to go. > > > >I suggest you work through Michael Grinberg's Flask book which will get you going on the Flask/UI part. > Michael Grinberg has a very good tutorial as well, i will work through that. > > q1) > So, for exchanging data between the server and the client without having to reload the webpage all the time, i use ajax/jquery? > Right? Yes > > q2) > >However, you have to figure out a way to make them interact properly > Ok, so flask has to run either in a thread (e.g. QThread) or in a separate application, right? > If it runs in a separate application, what would be a good way of connecting the two apps? > Sockets? > Maybe have the web app run in an entirely separate process and use a flat config file to link the two together? Each app watching for changes to the file. YAML purhaps. Just an idea, not my area of expertise. > q3) I am using the following method to run my main python application. Can i not call/run flask within that, without a thread? >> >> def main(): >> app = QCoreApplication(sys.argv) >> timerT = QTimer() >> timerT.start(2000) >> timerT.timeout.connect(oPIV.myTimeTask) >> return app.exec_() >> >> if __name__ == '__main__': >> main() > > > Thanks for your comments, > Nik > > > > > > Am 09.04.2016 um 07:22 schrieb Chukwudi Nwachukwu: >> >> @Nikolau, >> I've done something with PySide and Flask and ran it on Rocket Web server to make it fast. One thing I sure know is that Python threads and Qt do not work together, I stand to be corrected on this though. >> >> You would have to make sure that the Qt application would be the one to spin the thread that would run the server that would power Flask. If you ask me, Flask is capable of doing all you want and much more. However, you have to figure out a way to make them interact properly. >> >> >> >> iChux? >> http://bit.ly/iscrape >> Behind every no entry sign, there is a door. >> >> On 8 April 2016 at 17:00, wrote: >>> >>> Send Flask mailing list submissions to >>> flask at python.org >>> >>> To subscribe or unsubscribe via the World Wide Web, visit >>> https://mail.python.org/mailman/listinfo/flask >>> or, via email, send a message with subject or body 'help' to >>> flask-request at python.org >>> >>> You can reach the person managing the list at >>> flask-owner at python.org >>> >>> When replying, please edit your Subject line so it is more specific >>> than "Re: Contents of Flask digest..." >>> >>> Today's Topics: >>> >>> 1. Flask vor webbased GUI (2) (Nikolaus Neusser) >>> 2. Re: Flask vor webbased GUI (2) (Corey Boyle) >>> >>> >>> >>> ---------- Forwarded message ---------- >>> From: Nikolaus Neusser >>> To: flask at python.org >>> Cc: >>> Date: Fri, 8 Apr 2016 16:28:28 +0200 >>> Subject: [Flask] Flask vor webbased GUI (2) >>> Hi everyone, >>> >>> Sorry, last time i sent the eMail using another (not registered) eMail adress. >>> >>> i hope this ist the right place to ask my question, if not please let me know. >>> >>> I am wondering if flask is the right web framework to use for my private project. >>> >>> I am running a python program (app) on my raspberry pi in my local home network. >>> I would like to add a webbased GUI, that can control my app. >>> My python program is based on a QT QTimer object that runs a state machine every second. >>> The state machine itself runs lots of other functions. >>> >>> - the gui content would be (mainly) static html and css using text, checkboxes, buttons and a listview >>> - data has to be sent from the gui to my app, i.e. text, current state of checkboxes and buttons >>> - data has to be sent from the app to the gui, i.e. text, required state of checkboxes, data for listview >>> - sent and received data should directly interact with the state machine. >>> >>> Do you think that can be realized using flask? >>> >>> Thanks a lot for your answers. >>> >>> Nik >>> >>> >>> ---------- Forwarded message ---------- >>> From: Corey Boyle >>> To: Nikolaus Neusser >>> Cc: flask at python.org >>> Date: Fri, 8 Apr 2016 10:39:20 -0400 >>> Subject: Re: [Flask] Flask vor webbased GUI (2) >>> Sounds very doable. >>> >>> I suggest you work through Michael Grinberg's Flask book which will >>> get you going on the Flask/UI part. >>> >>> On Fri, Apr 8, 2016 at 10:28 AM, Nikolaus Neusser wrote: >>> > Hi everyone, >>> > >>> > Sorry, last time i sent the eMail using another (not registered) eMail >>> > adress. >>> > >>> > i hope this ist the right place to ask my question, if not please let me >>> > know. >>> > >>> > I am wondering if flask is the right web framework to use for my private >>> > project. >>> > >>> > I am running a python program (app) on my raspberry pi in my local home >>> > network. >>> > I would like to add a webbased GUI, that can control my app. >>> > My python program is based on a QT QTimer object that runs a state machine >>> > every second. >>> > The state machine itself runs lots of other functions. >>> > >>> > - the gui content would be (mainly) static html and css using text, >>> > checkboxes, buttons and a listview >>> > - data has to be sent from the gui to my app, i.e. text, current state of >>> > checkboxes and buttons >>> > - data has to be sent from the app to the gui, i.e. text, required state of >>> > checkboxes, data for listview >>> > - sent and received data should directly interact with the state machine. >>> > >>> > Do you think that can be realized using flask? >>> > >>> > Thanks a lot for your answers. >>> > >>> > Nik >>> > >>> > _______________________________________________ >>> > Flask mailing list >>> > Flask at python.org >>> > https://mail.python.org/mailman/listinfo/flask >>> > >>> >>> >>> _______________________________________________ >>> Flask mailing list >>> Flask at python.org >>> https://mail.python.org/mailman/listinfo/flask >>> >> >> >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask > > > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hsysinfo at gmail.com Sun Apr 10 11:25:44 2016 From: hsysinfo at gmail.com (Chukwudi Nwachukwu) Date: Sun, 10 Apr 2016 16:25:44 +0100 Subject: [Flask] Flask Digest, Vol 10, Issue 6 In-Reply-To: References: Message-ID: @nik, I've taken the time to write something minimal that worked for me. I used PySide and I've bundled the code to this link https://db.tt/52SCJFG0 I hope you would be able to draw inspiration from it and then make it happen in your code. iChux? http://bit.ly/iscrape *Behind every no entry sign, there is a door.* On 10 April 2016 at 13:47, wrote: > Send Flask mailing list submissions to > flask at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.python.org/mailman/listinfo/flask > or, via email, send a message with subject or body 'help' to > flask-request at python.org > > You can reach the person managing the list at > flask-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Flask digest..." > > Today's Topics: > > 1. Re: Flask vor webbased GUI (2) (nik.gen at gmx.de) > 2. Re: Flask vor webbased GUI (2) (Corey Boyle) > > > ---------- Forwarded message ---------- > From: nik.gen at gmx.de > To: flask at python.org > Cc: > Date: Sun, 10 Apr 2016 13:59:59 +0200 > Subject: Re: [Flask] Flask vor webbased GUI (2) > Ok, thanks. > Seems like Flask is the right way to go. > > >I suggest you work through Michael Grinberg's Flask book which will get > you going on the Flask/UI part. > Michael Grinberg has a very good tutorial as well, i will work through > that. > > q1) > So, for exchanging data between the server and the client without having > to reload the webpage all the time, i use ajax/jquery? > Right? > > q2) > >However, you have to figure out a way to make them interact properly > Ok, so flask has to run either in a thread (e.g. QThread) or in a separate > application, right? > If it runs in a separate application, what would be a good way of > connecting the two apps? > Sockets? > > q3) I am using the following method to run my main python application. Can > i not call/run flask within that, without a thread? > > *def main():* > * app = QCoreApplication(sys.argv)* > * timerT = QTimer()* > * timerT.start(2000)* > * timerT.timeout.connect(oPIV.myTimeTask) * > * return app.exec_()* > > *if __name__ == '__main__':* > * main()* > > > Thanks for your comments, > Nik > > > > > > Am 09.04.2016 um 07:22 schrieb Chukwudi Nwachukwu: > > @Nikolau, > I've done something with PySide and Flask and ran it on Rocket Web server > to make it fast. One thing I sure know is that Python threads and Qt do not > work together, I stand to be corrected on this though. > > You would have to make sure that the Qt application would be the one to > spin the thread that would run the server that would power Flask. If you > ask me, Flask is capable of doing all you want and much more. However, you > have to figure out a way to make them interact properly. > > > > iChux? > http://bit.ly/iscrape > *Behind every no entry sign, there is a door.* > > On 8 April 2016 at 17:00, wrote: > > Send Flask mailing list submissions to > flask at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.python.org/mailman/listinfo/flask > or, via email, send a message with subject or body 'help' to > flask-request at python.org > > You can reach the person managing the list at > flask-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Flask digest..." > > Today's Topics: > > 1. Flask vor webbased GUI (2) (Nikolaus Neusser) > 2. Re: Flask vor webbased GUI (2) (Corey Boyle) > > > ---------- Forwarded message ---------- > From: Nikolaus Neusser > To: flask at python.org > Cc: > Date: Fri, 8 Apr 2016 16:28:28 +0200 > Subject: [Flask] Flask vor webbased GUI (2) > Hi everyone, > > Sorry, last time i sent the eMail using another (not registered) eMail > adress. > > i hope this ist the right place to ask my question, if not please let me > know. > > I am wondering if flask is the right web framework to use for my private > project. > > I am running a python program (app) on my raspberry pi in my local home > network. > I would like to add a webbased GUI, that can control my app. > My python program is based on a QT QTimer object that runs a state machine > every second. > The state machine itself runs lots of other functions. > > - the gui content would be (mainly) static html and css using text, > checkboxes, buttons and a listview > - data has to be sent from the gui to my app, i.e. text, current state of > checkboxes and buttons > - data has to be sent from the app to the gui, i.e. text, required state > of checkboxes, data for listview > - sent and received data should directly interact with the state machine. > > Do you think that can be realized using flask? > > Thanks a lot for your answers. > > Nik > > > ---------- Forwarded message ---------- > From: Corey Boyle > To: Nikolaus Neusser > Cc: flask at python.org > Date: Fri, 8 Apr 2016 10:39:20 -0400 > Subject: Re: [Flask] Flask vor webbased GUI (2) > Sounds very doable. > > I suggest you work through Michael Grinberg's Flask book which will > get you going on the Flask/UI part. > > On Fri, Apr 8, 2016 at 10:28 AM, Nikolaus Neusser wrote: > > Hi everyone, > > > > Sorry, last time i sent the eMail using another (not registered) eMail > > adress. > > > > i hope this ist the right place to ask my question, if not please let me > > know. > > > > I am wondering if flask is the right web framework to use for my private > > project. > > > > I am running a python program (app) on my raspberry pi in my local home > > network. > > I would like to add a webbased GUI, that can control my app. > > My python program is based on a QT QTimer object that runs a state > machine > > every second. > > The state machine itself runs lots of other functions. > > > > - the gui content would be (mainly) static html and css using text, > > checkboxes, buttons and a listview > > - data has to be sent from the gui to my app, i.e. text, current state of > > checkboxes and buttons > > - data has to be sent from the app to the gui, i.e. text, required state > of > > checkboxes, data for listview > > - sent and received data should directly interact with the state machine. > > > > Do you think that can be realized using flask? > > > > Thanks a lot for your answers. > > > > Nik > > > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > > > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > > > > _______________________________________________ > Flask mailing listFlask at python.orghttps://mail.python.org/mailman/listinfo/flask > > > > > > ---------- Forwarded message ---------- > From: Corey Boyle > To: Nikolaus Neusser > Cc: flask at python.org > Date: Sun, 10 Apr 2016 08:39:40 -0400 > Subject: Re: [Flask] Flask vor webbased GUI (2) > > > On Apr 10, 2016 8:00 AM, wrote: > > > > Ok, thanks. > > Seems like Flask is the right way to go. > > > > > > >I suggest you work through Michael Grinberg's Flask book which will get > you going on the Flask/UI part. > > Michael Grinberg has a very good tutorial as well, i will work through > that. > > > > q1) > > So, for exchanging data between the server and the client without having > to reload the webpage all the time, i use ajax/jquery? > > Right? > > Yes > > > > > q2) > > >However, you have to figure out a way to make them interact properly > > Ok, so flask has to run either in a thread (e.g. QThread) or in a > separate application, right? > > If it runs in a separate application, what would be a good way of > connecting the two apps? > > Sockets? > > > > Maybe have the web app run in an entirely separate process and use a flat > config file to link the two together? Each app watching for changes to the > file. YAML purhaps. Just an idea, not my area of expertise. > > > q3) I am using the following method to run my main python application. > Can i not call/run flask within that, without a thread? > >> > >> def main(): > >> app = QCoreApplication(sys.argv) > >> timerT = QTimer() > >> timerT.start(2000) > >> timerT.timeout.connect(oPIV.myTimeTask) > >> return app.exec_() > >> > >> if __name__ == '__main__': > >> main() > > > > > > Thanks for your comments, > > Nik > > > > > > > > > > > > Am 09.04.2016 um 07:22 schrieb Chukwudi Nwachukwu: > >> > >> @Nikolau, > >> I've done something with PySide and Flask and ran it on Rocket Web > server to make it fast. One thing I sure know is that Python threads and Qt > do not work together, I stand to be corrected on this though. > >> > >> You would have to make sure that the Qt application would be the one to > spin the thread that would run the server that would power Flask. If you > ask me, Flask is capable of doing all you want and much more. However, you > have to figure out a way to make them interact properly. > >> > >> > >> > >> iChux? > >> http://bit.ly/iscrape > >> Behind every no entry sign, there is a door. > >> > >> On 8 April 2016 at 17:00, wrote: > >>> > >>> Send Flask mailing list submissions to > >>> flask at python.org > >>> > >>> To subscribe or unsubscribe via the World Wide Web, visit > >>> https://mail.python.org/mailman/listinfo/flask > >>> or, via email, send a message with subject or body 'help' to > >>> flask-request at python.org > >>> > >>> You can reach the person managing the list at > >>> flask-owner at python.org > >>> > >>> When replying, please edit your Subject line so it is more specific > >>> than "Re: Contents of Flask digest..." > >>> > >>> Today's Topics: > >>> > >>> 1. Flask vor webbased GUI (2) (Nikolaus Neusser) > >>> 2. Re: Flask vor webbased GUI (2) (Corey Boyle) > >>> > >>> > >>> > >>> ---------- Forwarded message ---------- > >>> From: Nikolaus Neusser > >>> To: flask at python.org > >>> Cc: > >>> Date: Fri, 8 Apr 2016 16:28:28 +0200 > >>> Subject: [Flask] Flask vor webbased GUI (2) > >>> Hi everyone, > >>> > >>> Sorry, last time i sent the eMail using another (not registered) eMail > adress. > >>> > >>> i hope this ist the right place to ask my question, if not please let > me know. > >>> > >>> I am wondering if flask is the right web framework to use for my > private project. > >>> > >>> I am running a python program (app) on my raspberry pi in my local > home network. > >>> I would like to add a webbased GUI, that can control my app. > >>> My python program is based on a QT QTimer object that runs a state > machine every second. > >>> The state machine itself runs lots of other functions. > >>> > >>> - the gui content would be (mainly) static html and css using text, > checkboxes, buttons and a listview > >>> - data has to be sent from the gui to my app, i.e. text, current state > of checkboxes and buttons > >>> - data has to be sent from the app to the gui, i.e. text, required > state of checkboxes, data for listview > >>> - sent and received data should directly interact with the state > machine. > >>> > >>> Do you think that can be realized using flask? > >>> > >>> Thanks a lot for your answers. > >>> > >>> Nik > >>> > >>> > >>> ---------- Forwarded message ---------- > >>> From: Corey Boyle > >>> To: Nikolaus Neusser > >>> Cc: flask at python.org > >>> Date: Fri, 8 Apr 2016 10:39:20 -0400 > >>> Subject: Re: [Flask] Flask vor webbased GUI (2) > >>> Sounds very doable. > >>> > >>> I suggest you work through Michael Grinberg's Flask book which will > >>> get you going on the Flask/UI part. > >>> > >>> On Fri, Apr 8, 2016 at 10:28 AM, Nikolaus Neusser > wrote: > >>> > Hi everyone, > >>> > > >>> > Sorry, last time i sent the eMail using another (not registered) > eMail > >>> > adress. > >>> > > >>> > i hope this ist the right place to ask my question, if not please > let me > >>> > know. > >>> > > >>> > I am wondering if flask is the right web framework to use for my > private > >>> > project. > >>> > > >>> > I am running a python program (app) on my raspberry pi in my local > home > >>> > network. > >>> > I would like to add a webbased GUI, that can control my app. > >>> > My python program is based on a QT QTimer object that runs a state > machine > >>> > every second. > >>> > The state machine itself runs lots of other functions. > >>> > > >>> > - the gui content would be (mainly) static html and css using text, > >>> > checkboxes, buttons and a listview > >>> > - data has to be sent from the gui to my app, i.e. text, current > state of > >>> > checkboxes and buttons > >>> > - data has to be sent from the app to the gui, i.e. text, required > state of > >>> > checkboxes, data for listview > >>> > - sent and received data should directly interact with the state > machine. > >>> > > >>> > Do you think that can be realized using flask? > >>> > > >>> > Thanks a lot for your answers. > >>> > > >>> > Nik > >>> > > >>> > _______________________________________________ > >>> > Flask mailing list > >>> > Flask at python.org > >>> > https://mail.python.org/mailman/listinfo/flask > >>> > > >>> > >>> > >>> _______________________________________________ > >>> Flask mailing list > >>> Flask at python.org > >>> https://mail.python.org/mailman/listinfo/flask > >>> > >> > >> > >> > >> _______________________________________________ > >> Flask mailing list > >> Flask at python.org > >> https://mail.python.org/mailman/listinfo/flask > > > > > > > > > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Stephen.Mazzei at asrcfederal.com Tue Apr 12 10:47:25 2016 From: Stephen.Mazzei at asrcfederal.com (Mazzei, Stephen Andrew) Date: Tue, 12 Apr 2016 14:47:25 +0000 Subject: [Flask] Developmental Tools Message-ID: Good morning, I have been tasked with updating an old php webpage. The old php scripts had zero ability for expandability and I decided to blow out the new and re-write it new. I used flask and it has been working perfectly. Being new to all this, I was just wondering if there was any good developmental tools or GUIs I could use to help along the way. Right now I have my environment setup on Ubuntu 15.10 with my database running on a CentOS 6 server. I am using Microsoft Visual Code to write everything and GIT to push my changes and corrections up to the test server for user testing. This has been working but has been extremely all hand typed code. I do not mind doing this, but was wondering if there was any tools or products that could help improve or enhance along the way. Thank you, --- Stephen A. Mazzei Systems Administrator | AFDS, ASRC Federal Data Solutions - P&G HPC Account | 513-634-9965 ________________________________ The preceding message (including attachments) is covered by the Electronic Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended only for the person or entity to which it is addressed, and may contain information that is confidential, protected by attorney-client or other privilege, or otherwise protected from disclosure by law. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error and destroy the original message and all copies. -------------- next part -------------- An HTML attachment was scrubbed... URL: From alejoar at gmail.com Tue Apr 12 11:07:13 2016 From: alejoar at gmail.com (Alejo Arias) Date: Tue, 12 Apr 2016 17:07:13 +0200 Subject: [Flask] Developmental Tools In-Reply-To: References: Message-ID: Hi Stephen, I recommend Sublime Text 3 with a few packages like Anaconda and SublimeLinter for pep8. Here's a good guide you can follow to set it up: https://realpython.com/blog/python/setting-up-sublime-text-3-for-full-stack-python-development/ The process of setting it all up the first time can be tough but once you've done it, it's definitely worth it. Other tools people use are PyCharm, Atom or vim. Hope that helps get you started. Alejo On 12 April 2016 at 16:47, Mazzei, Stephen Andrew < Stephen.Mazzei at asrcfederal.com> wrote: > Good morning, > > > > I have been tasked with updating an old php webpage. The old php scripts > had zero ability for expandability and I decided to blow out the new and > re-write it new. I used flask and it has been working perfectly. Being new > to all this, I was just wondering if there was any good developmental tools > or GUIs I could use to help along the way. Right now I have my environment > setup on Ubuntu 15.10 with my database running on a CentOS 6 server. I am > using Microsoft Visual Code to write everything and GIT to push my changes > and corrections up to the test server for user testing. This has been > working but has been extremely all hand typed code. I do not mind doing > this, but was wondering if there was any tools or products that could help > improve or enhance along the way. > > > > Thank you, > > > > > > --- > > Stephen A. Mazzei > > Systems Administrator | AFDS, ASRC Federal Data Solutions - P&G HPC > Account | 513-634-9965 > > > > > > ------------------------------ > > The preceding message (including attachments) is covered by the Electronic > Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended only > for the person or entity to which it is addressed, and may contain > information that is confidential, protected by attorney-client or other > privilege, or otherwise protected from disclosure by law. If you are not > the intended recipient, you are hereby notified that any retention, > dissemination, distribution, or copying of this communication is strictly > prohibited. Please reply to the sender that you have received the message > in error and destroy the original message and all copies. > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tamasiaina at gmail.com Tue Apr 12 12:31:16 2016 From: tamasiaina at gmail.com (Jonathan Chen) Date: Tue, 12 Apr 2016 09:31:16 -0700 Subject: [Flask] Developmental Tools In-Reply-To: References: Message-ID: The nice thing about Python is that you can almost use any text editor to get it working unlike some other languages. I personally use PyCharm with the VIM plugin. I also use VIM too when its a quick fix. ~Jonathan C. On Tue, Apr 12, 2016 at 8:07 AM, Alejo Arias wrote: > Hi Stephen, > > I recommend Sublime Text 3 with a few packages like Anaconda and > SublimeLinter for pep8. > > Here's a good guide you can follow to set it up: > > https://realpython.com/blog/python/setting-up-sublime-text-3-for-full-stack-python-development/ > > > The process of setting it all up the first time can be tough but once > you've done it, it's definitely worth it. > > Other tools people use are PyCharm, Atom or vim. > > Hope that helps get you started. > > Alejo > > > On 12 April 2016 at 16:47, Mazzei, Stephen Andrew < > Stephen.Mazzei at asrcfederal.com> wrote: > >> Good morning, >> >> >> >> I have been tasked with updating an old php webpage. The old php scripts >> had zero ability for expandability and I decided to blow out the new and >> re-write it new. I used flask and it has been working perfectly. Being new >> to all this, I was just wondering if there was any good developmental tools >> or GUIs I could use to help along the way. Right now I have my environment >> setup on Ubuntu 15.10 with my database running on a CentOS 6 server. I am >> using Microsoft Visual Code to write everything and GIT to push my changes >> and corrections up to the test server for user testing. This has been >> working but has been extremely all hand typed code. I do not mind doing >> this, but was wondering if there was any tools or products that could help >> improve or enhance along the way. >> >> >> >> Thank you, >> >> >> >> >> >> --- >> >> Stephen A. Mazzei >> >> Systems Administrator | AFDS, ASRC Federal Data Solutions - P&G HPC >> Account | 513-634-9965 >> >> >> >> >> >> ------------------------------ >> >> The preceding message (including attachments) is covered by the >> Electronic Communication Privacy Act, 18 U.S.C. sections 2510-2512, is >> intended only for the person or entity to which it is addressed, and may >> contain information that is confidential, protected by attorney-client or >> other privilege, or otherwise protected from disclosure by law. If you are >> not the intended recipient, you are hereby notified that any retention, >> dissemination, distribution, or copying of this communication is strictly >> prohibited. Please reply to the sender that you have received the message >> in error and destroy the original message and all copies. >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexandru at bluemasters.ro Tue Apr 12 13:08:19 2016 From: alexandru at bluemasters.ro (Alexandru) Date: Tue, 12 Apr 2016 20:08:19 +0300 Subject: [Flask] Developmental Tools In-Reply-To: References: Message-ID: <570D2B83.6060207@bluemasters.ro> I use atom.io, personally. Lots and lots of plugins and themes available for it. On 12.04.2016 19:31, Jonathan Chen wrote: > The nice thing about Python is that you can almost use any text editor > to get it working unlike some other languages. > > I personally use PyCharm with the VIM plugin. I also use VIM too when > its a quick fix. > > > ~Jonathan C. > > On Tue, Apr 12, 2016 at 8:07 AM, Alejo Arias > wrote: > > Hi Stephen, > > I recommend Sublime Text 3 with a few packages like Anaconda and > SublimeLinter for pep8. > > Here's a good guide you can follow to set it up: > https://realpython.com/blog/python/setting-up-sublime-text-3-for-full-stack-python-development/ > > > The process of setting it all up the first time can be tough but > once you've done it, it's definitely worth it. > > Other tools people use are PyCharm, Atom or vim. > > Hope that helps get you started. > > Alejo > > > On 12 April 2016 at 16:47, Mazzei, Stephen Andrew > > wrote: > > Good morning, > > I have been tasked with updating an old php webpage. The old > php scripts had zero ability for expandability and I decided > to blow out the new and re-write it new. I used flask and it > has been working perfectly. Being new to all this, I was just > wondering if there was any good developmental tools or GUIs I > could use to help along the way. Right now I have my > environment setup on Ubuntu 15.10 with my database running on > a CentOS 6 server. I am using Microsoft Visual Code to write > everything and GIT to push my changes and corrections up to > the test server for user testing. This has been working but > has been extremely all hand typed code. I do not mind doing > this, but was wondering if there was any tools or products > that could help improve or enhance along the way. > > Thank you, > > --- > > Stephen A. Mazzei > > Systems Administrator | AFDS, ASRC Federal Data Solutions - > P&G HPC Account | 513-634-9965 > > > ------------------------------------------------------------------------ > > The preceding message (including attachments) is covered by > the Electronic Communication Privacy Act, 18 U.S.C. sections > 2510-2512, is intended only for the person or entity to which > it is addressed, and may contain information that is > confidential, protected by attorney-client or other privilege, > or otherwise protected from disclosure by law. If you are not > the intended recipient, you are hereby notified that any > retention, dissemination, distribution, or copying of this > communication is strictly prohibited. Please reply to the > sender that you have received the message in error and destroy > the original message and all copies. > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From errata at gmx.com Tue Apr 12 13:20:47 2016 From: errata at gmx.com (errata at gmx.com) Date: Tue, 12 Apr 2016 11:20:47 -0600 Subject: [Flask] Flask Deployment on Tornado Message-ID: <570D2E6F.2050400@gmx.com> The Flask docs include this snippet for deploying a Flask app on Tornado: http_server = HTTPServer(WSGIContainer(app)) http_server.listen(5000) IOLoop.instance().start() But the Tornado docs have this to say about deploying WSGI apps using WSGIContainer: > Warning > > WSGI is a/synchronous/interface, while Tornado?s concurrency model is > based on single-threaded asynchronous execution. This means that > running a WSGI app with Tornado?s|WSGIContainer| > is/less > scalable/than running the same app in a multi-threaded WSGI server > like|gunicorn|or|uwsgi|. Use|WSGIContainer| > only > when there are benefits to combining Tornado and WSGI in the same > process that outweigh the reduced scalability. > So, is the consensus opinion to stick with gunicorn or uwsgi for deployment? -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidism at gmail.com Tue Apr 12 13:22:58 2016 From: davidism at gmail.com (David Lord) Date: Tue, 12 Apr 2016 10:22:58 -0700 Subject: [Flask] Flask Deployment on Tornado In-Reply-To: <570D2E6F.2050400@gmx.com> References: <570D2E6F.2050400@gmx.com> Message-ID: <570D2EF2.10106@gmail.com> The Tornado section was removed from the docs in master. https://github.com/pallets/flask/pull/1187 On 04/12/2016 10:20 AM, errata at gmx.com wrote: > > The Flask docs include this snippet for deploying a Flask app on Tornado: > http_server = HTTPServer(WSGIContainer(app)) > http_server.listen(5000) > IOLoop.instance().start() > > But the Tornado docs have this to say about deploying WSGI apps using > WSGIContainer: > > >> Warning >> >> WSGI is a/synchronous/interface, while Tornado?s concurrency model is >> based on single-threaded asynchronous execution. This means that >> running a WSGI app with Tornado?s|WSGIContainer| >> is/less >> scalable/than running the same app in a multi-threaded WSGI server >> like|gunicorn|or|uwsgi|. Use|WSGIContainer| >> only >> when there are benefits to combining Tornado and WSGI in the same >> process that outweigh the reduced scalability. >> > > So, is the consensus opinion to stick with gunicorn or uwsgi for > deployment? > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From errata at gmx.com Tue Apr 12 13:29:31 2016 From: errata at gmx.com (errata at gmx.com) Date: Tue, 12 Apr 2016 11:29:31 -0600 Subject: [Flask] Flask Deployment on Tornado In-Reply-To: <570D2EF2.10106@gmail.com> References: <570D2E6F.2050400@gmx.com> <570D2EF2.10106@gmail.com> Message-ID: <570D307B.1010608@gmx.com> Sigh. Sorry. I know the fact that the docs on the web site are out of sync has been discussed, I keep forgetting to use only the dev version. On 04/12/16 11:22 AM, David Lord wrote: > The Tornado section was removed from the docs in master. > https://github.com/pallets/flask/pull/1187 > > On 04/12/2016 10:20 AM, errata at gmx.com wrote: >> >> The Flask docs include this snippet for deploying a Flask app on Tornado: >> http_server = HTTPServer(WSGIContainer(app)) >> http_server.listen(5000) >> IOLoop.instance().start() >> >> But the Tornado docs have this to say about deploying WSGI apps using >> WSGIContainer: >> >> >>> Warning >>> >>> WSGI is a/synchronous/interface, while Tornado?s concurrency model >>> is based on single-threaded asynchronous execution. This means that >>> running a WSGI app with Tornado?s|WSGIContainer| >>> is/less >>> scalable/than running the same app in a multi-threaded WSGI server >>> like|gunicorn|or|uwsgi|. Use|WSGIContainer| >>> only >>> when there are benefits to combining Tornado and WSGI in the same >>> process that outweigh the reduced scalability. >>> >> >> So, is the consensus opinion to stick with gunicorn or uwsgi for >> deployment? >> >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask > > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Tue Apr 12 14:10:41 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Tue, 12 Apr 2016 14:10:41 -0400 Subject: [Flask] Developmental Tools In-Reply-To: <570D2B83.6060207@bluemasters.ro> References: <570D2B83.6060207@bluemasters.ro> Message-ID: I use Vim, Gnu Screen, and Virtualenv Wrapper as my "IDE". Like Jonathan C said, you can use pretty much anything you want that will edit a text file. For Vim plugins: - YouCompleteMe - NerdCommenter - Vim-Airline For those not comfortable living in the terminal I second Sublime. I keep it around for those rare times I'm dual-booted into Windows. Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Tue, Apr 12, 2016 at 1:08 PM, Alexandru wrote: > I use atom.io, personally. > > Lots and lots of plugins and themes available for it. > > > On 12.04.2016 19:31, Jonathan Chen wrote: > > The nice thing about Python is that you can almost use any text editor to > get it working unlike some other languages. > > I personally use PyCharm with the VIM plugin. I also use VIM too when its > a quick fix. > > > ~Jonathan C. > > On Tue, Apr 12, 2016 at 8:07 AM, Alejo Arias wrote: > >> Hi Stephen, >> >> I recommend Sublime Text 3 with a few packages like Anaconda and >> SublimeLinter for pep8. >> >> Here's a good guide you can follow to set it up: >> >> https://realpython.com/blog/python/setting-up-sublime-text-3-for-full-stack-python-development/ >> >> >> The process of setting it all up the first time can be tough but once >> you've done it, it's definitely worth it. >> >> Other tools people use are PyCharm, Atom or vim. >> >> Hope that helps get you started. >> >> Alejo >> >> >> On 12 April 2016 at 16:47, Mazzei, Stephen Andrew < >> Stephen.Mazzei at asrcfederal.com> wrote: >> >>> Good morning, >>> >>> >>> >>> I have been tasked with updating an old php webpage. The old php scripts >>> had zero ability for expandability and I decided to blow out the new and >>> re-write it new. I used flask and it has been working perfectly. Being new >>> to all this, I was just wondering if there was any good developmental tools >>> or GUIs I could use to help along the way. Right now I have my environment >>> setup on Ubuntu 15.10 with my database running on a CentOS 6 server. I am >>> using Microsoft Visual Code to write everything and GIT to push my changes >>> and corrections up to the test server for user testing. This has been >>> working but has been extremely all hand typed code. I do not mind doing >>> this, but was wondering if there was any tools or products that could help >>> improve or enhance along the way. >>> >>> >>> >>> Thank you, >>> >>> >>> >>> >>> >>> --- >>> >>> Stephen A. Mazzei >>> >>> Systems Administrator | AFDS, ASRC Federal Data Solutions - P&G HPC >>> Account | 513-634-9965 >>> >>> >>> >>> >>> >>> ------------------------------ >>> >>> The preceding message (including attachments) is covered by the >>> Electronic Communication Privacy Act, 18 U.S.C. sections 2510-2512, is >>> intended only for the person or entity to which it is addressed, and may >>> contain information that is confidential, protected by attorney-client or >>> other privilege, or otherwise protected from disclosure by law. If you are >>> not the intended recipient, you are hereby notified that any retention, >>> dissemination, distribution, or copying of this communication is strictly >>> prohibited. Please reply to the sender that you have received the message >>> in error and destroy the original message and all copies. >>> >>> _______________________________________________ >>> Flask mailing list >>> Flask at python.org >>> https://mail.python.org/mailman/listinfo/flask >>> >>> >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > > > _______________________________________________ > Flask mailing listFlask at python.orghttps://mail.python.org/mailman/listinfo/flask > > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Tue Apr 12 14:46:28 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Tue, 12 Apr 2016 14:46:28 -0400 Subject: [Flask] Developmental Tools In-Reply-To: References: <570D2B83.6060207@bluemasters.ro> Message-ID: I like Geany. On Tue, Apr 12, 2016 at 2:10 PM, Anthony Ford wrote: > I use Vim, Gnu Screen, and Virtualenv Wrapper as my "IDE". Like Jonathan C > said, you can use pretty much anything you want that will edit a text file. > > For Vim plugins: > - YouCompleteMe > - NerdCommenter > - Vim-Airline > > For those not comfortable living in the terminal I second Sublime. I keep it > around for those rare times I'm dual-booted into Windows. > > Anthony Ford, > KF5IBN, > ford.anthonyj at gmail.com > > On Tue, Apr 12, 2016 at 1:08 PM, Alexandru wrote: >> >> I use atom.io, personally. >> >> Lots and lots of plugins and themes available for it. >> >> >> On 12.04.2016 19:31, Jonathan Chen wrote: >> >> The nice thing about Python is that you can almost use any text editor to >> get it working unlike some other languages. >> >> I personally use PyCharm with the VIM plugin. I also use VIM too when its >> a quick fix. >> >> >> ~Jonathan C. >> >> On Tue, Apr 12, 2016 at 8:07 AM, Alejo Arias wrote: >>> >>> Hi Stephen, >>> >>> I recommend Sublime Text 3 with a few packages like Anaconda and >>> SublimeLinter for pep8. >>> >>> Here's a good guide you can follow to set it up: >>> >>> https://realpython.com/blog/python/setting-up-sublime-text-3-for-full-stack-python-development/ >>> >>> The process of setting it all up the first time can be tough but once >>> you've done it, it's definitely worth it. >>> >>> Other tools people use are PyCharm, Atom or vim. >>> >>> Hope that helps get you started. >>> >>> Alejo >>> >>> >>> On 12 April 2016 at 16:47, Mazzei, Stephen Andrew >>> wrote: >>>> >>>> Good morning, >>>> >>>> >>>> >>>> I have been tasked with updating an old php webpage. The old php scripts >>>> had zero ability for expandability and I decided to blow out the new and >>>> re-write it new. I used flask and it has been working perfectly. Being new >>>> to all this, I was just wondering if there was any good developmental tools >>>> or GUIs I could use to help along the way. Right now I have my environment >>>> setup on Ubuntu 15.10 with my database running on a CentOS 6 server. I am >>>> using Microsoft Visual Code to write everything and GIT to push my changes >>>> and corrections up to the test server for user testing. This has been >>>> working but has been extremely all hand typed code. I do not mind doing >>>> this, but was wondering if there was any tools or products that could help >>>> improve or enhance along the way. >>>> >>>> >>>> >>>> Thank you, >>>> >>>> >>>> >>>> >>>> >>>> --- >>>> >>>> Stephen A. Mazzei >>>> >>>> Systems Administrator | AFDS, ASRC Federal Data Solutions - P&G HPC >>>> Account | 513-634-9965 >>>> >>>> >>>> >>>> >>>> >>>> >>>> ________________________________ >>>> >>>> The preceding message (including attachments) is covered by the >>>> Electronic Communication Privacy Act, 18 U.S.C. sections 2510-2512, is >>>> intended only for the person or entity to which it is addressed, and may >>>> contain information that is confidential, protected by attorney-client or >>>> other privilege, or otherwise protected from disclosure by law. If you are >>>> not the intended recipient, you are hereby notified that any retention, >>>> dissemination, distribution, or copying of this communication is strictly >>>> prohibited. Please reply to the sender that you have received the message in >>>> error and destroy the original message and all copies. >>>> >>>> _______________________________________________ >>>> Flask mailing list >>>> Flask at python.org >>>> https://mail.python.org/mailman/listinfo/flask >>>> >>> >>> >>> _______________________________________________ >>> Flask mailing list >>> Flask at python.org >>> https://mail.python.org/mailman/listinfo/flask >>> >> >> >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > From satya.elipe at gmail.com Thu Apr 14 06:41:28 2016 From: satya.elipe at gmail.com (Satya Elipe) Date: Thu, 14 Apr 2016 11:41:28 +0100 Subject: [Flask] Jijna2 default templates Message-ID: Hello I'm new to flask web development. Just wondering if there's any default templates available in ninja2 that I can just import and use ? Also would be great if some one comment on the best way to use those default templates. Just want to give it a try with default templates rather than start creating my own to begin with. Thanks in anticipation Satya -------------- next part -------------- An HTML attachment was scrubbed... URL: From alejoar at gmail.com Thu Apr 14 07:10:16 2016 From: alejoar at gmail.com (Alejo Arias) Date: Thu, 14 Apr 2016 13:10:16 +0200 Subject: [Flask] Jijna2 default templates In-Reply-To: References: Message-ID: Hello Satya, Jinja is a templating language and there are no "default" templates as far as I know. It is like asking for a "default" flask application. I guess what you are really asking for might be a "hello world" flask application that uses Jinja. There are several guides to learn how to use Jinja with examples that you can find googling a bit. Here's one: https://realpython.com/blog/python/primer-on-jinja-templating/ In that tutorial they use Bootstrap with Jinja, which might be closer to what you were looking for if you assume Bootstrap as a default template. Miguel Gringberg's flask book also guides you through using Jinja with bootstrap, I recommend reading it. Hope that helps. Regards, Alejo On 14 April 2016 at 12:41, Satya Elipe wrote: > Hello > > I'm new to flask web development. > > Just wondering if there's any default templates available in ninja2 that I > can just import and use ? > > Also would be great if some one comment on the best way to use those > default templates. > > Just want to give it a try with default templates rather than start > creating my own to begin with. > > Thanks in anticipation > Satya > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From satya.elipe at gmail.com Thu Apr 14 07:42:26 2016 From: satya.elipe at gmail.com (Satya Elipe) Date: Thu, 14 Apr 2016 12:42:26 +0100 Subject: [Flask] Jijna2 default templates In-Reply-To: References: Message-ID: Hi Alejo Thanks for the prompt response and for the useful info. Got it. So if I want to build up a web app (mostly for static info, with drop down boxes), how easy or difficult it is to use jinja ? In general how easy it is to learn jinja for a new comer like me in web development (I heard jinja is powerful with its powerful library and inheritance, hence through of picking it up for my career on web development). Kindly advise. Sure, will take a look at below pointers. Thanks Satya On Thursday, 14 April 2016, Alejo Arias wrote: > Hello Satya, > > Jinja is a templating language and there are no "default" templates as far > as I know. It is like asking for a "default" flask application. I guess > what you are really asking for might be a "hello world" flask application > that uses Jinja. > > There are several guides to learn how to use Jinja with examples that you > can find googling a bit. Here's one: > https://realpython.com/blog/python/primer-on-jinja-templating/ > > In that tutorial they use Bootstrap with Jinja, which might be closer to > what you were looking for if you assume Bootstrap as a default template. > > Miguel Gringberg's flask book also guides you through using Jinja with > bootstrap, I recommend reading it. > > Hope that helps. > > Regards, > Alejo > > > On 14 April 2016 at 12:41, Satya Elipe wrote: > >> Hello >> >> I'm new to flask web development. >> >> Just wondering if there's any default templates available in ninja2 that >> I can just import and use ? >> >> Also would be great if some one comment on the best way to use those >> default templates. >> >> Just want to give it a try with default templates rather than start >> creating my own to begin with. >> >> Thanks in anticipation >> Satya >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alejoar at gmail.com Thu Apr 14 07:58:46 2016 From: alejoar at gmail.com (Alejo Arias) Date: Thu, 14 Apr 2016 13:58:46 +0200 Subject: [Flask] Jijna2 default templates In-Reply-To: References: Message-ID: Hi Satya, It is quite easy. Here is a quick example for what you mentioned. If you have an array in flask with an undetermined number of options that you want to use in your dropdown: my_options = ['option1', 'option2', 'option3', 'option4'] You can generate your html dropdown in Jinja like this: In my opinion, I think it is not difficult to learn Jinja and it integrates well if you are also learning Flask at the same time. Regards, Alejo On 14 April 2016 at 13:42, Satya Elipe wrote: > Hi Alejo > > Thanks for the prompt response and for the useful info. > > Got it. So if I want to build up a web app (mostly for static info, with > drop down boxes), how easy or difficult it is to use jinja ? > > In general how easy it is to learn jinja for a new comer like me in web > development (I heard jinja is powerful with its powerful library and > inheritance, hence through of picking it up for my career on web > development). > > Kindly advise. > > Sure, will take a look at below pointers. > > Thanks > Satya > > > > On Thursday, 14 April 2016, Alejo Arias wrote: > >> Hello Satya, >> >> Jinja is a templating language and there are no "default" templates as >> far as I know. It is like asking for a "default" flask application. I guess >> what you are really asking for might be a "hello world" flask application >> that uses Jinja. >> >> There are several guides to learn how to use Jinja with examples that you >> can find googling a bit. Here's one: >> https://realpython.com/blog/python/primer-on-jinja-templating/ >> >> In that tutorial they use Bootstrap with Jinja, which might be closer to >> what you were looking for if you assume Bootstrap as a default template. >> >> Miguel Gringberg's flask book also guides you through using Jinja with >> bootstrap, I recommend reading it. >> >> Hope that helps. >> >> Regards, >> Alejo >> >> >> On 14 April 2016 at 12:41, Satya Elipe wrote: >> >>> Hello >>> >>> I'm new to flask web development. >>> >>> Just wondering if there's any default templates available in ninja2 that >>> I can just import and use ? >>> >>> Also would be great if some one comment on the best way to use those >>> default templates. >>> >>> Just want to give it a try with default templates rather than start >>> creating my own to begin with. >>> >>> Thanks in anticipation >>> Satya >>> >>> _______________________________________________ >>> Flask mailing list >>> Flask at python.org >>> https://mail.python.org/mailman/listinfo/flask >>> >>> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Thu Apr 14 08:04:32 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Thu, 14 Apr 2016 08:04:32 -0400 Subject: [Flask] Jijna2 default templates In-Reply-To: References: Message-ID: I've found Jinja to be very intuitive. There are no "default" templates for it, however, the "Flask-Bootstrap" extension may offer the closest thing to a template. I would still recommend getting familiar with the basics of how Jinja works before you give Flask-Bootstrap a spin. As Alejo said, Miguel Gringberg's Flask book is an excellent resource, that's how I got started. On Thu, Apr 14, 2016 at 7:42 AM, Satya Elipe wrote: > Hi Alejo > > Thanks for the prompt response and for the useful info. > > Got it. So if I want to build up a web app (mostly for static info, with > drop down boxes), how easy or difficult it is to use jinja ? > > In general how easy it is to learn jinja for a new comer like me in web > development (I heard jinja is powerful with its powerful library and > inheritance, hence through of picking it up for my career on web > development). > > Kindly advise. > > Sure, will take a look at below pointers. > > Thanks > Satya > > > > On Thursday, 14 April 2016, Alejo Arias wrote: >> >> Hello Satya, >> >> Jinja is a templating language and there are no "default" templates as far >> as I know. It is like asking for a "default" flask application. I guess what >> you are really asking for might be a "hello world" flask application that >> uses Jinja. >> >> There are several guides to learn how to use Jinja with examples that you >> can find googling a bit. Here's one: >> https://realpython.com/blog/python/primer-on-jinja-templating/ >> >> In that tutorial they use Bootstrap with Jinja, which might be closer to >> what you were looking for if you assume Bootstrap as a default template. >> >> Miguel Gringberg's flask book also guides you through using Jinja with >> bootstrap, I recommend reading it. >> >> Hope that helps. >> >> Regards, >> Alejo >> >> >> On 14 April 2016 at 12:41, Satya Elipe wrote: >>> >>> Hello >>> >>> I'm new to flask web development. >>> >>> Just wondering if there's any default templates available in ninja2 that >>> I can just import and use ? >>> >>> Also would be great if some one comment on the best way to use those >>> default templates. >>> >>> Just want to give it a try with default templates rather than start >>> creating my own to begin with. >>> >>> Thanks in anticipation >>> Satya >>> >>> _______________________________________________ >>> Flask mailing list >>> Flask at python.org >>> https://mail.python.org/mailman/listinfo/flask >>> >> > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > From Adam.Steer at anu.edu.au Thu Apr 14 07:52:13 2016 From: Adam.Steer at anu.edu.au (Adam Steer) Date: Thu, 14 Apr 2016 11:52:13 +0000 Subject: [Flask] Jijna2 default templates In-Reply-To: References: Message-ID: <4530FC13-98E6-4F93-B555-71B7A7EBAA54@anu.edu.au> Hi Satya A long time ago I built web things with HTML (before such things as dynamic web pages existed) and then PHP, and haven?t built web pages in more than ten years. I am very new to Flask, until January this year I had never heard of either Flask or Jinja2. However, I?ve found Jinja2 quite natural and easy to get along with. I?m not using all of its features yet, but it?s very easy to set up, get variables from Flask onto a page, have some things that appear under certain conditions or not - and even create nice error handling pages! Some parts of Flask have driven me absolutely nuts, but I?m getting there. Jinja2, on the other hand, has been a breeze - probably because it?s quite similar to how I used to do things a long time ago. All that probably isn?t super helpful - I?m hopefully encouraging you to just have a go and see how it works. Jinja2 is not scary at all - if you can understand variables, and dig a bit into how Flask works, Jinja2 will take the least of your time. Regards Adam > On 14 Apr 2016, at 9:42 PM, Satya Elipe wrote: > > Hi Alejo > > Thanks for the prompt response and for the useful info. > > Got it. So if I want to build up a web app (mostly for static info, with drop down boxes), how easy or difficult it is to use jinja ? > > In general how easy it is to learn jinja for a new comer like me in web development (I heard jinja is powerful with its powerful library and inheritance, hence through of picking it up for my career on web development). > > Kindly advise. > > Sure, will take a look at below pointers. > > Thanks > Satya > > > > On Thursday, 14 April 2016, Alejo Arias wrote: > Hello Satya, > > Jinja is a templating language and there are no "default" templates as far as I know. It is like asking for a "default" flask application. I guess what you are really asking for might be a "hello world" flask application that uses Jinja. > > There are several guides to learn how to use Jinja with examples that you can find googling a bit. Here's one: https://realpython.com/blog/python/primer-on-jinja-templating/ > > In that tutorial they use Bootstrap with Jinja, which might be closer to what you were looking for if you assume Bootstrap as a default template. > > Miguel Gringberg's flask book also guides you through using Jinja with bootstrap, I recommend reading it. > > Hope that helps. > > Regards, > Alejo > > > On 14 April 2016 at 12:41, Satya Elipe wrote: > Hello > > I'm new to flask web development. > > Just wondering if there's any default templates available in ninja2 that I can just import and use ? > > Also would be great if some one comment on the best way to use those default templates. > > Just want to give it a try with default templates rather than start creating my own to begin with. > > Thanks in anticipation > Satya > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask From satya.elipe at gmail.com Thu Apr 14 11:46:39 2016 From: satya.elipe at gmail.com (Satya Elipe) Date: Thu, 14 Apr 2016 16:46:39 +0100 Subject: [Flask] Jijna2 default templates In-Reply-To: References: Message-ID: Thank you very much Alejo, Adam and Corey. Will read through the material suggested and come back if I have any further queries. Best Wishes Satya On Thursday, 14 April 2016, Corey Boyle wrote: > I've found Jinja to be very intuitive. > There are no "default" templates for it, however, the > "Flask-Bootstrap" extension may offer the closest thing to a template. > I would still recommend getting familiar with the basics of how Jinja > works before you give Flask-Bootstrap a spin. > As Alejo said, Miguel Gringberg's Flask book is an excellent resource, > that's how I got started. > > On Thu, Apr 14, 2016 at 7:42 AM, Satya Elipe > wrote: > > Hi Alejo > > > > Thanks for the prompt response and for the useful info. > > > > Got it. So if I want to build up a web app (mostly for static info, with > > drop down boxes), how easy or difficult it is to use jinja ? > > > > In general how easy it is to learn jinja for a new comer like me in web > > development (I heard jinja is powerful with its powerful library and > > inheritance, hence through of picking it up for my career on web > > development). > > > > Kindly advise. > > > > Sure, will take a look at below pointers. > > > > Thanks > > Satya > > > > > > > > On Thursday, 14 April 2016, Alejo Arias > wrote: > >> > >> Hello Satya, > >> > >> Jinja is a templating language and there are no "default" templates as > far > >> as I know. It is like asking for a "default" flask application. I guess > what > >> you are really asking for might be a "hello world" flask application > that > >> uses Jinja. > >> > >> There are several guides to learn how to use Jinja with examples that > you > >> can find googling a bit. Here's one: > >> https://realpython.com/blog/python/primer-on-jinja-templating/ > >> > >> In that tutorial they use Bootstrap with Jinja, which might be closer to > >> what you were looking for if you assume Bootstrap as a default template. > >> > >> Miguel Gringberg's flask book also guides you through using Jinja with > >> bootstrap, I recommend reading it. > >> > >> Hope that helps. > >> > >> Regards, > >> Alejo > >> > >> > >> On 14 April 2016 at 12:41, Satya Elipe > wrote: > >>> > >>> Hello > >>> > >>> I'm new to flask web development. > >>> > >>> Just wondering if there's any default templates available in ninja2 > that > >>> I can just import and use ? > >>> > >>> Also would be great if some one comment on the best way to use those > >>> default templates. > >>> > >>> Just want to give it a try with default templates rather than start > >>> creating my own to begin with. > >>> > >>> Thanks in anticipation > >>> Satya > >>> > >>> _______________________________________________ > >>> Flask mailing list > >>> Flask at python.org > >>> https://mail.python.org/mailman/listinfo/flask > >>> > >> > > > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gabor at szabgab.com Fri Apr 15 01:06:02 2016 From: gabor at szabgab.com (Gabor Szabo) Date: Fri, 15 Apr 2016 08:06:02 +0300 Subject: [Flask] commafy filter Message-ID: Hi, is there a filter in Jinja to commafy numbers? That is, to put a comma in-front of ever 3 digits? I could not find one yet, so I've been using this expression all over the place: {{ "{:,}".format( value ) }} but I think it would be nicer if I could write {{ value | commafy }} regards Gabor -------------- next part -------------- An HTML attachment was scrubbed... URL: From jani.sumak at gmail.com Fri Apr 15 01:26:03 2016 From: jani.sumak at gmail.com (=?UTF-8?Q?Jani_=C5=A0umak?=) Date: Fri, 15 Apr 2016 05:26:03 +0000 Subject: [Flask] commafy filter In-Reply-To: References: Message-ID: Hi Gabor, you mean something similar to intcomma in Django ( https://docs.djangoproject.com/en/1.9/ref/contrib/humanize/#intcomma)? I think not (please correct me if I am wrong), but you can always register your own filters. Take a look at custom filters . Hope that helps! Cheers, Jani On Fri, Apr 15, 2016 at 7:06 AM Gabor Szabo wrote: > Hi, > > is there a filter in Jinja to commafy numbers? That is, to put a comma > in-front of ever 3 digits? > > I could not find one yet, so I've been using this expression all over the > place: > > {{ "{:,}".format( value ) }} > > but I think it would be nicer if I could write > > {{ value | commafy }} > > > > regards > Gabor > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gabor at szabgab.com Fri Apr 15 01:35:24 2016 From: gabor at szabgab.com (Gabor Szabo) Date: Fri, 15 Apr 2016 08:35:24 +0300 Subject: [Flask] commafy filter In-Reply-To: References: Message-ID: Hi Jani, yes, it seems in Django it is called intcomma. I was looking at the custom filters page, but so far I have not managed to make that work. I've added the following to the file of my flask application, but I still get TemplateAssertionError: no filter named 'commafy' It is not yet clear to me how do I convince Flask to see it. from jinja2 import Environment env = Environment() def commafy(s): return 42 env.filters['commafy'] = commafy Gabor On Fri, Apr 15, 2016 at 8:26 AM, Jani ?umak wrote: > Hi Gabor, > > you mean something similar to intcomma in Django ( > https://docs.djangoproject.com/en/1.9/ref/contrib/humanize/#intcomma)? I > think not (please correct me if I am wrong), but you can always register > your own filters. Take a look at custom filters > . > > Hope that helps! > > Cheers, Jani > > On Fri, Apr 15, 2016 at 7:06 AM Gabor Szabo wrote: > >> Hi, >> >> is there a filter in Jinja to commafy numbers? That is, to put a comma >> in-front of ever 3 digits? >> >> I could not find one yet, so I've been using this expression all over the >> place: >> >> {{ "{:,}".format( value ) }} >> >> but I think it would be nicer if I could write >> >> {{ value | commafy }} >> >> >> >> regards >> Gabor >> >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> > -- Gabor Szabo http://szabgab.com/ Code Maven http://code-maven.com/ Perl Maven http://perlmaven.com/ Perl Weekly http://perlweekly.com/ Phone: +972-54-4624648 -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidism at gmail.com Fri Apr 15 01:47:27 2016 From: davidism at gmail.com (David Lord) Date: Thu, 14 Apr 2016 22:47:27 -0700 Subject: [Flask] commafy filter In-Reply-To: References: Message-ID: <5710806F.3060604@gmail.com> You can register your own template filters with your app. They will be available in any templates rendered with the app?s Jinja env. |@app.template_filter() def commafy(value): return '{:,}'.format(value) | On 04/14/2016 10:06 PM, Gabor Szabo wrote: > Hi, > > is there a filter in Jinja to commafy numbers? That is, to put a comma > in-front of ever 3 digits? > > I could not find one yet, so I've been using this expression all over > the place: > > {{ "{:,}".format( value ) }} > > but I think it would be nicer if I could write > > {{ value | commafy }} > > > > regards > Gabor > > > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From gabor at szabgab.com Fri Apr 15 02:39:19 2016 From: gabor at szabgab.com (Gabor Szabo) Date: Fri, 15 Apr 2016 09:39:19 +0300 Subject: [Flask] commafy filter In-Reply-To: <5710806F.3060604@gmail.com> References: <5710806F.3060604@gmail.com> Message-ID: Nice. Thank you all! Gabor On Fri, Apr 15, 2016 at 8:47 AM, David Lord wrote: > You can register your own template filters with your app. They will be > available in any templates rendered with the app?s Jinja env. > > @app.template_filter()def commafy(value): > return '{:,}'.format(value) > > On 04/14/2016 10:06 PM, Gabor Szabo wrote: > > Hi, > > is there a filter in Jinja to commafy numbers? That is, to put a comma > in-front of ever 3 digits? > > I could not find one yet, so I've been using this expression all over the > place: > > {{ "{:,}".format( value ) }} > > but I think it would be nicer if I could write > > {{ value | commafy }} > > > > regards > Gabor > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gabor at szabgab.com Fri Apr 15 02:46:43 2016 From: gabor at szabgab.com (Gabor Szabo) Date: Fri, 15 Apr 2016 09:46:43 +0300 Subject: [Flask] Avoiding crash when compilation error occurs during development Message-ID: Hi, this has been bothering me for a while now, and have not found a solution yet. During development I launch the application using app.run(debug=True, host='0.0.0.0') it works nicely and reloads the application when I make some changes, but if I make a syntax error, and I make quite a lot of them, then the server crashes and then I have to switch to the console to start it again. Is there a way to avoid this? Well, besides not making syntax errors any more. Gabor -------------- next part -------------- An HTML attachment was scrubbed... URL: From jerry.mccreary at mac.com Fri Apr 15 01:49:07 2016 From: jerry.mccreary at mac.com (Jerry Mccreary) Date: Fri, 15 Apr 2016 01:49:07 -0400 Subject: [Flask] commafy filter In-Reply-To: References: Message-ID: There is a Flask interface for the Humanize library. https://github.com/vitalk/flask-humanize It has intcomma filter. -- Jerry McCreary > On Apr 15, 2016, at 1:35 AM, Gabor Szabo wrote: > > Hi Jani, > > yes, it seems in Django it is called intcomma. > I was looking at the custom filters page, but so far I have not managed to make that work. > > I've added the following to the file of my flask application, but I still get TemplateAssertionError: no filter named 'commafy' > It is not yet clear to me how do I convince Flask to see it. > > from jinja2 import Environment > env = Environment() > > def commafy(s): > return 42 > env.filters['commafy'] = commafy > > > Gabor > >> On Fri, Apr 15, 2016 at 8:26 AM, Jani ?umak wrote: >> Hi Gabor, >> >> you mean something similar to intcomma in Django (https://docs.djangoproject.com/en/1.9/ref/contrib/humanize/#intcomma)? I think not (please correct me if I am wrong), but you can always register your own filters. Take a look at custom filters. >> >> Hope that helps! >> >> Cheers, Jani >> >>> On Fri, Apr 15, 2016 at 7:06 AM Gabor Szabo wrote: >>> Hi, >>> >>> is there a filter in Jinja to commafy numbers? That is, to put a comma in-front of ever 3 digits? >>> >>> I could not find one yet, so I've been using this expression all over the place: >>> >>> {{ "{:,}".format( value ) }} >>> >>> but I think it would be nicer if I could write >>> >>> {{ value | commafy }} >>> >>> >>> >>> regards >>> Gabor >>> >>> >>> _______________________________________________ >>> Flask mailing list >>> Flask at python.org >>> https://mail.python.org/mailman/listinfo/flask > > > > -- > Gabor Szabo http://szabgab.com/ > Code Maven http://code-maven.com/ > Perl Maven http://perlmaven.com/ > Perl Weekly http://perlweekly.com/ > Phone: +972-54-4624648 > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From alejoar at gmail.com Fri Apr 15 03:02:54 2016 From: alejoar at gmail.com (Alejo Arias) Date: Fri, 15 Apr 2016 09:02:54 +0200 Subject: [Flask] Avoiding crash when compilation error occurs during development In-Reply-To: References: Message-ID: Hi Gabor, Unfortunately there's no straight forward way to do that. A python program won't run with syntax or semantic errors. What you could do is use an editor with linting that will highlight your syntax mistakes and make sure you don't save the file with errors in it. This can greatly help you minimize your problem. Yesterday someone asked about IDEs for developing flask, you can check those answers to find some editor suggestions. Regards, Alejo On Apr 15, 2016 08:46, "Gabor Szabo" wrote: > > Hi, > > this has been bothering me for a while now, and have not found a solution > yet. > > During development I launch the application using > > app.run(debug=True, host='0.0.0.0') > > it works nicely and reloads the application when I make some changes, > but if I make a syntax error, and I make quite a lot of them, then the > server crashes > and then I have to switch to the console to start it again. > > Is there a way to avoid this? > Well, besides not making syntax errors any more. > > Gabor > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alejoar at gmail.com Fri Apr 15 04:02:48 2016 From: alejoar at gmail.com (Alejo Arias) Date: Fri, 15 Apr 2016 10:02:48 +0200 Subject: [Flask] Avoiding crash when compilation error occurs during development In-Reply-To: References: Message-ID: Here's the thread I was referring to. Sorry, I was on my phone before. https://mail.python.org/pipermail/flask/2016-April/000311.html Regards On 15 April 2016 at 09:02, Alejo Arias wrote: > Hi Gabor, > > Unfortunately there's no straight forward way to do that. A python program > won't run with syntax or semantic errors. > > What you could do is use an editor with linting that will highlight your > syntax mistakes and make sure you don't save the file with errors in it. > This can greatly help you minimize your problem. > > Yesterday someone asked about IDEs for developing flask, you can check > those answers to find some editor suggestions. > > Regards, > Alejo > On Apr 15, 2016 08:46, "Gabor Szabo" wrote: > >> >> Hi, >> >> this has been bothering me for a while now, and have not found a solution >> yet. >> >> During development I launch the application using >> >> app.run(debug=True, host='0.0.0.0') >> >> it works nicely and reloads the application when I make some changes, >> but if I make a syntax error, and I make quite a lot of them, then the >> server crashes >> and then I have to switch to the console to start it again. >> >> Is there a way to avoid this? >> Well, besides not making syntax errors any more. >> >> Gabor >> >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas.dorfner at stud.hs-regensburg.de Mon Apr 18 09:11:43 2016 From: andreas.dorfner at stud.hs-regensburg.de (Andreas Dorfner) Date: Mon, 18 Apr 2016 15:11:43 +0200 Subject: [Flask] Data Logger with flask Message-ID: <5714DD0F.90301@stud.hs-regensburg.de> Hi all, I would like to realize a data logger for energy meter ALE3 with a beaglebone black running debian on it (for datasheet see link below). After an initialization time of 30 sec. for the ALE3 module, the framework pymodbus is used to read data from the energy meter (refresh time for new data is 10 sec.) and display it on the therminal. Ok, that part is still working with the following code (code without initialization). time.sleep(30) #communication is ready 30 sec. after power on while 1: val = client.connect() if not val: print "Error in Client Connection" rcv_data = client.read_holding_registers(35, count = 17, unit = 1) #read registers 36 to 52 and save it in rcv_data print("Registers are") for i in range (17): print(rcv_data.registers[i]) client.close() time.sleep(10) #refresh time for the data of the energy meter is 10 sec. Next, I would like to save that data in a database and create a website to edit the informations as a graph or a diagram. For that, I will use flask, but I'm not sure if flask is the right framework for this project? Does someone have experience with the implementation of a data logger using flask or does anybody knows another framework which better fits to my project? Is it possible to run the webserver for the website and the Pymodbus code in the same Python-File or is it a problem because of the while infinite loop? Maybe it's better to split it to two separate files, one for read data and save it in a database; the second one for the webserver. But how can I link that two files, because I think they have to run simultaneously. I'm a newbie in python and flask, so hopefully you have a lot of informations and suggestions for me and my project. All I did with flask is the tutorial (see also attachment). http://flask.pocoo.org/docs/0.10/tutorial/#tutorial Maybe I can use some parts of that tutorial and save the data of the energy meter in the database I have initiazized there? Thanks in anticipation for all your help! Andreas Datasheet energy meter ALE3: http://www.meterbuy.com/fileadmin/user_upload/Data_sheets/120102_SAIA_-_Data_sheet_26-527_EN_DS_Energy-Meter-ALE3-with-Modbus.pdf --- Diese E-Mail wurde von Avast Antivirus-Software auf Viren gepr?ft. https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- #all the imports import sqlite3 from flask import Flask, request, session, g, redirect, url_for, \ abort, render_template, flash from contextlib import closing # configuration DATABASE = '/tmp/flaskr.db' DEBUG = True SECRET_KEY = 'development key' USERNAME = 'admin' PASSWORD = 'default' #--------------------------------------------------------------------------- # create my little application :) app = Flask(__name__) app.config.from_object(__name__) #--------------------------------------------------------------------------- #connects to the specific database def connect_db(): return sqlite3.connect(app.config['DATABASE']) #--------------------------------------------------------------------------- #initializes the database def init_db(): with closing(connect_db()) as db: with app.open_resource('schema.sql', mode='r') as f: db.cursor().executescript(f.read()) db.commit() #--------------------------------------------------------------------------- #open the database before each request @app.before_request def before_request(): g.db = connect_db() #--------------------------------------------------------------------------- #shut down the database afterwards @app.teardown_request def teardown_request(exception): db = getattr(g, 'db', None) if db is not None: db.close() #--------------------------------------------------------------------------- #That function pass the entries as dicts to the show_entries.html template #and return the broadcasted one. @app.route('/') def show_entries(): cur = g.db.execute('select title, text from entries order by id desc') entries = [dict(title=row[0], text=row[1]) for row in cur.fetchall()] return render_template('show_entries.html', entries=entries) #--------------------------------------------------------------------------- #This view lets the user add new entries if he is logged in. There is a check #if the user is logged in as well. @app.route('/add', methods=['POST']) def add_entry(): if not session.get('logged_in'): abort(401) g.db.execute('insert into entries (title, text) values (?, ?)', [request.form['title'], request.form['text']]) g.db.commit() flash('New entry was successfully posted') return redirect(url_for('show_entries')) #--------------------------------------------------------------------------- #--------------------------------------------------------------------------- # The following two functions are used to sign the user in and out. Login # checks the username and password against the ones from the configuration # above and sets the logged_in key in the session. Logout remove that key # from the session. #--------------------------------------------------------------------------- #Login function @app.route('/login', methods=['GET', 'POST']) def login(): error = None if request.method == 'POST': if request.form['username'] != app.config['USERNAME']: error = 'Invalid username' elif request.form['password'] != app.config['PASSWORD']: error = 'Invalid password' else: session['logged_in'] = True flash('You were logged in') return redirect(url_for('show_entries')) return render_template('login.html', error=error) #--------------------------------------------------------------------------- #Logout function @app.route('/logout') def logout(): session.pop('logged_in', None) flash('You were logged out') return redirect(url_for('show_entries')) #--------------------------------------------------------------------------- #Run the file as a standalone application on IP address 192.168.7.2 (BBB) #at Port 5000 if __name__ == '__main__': app.run(host = '192.168.7.2') #--------------------------------------------------------------------------- From barak.bloch at gmail.com Mon Apr 18 10:02:35 2016 From: barak.bloch at gmail.com (Barak Bloch) Date: Mon, 18 Apr 2016 17:02:35 +0300 Subject: [Flask] Avoiding crash when compilation error occurs during development In-Reply-To: References: Message-ID: I think the way to go is to write a shell script to run the python server and when it fails will run it again. On 15 April 2016 at 09:46, Gabor Szabo wrote: > > Hi, > > this has been bothering me for a while now, and have not found a solution > yet. > > During development I launch the application using > > app.run(debug=True, host='0.0.0.0') > > it works nicely and reloads the application when I make some changes, > but if I make a syntax error, and I make quite a lot of them, then the > server crashes > and then I have to switch to the console to start it again. > > Is there a way to avoid this? > Well, besides not making syntax errors any more. > > Gabor > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From and.damore at gmail.com Tue Apr 19 02:52:38 2016 From: and.damore at gmail.com (Andrea D'Amore) Date: Tue, 19 Apr 2016 08:52:38 +0200 Subject: [Flask] Avoiding crash when compilation error occurs during development In-Reply-To: References: Message-ID: On 18 April 2016 at 16:02, Barak Bloch wrote: > I think the way to go is to write a shell script to run the python server > and when it fails will run it again. I wouldn't suggest a re-run-on-fail, simply respawning a process that exited with error because a syntax error was introduced will just result in the same fail over and over. Such a spawner would better be observing the fs for changes (fsnotify or so, depending on the system) and then retry. -- Andrea From and.damore at gmail.com Tue Apr 19 03:19:24 2016 From: and.damore at gmail.com (Andrea D'Amore) Date: Tue, 19 Apr 2016 09:19:24 +0200 Subject: [Flask] Data Logger with flask In-Reply-To: <5714DD0F.90301@stud.hs-regensburg.de> References: <5714DD0F.90301@stud.hs-regensburg.de> Message-ID: On 18 April 2016 at 15:11, Andreas Dorfner wrote: > Next, I would like to save that data in a database and create a website to edit the informations as a graph or a diagram. > For that, I will use flask, but I'm not sure if flask is the right framework for this project? It depends on what you mean for "right", Flask is certainly capable of doing that. Actually any microframework would be, but with Flask you have a nice ecosystem if you want to add anything later on. I suggest go with Flask, but this is a Flask mailing list so my advice may be biased. > Is it possible to run the webserver for the website and the Pymodbus code in the same Python-File or is it a problem because of the while infinite loop? Maybe it's better to split it to two separate files, one for read data and save it in a database; the second one for the webserver. But how can I link that two files, because I think they have to run simultaneously. You're doing active polling there, while a webserver adheres to a client-server paradigm where the client initiates the action while the server waits. Those two are different in nature, I've never checked werkzeug's internals but I'm not sure it won't keep the thread busy. I'd keep those two parts separated. Running two programs at the same time isn't an issue, in a sh-like shell you run: ./fetcher.py & ./webserver.py & or any variation of that, according to your spawner. You're likely wanting to display the data from the meter as a system service, i.e. you switch on the beagleboard, you wait an adequate amount of time and then the system should be working. How to implement that depends on the operating system that the BB is running. > Maybe I can use some parts of that tutorial and save the data of the energy meter in the database I have initiazized there? The app looks fairly simple from what you described, you want a single view, in which you load a bunch of data from the db and then pass it to the template for rendering. I'd use one of the nice js plotting library out there to plot the data passed. Then you either reload the whole page or you could go with a more refined solution, implement a specific method returning just the updated data and then just reload the chart via AJAX rather than the whole page.. It may not be worth the effort it in this case since the 10 seconds refresh period is quite long and you're not likely to have more than a couple clients at a time. -- Andrea From ford.anthonyj at gmail.com Tue Apr 19 08:00:10 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Tue, 19 Apr 2016 08:00:10 -0400 Subject: [Flask] Data Logger with flask In-Reply-To: References: <5714DD0F.90301@stud.hs-regensburg.de> Message-ID: To chime in, Andrea has the right idea. You want to separate your background logger and your web view. If you leverage your SQLAlchemy models right, you can share those in a common package to both applications, or if your SQL is straight-forward, you can skip it and write your own queries. I have a project for work that is this exact same architecture. For continual logging of multiple parameters of the Arecibo Observatory's Cryogenics system, my background process uses PyModbus to poll the industrial microcontroller modules for the parameters, dumps them in a Postgres DB, and my web front-end pulls the DB data and generates live graphs and JSON structures for the API. I originally used Supervisor (http://supervisord.org/) to manage the background process, but I've started to explore using uwsgi to launch it as a worker process. No real progress on that yet. For managing the Polling, I use APScheduler ( http://apscheduler.readthedocs.org/en/latest/userguide.html), but that's cause originally I had a more dynamic polling (adjusting rates throughout the day to account for cooler nights and hotter days). I now poll every 5 minutes, and could have easily done it with a loop. Good Luck! Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Tue, Apr 19, 2016 at 3:19 AM, Andrea D'Amore wrote: > On 18 April 2016 at 15:11, Andreas Dorfner > wrote: > > Next, I would like to save that data in a database and create a website > to edit the informations as a graph or a diagram. > > For that, I will use flask, but I'm not sure if flask is the right > framework for this project? > > It depends on what you mean for "right", Flask is certainly capable of > doing that. > Actually any microframework would be, but with Flask you have a nice > ecosystem if you want to add anything later on. > I suggest go with Flask, but this is a Flask mailing list so my advice > may be biased. > > > Is it possible to run the webserver for the website and the Pymodbus > code in the same Python-File or is it a problem because of the while > infinite loop? Maybe it's better to split it to two separate files, one for > read data and save it in a database; the second one for the webserver. But > how can I link that two files, because I think they have to run > simultaneously. > > You're doing active polling there, while a webserver adheres to a > client-server paradigm where the client initiates the action while the > server waits. > Those two are different in nature, I've never checked werkzeug's > internals but I'm not sure it won't keep the thread busy. I'd keep > those two parts separated. > Running two programs at the same time isn't an issue, in a sh-like > shell you run: > > ./fetcher.py & ./webserver.py & > > or any variation of that, according to your spawner. > You're likely wanting to display the data from the meter as a system > service, i.e. you switch on the beagleboard, you wait an adequate > amount of time and then the system should be working. > How to implement that depends on the operating system that the BB is > running. > > > Maybe I can use some parts of that tutorial and save the data of the > energy meter in the database I have initiazized there? > > The app looks fairly simple from what you described, you want a single > view, in which you load a bunch of data from the db and then pass it > to the template for rendering. I'd use one of the nice js plotting > library out there to plot the data passed. > > Then you either reload the whole page or you could go with a more > refined solution, implement a specific method returning just the > updated data and then just reload the chart via AJAX rather than the > whole page.. It may not be worth the effort it in this case since the > 10 seconds refresh period is quite long and you're not likely to have > more than a couple clients at a time. > > > -- > Andrea > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at davidbaumgold.com Tue Apr 19 08:07:10 2016 From: david at davidbaumgold.com (David Baumgold) Date: Tue, 19 Apr 2016 08:07:10 -0400 Subject: [Flask] Data Logger with flask In-Reply-To: References: <5714DD0F.90301@stud.hs-regensburg.de> Message-ID: I can?t help you with the process of getting data from the energy meter to a database, but for getting the data from the database to the client and streaming updates, you may want to look into server-sent events instead of polling. I?ve written a Flask extension to make server-sent events easy: it?s called Flask-SSE.?https://github.com/singingwolfboy/flask-sse?Please let me know if you decide to use it, and how it could be improved! David Baumgold On April 19, 2016 at 8:01:05 AM, Anthony Ford (ford.anthonyj at gmail.com) wrote: To chime in, Andrea has the right idea. You want to separate your background logger and your web view. If you leverage your SQLAlchemy models right, you can share those in a common package to both applications, or if your SQL is straight-forward, you can skip it and write your own queries. I have a project for work that is this exact same architecture. For continual logging of multiple parameters of the Arecibo Observatory's Cryogenics system, my background process uses PyModbus to poll the industrial microcontroller modules for the parameters, dumps them in a Postgres DB, and my web front-end pulls the DB data and generates live graphs and JSON structures for the API. I originally used Supervisor (http://supervisord.org/) to manage the background process, but I've started to explore using uwsgi to launch it as a worker process. No real progress on that yet. For managing the Polling, I use APScheduler (http://apscheduler.readthedocs.org/en/latest/userguide.html), but that's cause originally I had a more dynamic polling (adjusting rates throughout the day to account for cooler nights and hotter days). I now poll ?every 5 minutes, and could have easily done it with a loop. Good Luck! Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Tue, Apr 19, 2016 at 3:19 AM, Andrea D'Amore wrote: On 18 April 2016 at 15:11, Andreas Dorfner wrote: > Next, I would like to save that data in a database and create a website to edit the informations as a graph or a diagram. > For that, I will use flask, but I'm not sure if flask is the right framework for this project? It depends on what you mean for "right", Flask is certainly capable of doing that. Actually any microframework would be, but with Flask you have a nice ecosystem if you want to add anything later on. I suggest go with Flask, but this is a Flask mailing list so my advice may be biased. > Is it possible to run the webserver for the website and the Pymodbus code in the same Python-File or is it a problem because of the while infinite loop? Maybe it's better to split it to two separate files, one for read data and save it in a database; the second one for the webserver. But how can I link that two files, because I think they have to run simultaneously. You're doing active polling there, while a webserver adheres to a client-server paradigm where the client initiates the action while the server waits. Those two are different in nature, I've never checked werkzeug's internals but I'm not sure it won't keep the thread busy. I'd keep those two parts separated. Running two programs at the same time isn't an issue, in a sh-like shell you run: ? ? ./fetcher.py & ./webserver.py & or any variation of that, according to your spawner. You're likely wanting to display the data from the meter as a system service, i.e. you switch on the beagleboard, you wait an adequate amount of time and then the system should be working. How to implement that depends on the operating system that the BB is running. > Maybe I can use some parts of that tutorial and save the data of the energy meter in the database I have initiazized there? The app looks fairly simple from what you described, you want a single view, in which you load a bunch of data from the db and then pass it to the template for rendering. I'd use one of the nice js plotting library out there to plot the data passed. Then you either reload the whole page or you could go with a more refined solution, implement a specific method returning just the updated data and then just reload the chart via AJAX rather than the whole page.. It may not be worth the effort it in this case since the 10 seconds refresh period is quite long and you're not likely to have more than a couple clients at a time. -- Andrea _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From itetteh34 at hotmail.com Tue Apr 19 09:38:15 2016 From: itetteh34 at hotmail.com (isaac tetteh) Date: Tue, 19 Apr 2016 08:38:15 -0500 Subject: [Flask] Creating a bootstrap table with values from mysql using flask Message-ID: hello guys I am trying to create a bootstrap table with data from MySQL database. I am getting an error local variable data referenced before assignment. Please help my code is as below. app.py code @app.route("viewSingle", methods=['POST','GET']) def Singleview(): if request.method=='POst': if request.form['submit']=="view continent': try: c,conn=connection() c.execut('''SELECT * FROM Continent''') data=c.fetchall() except Error: flash("something wrong happend") finally: c.close() conn.close() return render_template("view.html", data=data) view.html
header1 header2 {%for row in data%} {row[1]} {row [1]}
It seems to not be working I was hoping on getting the value [0] and [1] from the tuple( data= c.fetchall()) into the table but I get the error local variable 'data' referenced before assignment.But if I change the return render_template("view.html", data=data) to he return render_template("view.html") its runs with no error but just that the is empty noting print. Is there a better way to do this or am I missing something. Please advice or help. Thanks Sent from my iPhone From unai at sysbible.org Tue Apr 19 09:48:00 2016 From: unai at sysbible.org (Unai Rodriguez) Date: Tue, 19 Apr 2016 21:48:00 +0800 Subject: [Flask] Creating a bootstrap table with values from mysql using flask In-Reply-To: References: Message-ID: <1461073680.3611084.583258297.72EBD86B@webmail.messagingengine.com> Don't you want to use flask SQL alchemy? The code becomes much cleaner and less error prone. -- unai On Tue, Apr 19, 2016, at 09:38 PM, isaac tetteh wrote: > hello guys I am trying to create a bootstrap table with data from MySQL > database. I am getting an error local variable data referenced before > assignment. Please help my code is as below. > > app.py code > > @app.route("viewSingle", methods=['POST','GET']) > def Singleview(): > if request.method=='POst': > if request.form['submit']=="view continent': > try: > c,conn=connection() > c.execut('''SELECT * FROM Continent''') > data=c.fetchall() > except Error: > flash("something wrong happend") > finally: > c.close() > conn.close() > return render_template("view.html", data=data) > view.html > >
>
POST> > > > > header1 > header2 > > > {%for row in data%} > > > {row[1]} > {row [1]} > > > > >
> > It seems to not be working I was hoping on getting the value [0] and [1] > from the tuple( data= c.fetchall()) into the table but I get the error > local variable 'data' referenced before assignment.But if I change the > return render_template("view.html", data=data) to he return > render_template("view.html") its runs with no error but just that the > is empty noting print. Is there a better way to do this or am I > missing something. Please advice or help. Thanks > > > Sent from my iPhone > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask From kerriden1 at gmail.com Tue Apr 19 10:35:59 2016 From: kerriden1 at gmail.com (Oleksandr Chalyi) Date: Tue, 19 Apr 2016 17:35:59 +0300 Subject: [Flask] Creating a bootstrap table with values from mysql using flask In-Reply-To: <1461073680.3611084.583258297.72EBD86B@webmail.messagingengine.com> References: <1461073680.3611084.583258297.72EBD86B@webmail.messagingengine.com> Message-ID: if request.method=='POst' I believe it should be changed to == 'POST' c.execut('''SELECT * FROM Continent''') change to c.execute('''SELECT * FROM Continent''') But actually, the problem here is that if a request method is not POST, flask goes to return render_template("view.html", data=data), where variable data is not declared. You should declare data before "if request.method == 'POST'" 2016-04-19 16:48 GMT+03:00 Unai Rodriguez : > Don't you want to use flask SQL alchemy? The code becomes much cleaner > and less error prone. > > -- unai > > On Tue, Apr 19, 2016, at 09:38 PM, isaac tetteh wrote: > > hello guys I am trying to create a bootstrap table with data from MySQL > > database. I am getting an error local variable data referenced before > > assignment. Please help my code is as below. > > > > app.py code > > > > @app.route("viewSingle", methods=['POST','GET']) > > def Singleview(): > > if request.method=='POst': > > if request.form['submit']=="view continent': > > try: > > c,conn=connection() > > c.execut('''SELECT * FROM Continent''') > > data=c.fetchall() > > except Error: > > flash("something wrong happend") > > finally: > > c.close() > > conn.close() > > return render_template("view.html", data=data) > > view.html > > > >
> >
> POST> > > > > > > > > header1 > > header2 > > > > > > {%for row in data%} > > > > > > {row[1]} > > {row [1]} > > > > > > > > > >
> > > > It seems to not be working I was hoping on getting the value [0] and [1] > > from the tuple( data= c.fetchall()) into the table but I get the error > > local variable 'data' referenced before assignment.But if I change the > > return render_template("view.html", data=data) to he return > > render_template("view.html") its runs with no error but just that the > > is empty noting print. Is there a better way to do this or am I > > missing something. Please advice or help. Thanks > > > > > > Sent from my iPhone > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Tue Apr 19 10:51:06 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Tue, 19 Apr 2016 10:51:06 -0400 Subject: [Flask] Creating a bootstrap table with values from mysql using flask In-Reply-To: References: <1461073680.3611084.583258297.72EBD86B@webmail.messagingengine.com> Message-ID: Yeah, I just came to the same conclusion. Though given the other typos, that may just be translation error to the email. - At if request.form['submit']=="view continent' , you have mismatched quotes around *view continent. *You have one double and one single quote. - You're also missing a leading slash on the route. - You are missing the {%endfor%} in your template - You should also wrap only the table row in your for loop (within your template), instead of the whole table body. - The url_for in the template has the wrong capitalization ("SingleView" vs "Singleview") - Jinja uses {{ }} instead of { } for printing vars. But I assume most of these are from quickly generating a "sanitized" demo for us to look at. I recommend you use a pastebin or gist next time. Also try and send a full working demo if possible. It makes it easier for someone else to download the files and try things. Good luck! Hope you figure out everything. Trial and error like this is the best way to learn. We've all been there. Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Tue, Apr 19, 2016 at 10:35 AM, Oleksandr Chalyi wrote: > if request.method=='POst' > > I believe it should be changed to == 'POST' > > c.execut('''SELECT * FROM Continent''') > change to > c.execute('''SELECT * FROM Continent''') > > But actually, the problem here is that if a request method is not POST, > flask goes to return render_template("view.html", data=data), where > variable data is not declared. > You should declare data before "if request.method == 'POST'" > > > 2016-04-19 16:48 GMT+03:00 Unai Rodriguez : > >> Don't you want to use flask SQL alchemy? The code becomes much cleaner >> and less error prone. >> >> -- unai >> >> On Tue, Apr 19, 2016, at 09:38 PM, isaac tetteh wrote: >> > hello guys I am trying to create a bootstrap table with data from MySQL >> > database. I am getting an error local variable data referenced before >> > assignment. Please help my code is as below. >> > >> > app.py code >> > >> > @app.route("viewSingle", methods=['POST','GET']) >> > def Singleview(): >> > if request.method=='POst': >> > if request.form['submit']=="view continent': >> > try: >> > c,conn=connection() >> > c.execut('''SELECT * FROM Continent''') >> > data=c.fetchall() >> > except Error: >> > flash("something wrong happend") >> > finally: >> > c.close() >> > conn.close() >> > return render_template("view.html", data=data) >> > view.html >> > >> >
>> >
> > POST> >> > >> > >> > >> > header1 >> > header2 >> > >> > >> > {%for row in data%} >> > >> > >> > {row[1]} >> > {row [1]} >> > >> > >> > >> > >> >
>> > >> > It seems to not be working I was hoping on getting the value [0] and [1] >> > from the tuple( data= c.fetchall()) into the table but I get the error >> > local variable 'data' referenced before assignment.But if I change the >> > return render_template("view.html", data=data) to he return >> > render_template("view.html") its runs with no error but just that the >> > is empty noting print. Is there a better way to do this or am >> I >> > missing something. Please advice or help. Thanks >> > >> > >> > Sent from my iPhone >> > _______________________________________________ >> > Flask mailing list >> > Flask at python.org >> > https://mail.python.org/mailman/listinfo/flask >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From itetteh34 at hotmail.com Tue Apr 19 10:53:55 2016 From: itetteh34 at hotmail.com (isaac tetteh) Date: Tue, 19 Apr 2016 09:53:55 -0500 Subject: [Flask] Creating a bootstrap table with values from mysql using flask In-Reply-To: References: <1461073680.3611084.583258297.72EBD86B@webmail.messagingengine.com> Message-ID: Thanks I think I corrected the spelling. But also what i am trying to do is click a button and when the button is clicked a jQuery code will slide down the table which is is the form tag and the. Access the data from app.run. What do you suggest the validation of the button click should be other thanif request.method=="POST". Is there a better way to do that. Sent from my iPhone > On Apr 19, 2016, at 9:36 AM, Oleksandr Chalyi wrote: > > if request.method=='POst' > > I believe it should be changed to == 'POST' > > c.execut('''SELECT * FROM Continent''') > change to > c.execute('''SELECT * FROM Continent''') > > But actually, the problem here is that if a request method is not POST, flask goes to return render_template("view.html", data=data), where variable data is not declared. > You should declare data before "if request.method == 'POST'" > > > 2016-04-19 16:48 GMT+03:00 Unai Rodriguez : >> Don't you want to use flask SQL alchemy? The code becomes much cleaner >> and less error prone. >> >> -- unai >> >> On Tue, Apr 19, 2016, at 09:38 PM, isaac tetteh wrote: >> > hello guys I am trying to create a bootstrap table with data from MySQL >> > database. I am getting an error local variable data referenced before >> > assignment. Please help my code is as below. >> > >> > app.py code >> > >> > @app.route("viewSingle", methods=['POST','GET']) >> > def Singleview(): >> > if request.method=='POst': >> > if request.form['submit']=="view continent': >> > try: >> > c,conn=connection() >> > c.execut('''SELECT * FROM Continent''') >> > data=c.fetchall() >> > except Error: >> > flash("something wrong happend") >> > finally: >> > c.close() >> > conn.close() >> > return render_template("view.html", data=data) >> > view.html >> > >> >
>> >
> > POST> >> > >> > >> > >> > header1 >> > header2 >> > >> > >> > {%for row in data%} >> > >> > >> > {row[1]} >> > {row [1]} >> > >> > >> > >> > >> >
>> > >> > It seems to not be working I was hoping on getting the value [0] and [1] >> > from the tuple( data= c.fetchall()) into the table but I get the error >> > local variable 'data' referenced before assignment.But if I change the >> > return render_template("view.html", data=data) to he return >> > render_template("view.html") its runs with no error but just that the >> > is empty noting print. Is there a better way to do this or am I >> > missing something. Please advice or help. Thanks >> > >> > >> > Sent from my iPhone >> > _______________________________________________ >> > Flask mailing list >> > Flask at python.org >> > https://mail.python.org/mailman/listinfo/flask >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Tue Apr 19 11:10:15 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Tue, 19 Apr 2016 11:10:15 -0400 Subject: [Flask] Creating a bootstrap table with values from mysql using flask In-Reply-To: References: <1461073680.3611084.583258297.72EBD86B@webmail.messagingengine.com> Message-ID: Two ways to achieve that (though I'm sure there are about a thousand others just as good): One way is to just POST to SingleView, and if there's no POST (i.e. the "Else" branch of the "if request.method"), render a form page with no table. If you do have a POST, render the table and data, or a "No Results" row in the table if there's no data (i.e. a search through the DB with no results). Another is to use jQuery to run an AJAX request in the background, to a separate endpoint. This endpoint (i.e. "/search"), could respond in JSON, and you have jQuery code process the JSON object and build the table. If you go this route, you have to have jQuery capture the click on the "Submit" button, so it doesn't send the form. But this approach means that someone with NoScript or Javascript turned off wouldn't be able to use your form. Both approaches are completely valid. I've used both in different projects, and even both approaches in the same project. It all depends on what you want. The first approach is less... elegant if you will. It will involve a page refresh, and if you are hitting the DB hard (i.e. large query or search through large number of records), the page refresh could seem slower to the user than the jQuery approach. The second is more work and involves more working parts (original view function, ajax endpoint, jQuery code), and if you are unfamiliar with jQuery and JSON, may have a bit of a learning curve on top of the Python/Flask stuff. Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Tue, Apr 19, 2016 at 10:53 AM, isaac tetteh wrote: > Thanks I think I corrected the spelling. But also what i am trying to do > is click a button and when the button is clicked a jQuery code will slide > down the table which is is the form tag and the. Access the data from > app.run. What do you suggest the validation of the button click should be > other thanif request.method=="POST". Is there a better way to do that. > > Sent from my iPhone > > On Apr 19, 2016, at 9:36 AM, Oleksandr Chalyi wrote: > > if request.method=='POst' > > I believe it should be changed to == 'POST' > > c.execut('''SELECT * FROM Continent''') > change to > c.execute('''SELECT * FROM Continent''') > > But actually, the problem here is that if a request method is not POST, > flask goes to return render_template("view.html", data=data), where > variable data is not declared. > You should declare data before "if request.method == 'POST'" > > > 2016-04-19 16:48 GMT+03:00 Unai Rodriguez : > >> Don't you want to use flask SQL alchemy? The code becomes much cleaner >> and less error prone. >> >> -- unai >> >> On Tue, Apr 19, 2016, at 09:38 PM, isaac tetteh wrote: >> > hello guys I am trying to create a bootstrap table with data from MySQL >> > database. I am getting an error local variable data referenced before >> > assignment. Please help my code is as below. >> > >> > app.py code >> > >> > @app.route("viewSingle", methods=['POST','GET']) >> > def Singleview(): >> > if request.method=='POst': >> > if request.form['submit']=="view continent': >> > try: >> > c,conn=connection() >> > c.execut('''SELECT * FROM Continent''') >> > data=c.fetchall() >> > except Error: >> > flash("something wrong happend") >> > finally: >> > c.close() >> > conn.close() >> > return render_template("view.html", data=data) >> > view.html >> > >> >
>> >
> > POST> >> > >> > >> > >> > header1 >> > header2 >> > >> > >> > {%for row in data%} >> > >> > >> > {row[1]} >> > {row [1]} >> > >> > >> > >> > >> >
>> > >> > It seems to not be working I was hoping on getting the value [0] and [1] >> > from the tuple( data= c.fetchall()) into the table but I get the error >> > local variable 'data' referenced before assignment.But if I change the >> > return render_template("view.html", data=data) to he return >> > render_template("view.html") its runs with no error but just that the >> > is empty noting print. Is there a better way to do this or am >> I >> > missing something. Please advice or help. Thanks >> > >> > >> > Sent from my iPhone >> > _______________________________________________ >> > Flask mailing list >> > Flask at python.org >> > https://mail.python.org/mailman/listinfo/flask >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From itetteh34 at hotmail.com Tue Apr 19 11:21:12 2016 From: itetteh34 at hotmail.com (isaac tetteh) Date: Tue, 19 Apr 2016 15:21:12 +0000 Subject: [Flask] Creating a bootstrap table with values from mysql using flask In-Reply-To: References: , <1461073680.3611084.583258297.72EBD86B@webmail.messagingengine.com>, , Message-ID: thanks guys i appreciate all the advice coming up But I dont know alot about Query and Ajax . im just a biginner.T his is the link to the code I'm sure it will help with what i'm doing wrong and how to fix it .Thanks http://pastebin.com/u/itetteh/1 From: ford.anthonyj at gmail.com Date: Tue, 19 Apr 2016 11:10:15 -0400 Subject: Re: [Flask] Creating a bootstrap table with values from mysql using flask To: itetteh34 at hotmail.com CC: kerriden1 at gmail.com; flask at python.org Two ways to achieve that (though I'm sure there are about a thousand others just as good): One way is to just POST to SingleView, and if there's no POST (i.e. the "Else" branch of the "if request.method"), render a form page with no table. If you do have a POST, render the table and data, or a "No Results" row in the table if there's no data (i.e. a search through the DB with no results). Another is to use jQuery to run an AJAX request in the background, to a separate endpoint. This endpoint (i.e. "/search"), could respond in JSON, and you have jQuery code process the JSON object and build the table. If you go this route, you have to have jQuery capture the click on the "Submit" button, so it doesn't send the form. But this approach means that someone with NoScript or Javascript turned off wouldn't be able to use your form. Both approaches are completely valid. I've used both in different projects, and even both approaches in the same project. It all depends on what you want. The first approach is less... elegant if you will. It will involve a page refresh, and if you are hitting the DB hard (i.e. large query or search through large number of records), the page refresh could seem slower to the user than the jQuery approach. The second is more work and involves more working parts (original view function, ajax endpoint, jQuery code), and if you are unfamiliar with jQuery and JSON, may have a bit of a learning curve on top of the Python/Flask stuff. Anthony Ford, KF5IBN,ford.anthonyj at gmail.com On Tue, Apr 19, 2016 at 10:53 AM, isaac tetteh wrote: Thanks I think I corrected the spelling. But also what i am trying to do is click a button and when the button is clicked a jQuery code will slide down the table which is is the form tag and the. Access the data from app.run. What do you suggest the validation of the button click should be other thanif request.method=="POST". Is there a better way to do that. Sent from my iPhone On Apr 19, 2016, at 9:36 AM, Oleksandr Chalyi wrote: if request.method=='POst' I believe it should be changed to == 'POST' c.execut('''SELECT * FROM Continent''') change to c.execute('''SELECT * FROM Continent''') But actually, the problem here is that if a request method is not POST, flask goes to return render_template("view.html", data=data), where variable data is not declared.You should declare data before "if request.method == 'POST'" 2016-04-19 16:48 GMT+03:00 Unai Rodriguez : Don't you want to use flask SQL alchemy? The code becomes much cleaner and less error prone. -- unai On Tue, Apr 19, 2016, at 09:38 PM, isaac tetteh wrote: > hello guys I am trying to create a bootstrap table with data from MySQL > database. I am getting an error local variable data referenced before > assignment. Please help my code is as below. > > app.py code > > @app.route("viewSingle", methods=['POST','GET']) > def Singleview(): > if request.method=='POst': > if request.form['submit']=="view continent': > try: > c,conn=connection() > c.execut('''SELECT * FROM Continent''') > data=c.fetchall() > except Error: > flash("something wrong happend") > finally: > c.close() > conn.close() > return render_template("view.html", data=data) > view.html > >
>
POST> > > > > header1 > header2 > > > {%for row in data%} > > > {row[1]} > {row [1]} > > > > >
> > It seems to not be working I was hoping on getting the value [0] and [1] > from the tuple( data= c.fetchall()) into the table but I get the error > local variable 'data' referenced before assignment.But if I change the > return render_template("view.html", data=data) to he return > render_template("view.html") its runs with no error but just that the > is empty noting print. Is there a better way to do this or am I > missing something. Please advice or help. Thanks > > > Sent from my iPhone > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From kerriden1 at gmail.com Tue Apr 19 11:31:54 2016 From: kerriden1 at gmail.com (Oleksandr Chalyi) Date: Tue, 19 Apr 2016 18:31:54 +0300 Subject: [Flask] Creating a bootstrap table with values from mysql using flask In-Reply-To: References: <1461073680.3611084.583258297.72EBD86B@webmail.messagingengine.com> Message-ID: update the following function to: 1. @app.route("/viewSingle", methods=['POST','GET']) 2. def SingleView(): 3. data = [] 4. if request.method=="POST": 5. if request.form['submit']=="View CONTINENT": 6. c,conn = connection() 7. c.execute('''select * from Country''') 8. data = c.fetchall () 9. c.close () 10. conn.close () 11. return render_template("view.html",data=data) -------------- next part -------------- An HTML attachment was scrubbed... URL: From itetteh34 at hotmail.com Tue Apr 19 12:52:17 2016 From: itetteh34 at hotmail.com (isaac tetteh) Date: Tue, 19 Apr 2016 11:52:17 -0500 Subject: [Flask] Creating a bootstrap table with values from mysql using flask In-Reply-To: References: <1461073680.3611084.583258297.72EBD86B@webmail.messagingengine.com> Message-ID: Wow the error went away but data is empty list. I think that works but the problem is my code doesnt enter when it get to if request.form['submit'] i think i don't have correct code for that side. But how will i know if that specific button is pressed. Thanks Sent from my iPhone > On Apr 19, 2016, at 10:31 AM, Oleksandr Chalyi wrote: > > update the following function to: > > @app.route("/viewSingle", methods=['POST','GET']) > def SingleView(): > data = [] > if request.method=="POST": > if request.form['submit']=="View CONTINENT": > c,conn = connection() > c.execute('''select * from Country''') > data = c.fetchall () > c.close () > conn.close () > return render_template("view.html",data=data) -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Wed Apr 20 14:15:53 2016 From: ahall at autodist.com (Alex Hall) Date: Wed, 20 Apr 2016 14:15:53 -0400 Subject: [Flask] Getting values of Flask-WTF SelectMultipleField? Message-ID: Hello list, I've only been using Flask for a few days, but I'm really likeing it so far. My one question is how to deal with multiple select fields. I can get the value of standard inputs with request.form["fieldName"] but I can't figure out what to do about multiple select fields. I've googled the topic several different ways, but the only clear answer I found suggested using request.form.selectListName.data which doesn't do anything. I need to get the selected values as a list to pass to a database lookup function. For instance, the function expects ["v1", "v2", "v3"]. What's the trick to accessing the selected values of this kind of field? Thanks! -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidism at gmail.com Wed Apr 20 14:20:23 2016 From: davidism at gmail.com (David Lord) Date: Wed, 20 Apr 2016 11:20:23 -0700 Subject: [Flask] Getting values of Flask-WTF SelectMultipleField? In-Reply-To: References: Message-ID: <5717C867.9060603@gmail.com> The same name is supplied multiple times with select multiple fields (and this can be done with other fields as well). Use |request.form.getlist(name)| to get all values for the given name. You found an example using Flask-WTF or just straight WTForms and conflated it with |request.form| when it was really referring to |form| as in ?an instance of a |Form|?. On 04/20/2016 11:15 AM, Alex Hall wrote: > Hello list, > I've only been using Flask for a few days, but I'm really likeing it > so far. My one question is how to deal with multiple select fields. I > can get the value of standard inputs with > request.form["fieldName"] > but I can't figure out what to do about multiple select fields. I've > googled the topic several different ways, but the only clear answer I > found suggested using > request.form.selectListName.data > which doesn't do anything. > > I need to get the selected values as a list to pass to a database > lookup function. For instance, the function expects ["v1", "v2", > "v3"]. What's the trick to accessing the selected values of this kind > of field? Thanks! > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidism at gmail.com Wed Apr 20 14:21:34 2016 From: davidism at gmail.com (David Lord) Date: Wed, 20 Apr 2016 11:21:34 -0700 Subject: [Flask] Getting values of Flask-WTF SelectMultipleField? In-Reply-To: <5717C867.9060603@gmail.com> References: <5717C867.9060603@gmail.com> Message-ID: <5717C8AE.6000800@gmail.com> And speaking of Flask-WTF, you should use that, as it handles multiple values and many other things for you. On 04/20/2016 11:20 AM, David Lord wrote: > > The same name is supplied multiple times with select multiple fields > (and this can be done with other fields as well). Use > |request.form.getlist(name)| to get all values for the given name. > > You found an example using Flask-WTF or just straight WTForms and > conflated it with |request.form| when it was really referring to > |form| as in ?an instance of a |Form|?. > > On 04/20/2016 11:15 AM, Alex Hall wrote: > >> Hello list, >> I've only been using Flask for a few days, but I'm really likeing it >> so far. My one question is how to deal with multiple select fields. I >> can get the value of standard inputs with >> request.form["fieldName"] >> but I can't figure out what to do about multiple select fields. I've >> googled the topic several different ways, but the only clear answer I >> found suggested using >> request.form.selectListName.data >> which doesn't do anything. >> >> I need to get the selected values as a list to pass to a database >> lookup function. For instance, the function expects ["v1", "v2", >> "v3"]. What's the trick to accessing the selected values of this kind >> of field? Thanks! >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask > ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Wed Apr 20 14:54:03 2016 From: ahall at autodist.com (Alex Hall) Date: Wed, 20 Apr 2016 14:54:03 -0400 Subject: [Flask] Getting values of Flask-WTF SelectMultipleField? In-Reply-To: <5717C8AE.6000800@gmail.com> References: <5717C867.9060603@gmail.com> <5717C8AE.6000800@gmail.com> Message-ID: Thanks for the clarification. I used print request.form.getlist("users") but only got two empty lists (that is, []). I'm selecting users logged in when packages were processed at the company where I work. That is, which user did the processing for a given package. I want people to be able to check any users they want to include, to see only packages from those users. The function I have that queries the database expects a list of users, each user as a string. My selection list is set up this way, in my form class: usernames = ["u1", "u2", "u3", "u4"] users = SelectMultipleField("Users", choices=[(u, u) for u in userNames]) Then, in my template: {{form.users(rows=6, multiple=True)}} In the function handling this form's input (technically an Ajax handler, not a view, but it comes to the same thing): @app.route("/orderLookup", methods=searchMethods) def getOrderSearchResults(): results = [] print request.form.getlist("users") for result in DBInterface.getOrderDetails(orderNumber=request.form["orderNumber"]): results.append({ "name": result.user, "orderNumber": result.reference_3 }) return json.dumps(results) Of course, I'll want to add the users list to the database lookup function once I can figure out how to access said list. Hopefully that clarifies things. On Wed, Apr 20, 2016 at 2:21 PM, David Lord wrote: > And speaking of Flask-WTF, you should use that, as it handles multiple > values and many other things for you. > > > On 04/20/2016 11:20 AM, David Lord wrote: > > The same name is supplied multiple times with select multiple fields (and > this can be done with other fields as well). Use > request.form.getlist(name) to get all values for the given name. > > You found an example using Flask-WTF or just straight WTForms and > conflated it with request.form when it was really referring to form as in > ?an instance of a Form?. > > On 04/20/2016 11:15 AM, Alex Hall wrote: > > Hello list, > I've only been using Flask for a few days, but I'm really likeing it so > far. My one question is how to deal with multiple select fields. I can get > the value of standard inputs with > request.form["fieldName"] > but I can't figure out what to do about multiple select fields. I've > googled the topic several different ways, but the only clear answer I found > suggested using > request.form.selectListName.data > which doesn't do anything. > > I need to get the selected values as a list to pass to a database lookup > function. For instance, the function expects ["v1", "v2", "v3"]. What's the > trick to accessing the selected values of this kind of field? Thanks! > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > > _______________________________________________ > Flask mailing listFlask at python.orghttps://mail.python.org/mailman/listinfo/flask > > ? > > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Wed Apr 20 15:10:09 2016 From: ahall at autodist.com (Alex Hall) Date: Wed, 20 Apr 2016 15:10:09 -0400 Subject: [Flask] Getting values of Flask-WTF SelectMultipleField? In-Reply-To: References: <5717C867.9060603@gmail.com> <5717C8AE.6000800@gmail.com> Message-ID: A small correction: I get one empty list, not two. As I think about this more, do I need to set the id of each option element somehow? If all of them were the same, that would make getlist("optionID") work, wouldn't it? Is that the secret? I don't know if I can do that, since the options are built from a list of tuples (value, text) as far as I understand it. On Wed, Apr 20, 2016 at 2:54 PM, Alex Hall wrote: > Thanks for the clarification. I used > print request.form.getlist("users") > but only got two empty lists (that is, []). > > I'm selecting users logged in when packages were processed at the company > where I work. That is, which user did the processing for a given package. I > want people to be able to check any users they want to include, to see only > packages from those users. The function I have that queries the database > expects a list of users, each user as a string. My selection list is set up > this way, in my form class: > > usernames = ["u1", "u2", "u3", "u4"] > users = SelectMultipleField("Users", choices=[(u, u) for u in userNames]) > > Then, in my template: > > {{form.users(rows=6, multiple=True)}} > > In the function handling this form's input (technically an Ajax handler, > not a view, but it comes to the same thing): > > @app.route("/orderLookup", methods=searchMethods) > def getOrderSearchResults(): > results = [] > print request.form.getlist("users") > for result in > DBInterface.getOrderDetails(orderNumber=request.form["orderNumber"]): > results.append({ > "name": result.user, > "orderNumber": result.reference_3 > }) > return json.dumps(results) > > Of course, I'll want to add the users list to the database lookup function > once I can figure out how to access said list. Hopefully that clarifies > things. > > On Wed, Apr 20, 2016 at 2:21 PM, David Lord wrote: > >> And speaking of Flask-WTF, you should use that, as it handles multiple >> values and many other things for you. >> >> >> On 04/20/2016 11:20 AM, David Lord wrote: >> >> The same name is supplied multiple times with select multiple fields (and >> this can be done with other fields as well). Use >> request.form.getlist(name) to get all values for the given name. >> >> You found an example using Flask-WTF or just straight WTForms and >> conflated it with request.form when it was really referring to form as >> in ?an instance of a Form?. >> >> On 04/20/2016 11:15 AM, Alex Hall wrote: >> >> Hello list, >> I've only been using Flask for a few days, but I'm really likeing it so >> far. My one question is how to deal with multiple select fields. I can get >> the value of standard inputs with >> request.form["fieldName"] >> but I can't figure out what to do about multiple select fields. I've >> googled the topic several different ways, but the only clear answer I found >> suggested using >> request.form.selectListName.data >> which doesn't do anything. >> >> I need to get the selected values as a list to pass to a database lookup >> function. For instance, the function expects ["v1", "v2", "v3"]. What's the >> trick to accessing the selected values of this kind of field? Thanks! >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> >> _______________________________________________ >> Flask mailing listFlask at python.orghttps://mail.python.org/mailman/listinfo/flask >> >> ? >> >> >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Wed Apr 20 16:31:01 2016 From: ahall at autodist.com (Alex Hall) Date: Wed, 20 Apr 2016 16:31:01 -0400 Subject: [Flask] Using Flask with Apache2.4 on Windows 7? Message-ID: Hello list, The other major difficulty I'm running into is getting Apache to host my Flask project. I have WAMP installed on Windows 7 64-bit, which gives me Apache2.4 The instructions from Flask's site say to use Mod_WSGI, and offer a link to setup instructions. However, the Flask docs then state that the linked page is Unix-only, and offer nothing for Windows. I went to the page on the off chance that I could gleen something useful, and found that it's only for Apache 2.2 or below. I've searched out how to install Mod_WSGI on Apache2.4, and only been able to find confusing instructions. For instance, one page said I'd need to know the version, not of Apache, but of the MS compiler that was used to generate my version of Apache. Others point me to download pages, but I'm never able to find installers or scripts for Apache2.4 and Python2.7. What's the trick to getting Flask hosted by Apache2.4 under Windows 7? I can't use a shared or cloud server, because this project is an intranet one that must be on my work's local network to talk to the databases I'm querying. It'll have to be hosted under either IIS or Apache, and I really dislike IIS. Hopefully this is possible and I've just managed to miss the instructions that will reveal the secrets. If anyone has any suggestions, I'd greatly appreciate hearing them. Thanks in advance! -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidism at gmail.com Wed Apr 20 16:48:21 2016 From: davidism at gmail.com (David Lord) Date: Wed, 20 Apr 2016 13:48:21 -0700 Subject: [Flask] Using Flask with Apache2.4 on Windows 7? In-Reply-To: References: Message-ID: <5717EB15.9060803@gmail.com> The docs link to this : Occassionally precompiled binaries will be made available for mod_wsgi. These may not be updated on every release because more often than not code changes are being made which relate only to mod_wsgi daemon mode, or mod_wsgi-express, neither of which are available for Windows. When pre-compiled mod_wsgi binaries are made available they will be downloadable from the github release page for the mod_wsgi project at https://github.com/GrahamDumpleton/mod_wsgi/releases. Look back at older releases if the most current version doesn?t have them associated with it. Looking at the latest release on the linked page shows that the last Windows builds needed generating for the 4.4.12 release , which has a Windows download link. Within that archive you would extract |/Apache24-win32-VC9/modules/mod_wsgi-py27-VC9.so|. (Assuming you?re using the 32-bit install which is the default on Windows.) On 04/20/2016 01:31 PM, Alex Hall wrote: > Hello list, > The other major difficulty I'm running into is getting Apache to host > my Flask project. I have WAMP installed on Windows 7 64-bit, which > gives me Apache2.4 > > The instructions from Flask's site say to use Mod_WSGI, and offer a > link to setup instructions. However, the Flask docs then state that > the linked page is Unix-only, and offer nothing for Windows. I went to > the page on the off chance that I could gleen something useful, and > found that it's only for Apache 2.2 or below. I've searched out how to > install Mod_WSGI on Apache2.4, and only been able to find confusing > instructions. For instance, one page said I'd need to know the > version, not of Apache, but of the MS compiler that was used to > generate my version of Apache. Others point me to download pages, but > I'm never able to find installers or scripts for Apache2.4 and Python2.7. > > What's the trick to getting Flask hosted by Apache2.4 under Windows 7? > I can't use a shared or cloud server, because this project is an > intranet one that must be on my work's local network to talk to the > databases I'm querying. It'll have to be hosted under either IIS or > Apache, and I really dislike IIS. Hopefully this is possible and I've > just managed to miss the instructions that will reveal the secrets. If > anyone has any suggestions, I'd greatly appreciate hearing them. > Thanks in advance! > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Wed Apr 20 17:10:39 2016 From: ahall at autodist.com (Alex Hall) Date: Wed, 20 Apr 2016 17:10:39 -0400 Subject: [Flask] Using Flask with Apache2.4 on Windows 7? In-Reply-To: <5717EB15.9060803@gmail.com> References: <5717EB15.9060803@gmail.com> Message-ID: Thanks. I'd looked on that page, but couldn't remember why it failed. Now, having tried it again, I do. I'm on 64-bit Windows, which the readme for Windows (linked to on the page you sent) says is problematic. I followed the instructions, but when Apache starts, it gives me an error that mod_wsgi.so is not a valid win32 application. Plus, the Windows readme is full of warnings, caviats, and the like. Is there a web server that is as robust as Apache, but that is more friendly to Flask? I've never had so much trouble getting Python to work, and that counts trying to use Py2Exe on an app that uses WX. :) On Wed, Apr 20, 2016 at 4:48 PM, David Lord wrote: > The docs > link to this > > : > > Occassionally precompiled binaries will be made available for mod_wsgi. > These may not be updated on every release because more often than not code > changes are being made which relate only to mod_wsgi daemon mode, or > mod_wsgi-express, neither of which are available for Windows. > > When pre-compiled mod_wsgi binaries are made available they will be > downloadable from the github release page for the mod_wsgi project at > > https://github.com/GrahamDumpleton/mod_wsgi/releases. > > Look back at older releases if the most current version doesn?t have them > associated with it. > > Looking at the latest release on the linked page shows that the last > Windows builds needed generating for the 4.4.12 release > , which > has a Windows download link. Within that archive you would extract > /Apache24-win32-VC9/modules/mod_wsgi-py27-VC9.so. (Assuming you?re using > the 32-bit install which is the default on Windows.) > > On 04/20/2016 01:31 PM, Alex Hall wrote: > > Hello list, > The other major difficulty I'm running into is getting Apache to host my > Flask project. I have WAMP installed on Windows 7 64-bit, which gives me > Apache2.4 > > The instructions from Flask's site say to use Mod_WSGI, and offer a link > to setup instructions. However, the Flask docs then state that the linked > page is Unix-only, and offer nothing for Windows. I went to the page on the > off chance that I could gleen something useful, and found that it's only > for Apache 2.2 or below. I've searched out how to install Mod_WSGI on > Apache2.4, and only been able to find confusing instructions. For instance, > one page said I'd need to know the version, not of Apache, but of the MS > compiler that was used to generate my version of Apache. Others point me to > download pages, but I'm never able to find installers or scripts for > Apache2.4 and Python2.7. > > What's the trick to getting Flask hosted by Apache2.4 under Windows 7? I > can't use a shared or cloud server, because this project is an intranet one > that must be on my work's local network to talk to the databases I'm > querying. It'll have to be hosted under either IIS or Apache, and I really > dislike IIS. Hopefully this is possible and I've just managed to miss the > instructions that will reveal the secrets. If anyone has any suggestions, > I'd greatly appreciate hearing them. Thanks in advance! > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > > _______________________________________________ > Flask mailing listFlask at python.orghttps://mail.python.org/mailman/listinfo/flask > > ? > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Wed Apr 20 17:25:19 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Wed, 20 Apr 2016 17:25:19 -0400 Subject: [Flask] Using Flask with Apache2.4 on Windows 7? In-Reply-To: References: <5717EB15.9060803@gmail.com> Message-ID: Nginx is an option, but it's preferred approach is to run your app in uwsgi, which is not windows friendly. Perhaps with some effort you could get it running? How about a VM? Could you prop up a really light linux VM on the machine in question? Then you could run Apache or Nginx on a more widely supported platform. You could simply port-bind the required ports (80 & whatever your DB needs) and it would be nearly seamless to the outside. Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Wed, Apr 20, 2016 at 5:10 PM, Alex Hall wrote: > Thanks. I'd looked on that page, but couldn't remember why it failed. Now, > having tried it again, I do. I'm on 64-bit Windows, which the readme for > Windows (linked to on the page you sent) says is problematic. I followed > the instructions, but when Apache starts, it gives me an error that > mod_wsgi.so is not a valid win32 application. Plus, the Windows readme is > full of warnings, caviats, and the like. > > Is there a web server that is as robust as Apache, but that is more > friendly to Flask? I've never had so much trouble getting Python to work, > and that counts trying to use Py2Exe on an app that uses WX. :) > > On Wed, Apr 20, 2016 at 4:48 PM, David Lord wrote: > >> The docs >> link to this >> >> : >> >> Occassionally precompiled binaries will be made available for mod_wsgi. >> These may not be updated on every release because more often than not code >> changes are being made which relate only to mod_wsgi daemon mode, or >> mod_wsgi-express, neither of which are available for Windows. >> >> When pre-compiled mod_wsgi binaries are made available they will be >> downloadable from the github release page for the mod_wsgi project at >> >> https://github.com/GrahamDumpleton/mod_wsgi/releases. >> >> Look back at older releases if the most current version doesn?t have them >> associated with it. >> >> Looking at the latest release on the linked page shows that the last >> Windows builds needed generating for the 4.4.12 release >> , which >> has a Windows download link. Within that archive you would extract >> /Apache24-win32-VC9/modules/mod_wsgi-py27-VC9.so. (Assuming you?re using >> the 32-bit install which is the default on Windows.) >> >> On 04/20/2016 01:31 PM, Alex Hall wrote: >> >> Hello list, >> The other major difficulty I'm running into is getting Apache to host my >> Flask project. I have WAMP installed on Windows 7 64-bit, which gives me >> Apache2.4 >> >> The instructions from Flask's site say to use Mod_WSGI, and offer a link >> to setup instructions. However, the Flask docs then state that the linked >> page is Unix-only, and offer nothing for Windows. I went to the page on the >> off chance that I could gleen something useful, and found that it's only >> for Apache 2.2 or below. I've searched out how to install Mod_WSGI on >> Apache2.4, and only been able to find confusing instructions. For instance, >> one page said I'd need to know the version, not of Apache, but of the MS >> compiler that was used to generate my version of Apache. Others point me to >> download pages, but I'm never able to find installers or scripts for >> Apache2.4 and Python2.7. >> >> What's the trick to getting Flask hosted by Apache2.4 under Windows 7? I >> can't use a shared or cloud server, because this project is an intranet one >> that must be on my work's local network to talk to the databases I'm >> querying. It'll have to be hosted under either IIS or Apache, and I really >> dislike IIS. Hopefully this is possible and I've just managed to miss the >> instructions that will reveal the secrets. If anyone has any suggestions, >> I'd greatly appreciate hearing them. Thanks in advance! >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> >> _______________________________________________ >> Flask mailing listFlask at python.orghttps://mail.python.org/mailman/listinfo/flask >> >> ? >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Wed Apr 20 21:21:32 2016 From: ahall at autodist.com (Alex Hall) Date: Wed, 20 Apr 2016 21:21:32 -0400 Subject: [Flask] Using Flask with Apache2.4 on Windows 7? In-Reply-To: References: <5717EB15.9060803@gmail.com> Message-ID: So, Apache on Windows isn't the best idea, and it's not just that I'm missing something? That's good to know. Well, it's frustrating, but at least I know it's not me missing the obvious. I'm considering a Raspberry Pi, so it can always be on. My test machine sleeps at night and isn't the most capable--an old Dell--so a dedicated, small device seems a good option. This is an intranet-only site for my work, so it has to be up as much as possible but won't see heavy traffic. Is the Raspi a valid option for hosting Flask? Is there a Linux distort that can do the job better, running in a VM? Or will any Linux do the job? > On Apr 20, 2016, at 17:25, Anthony Ford wrote: > > Nginx is an option, but it's preferred approach is to run your app in uwsgi, which is not windows friendly. > > Perhaps with some effort you could get it running? > > How about a VM? Could you prop up a really light linux VM on the machine in question? Then you could run Apache or Nginx on a more widely supported platform. You could simply port-bind the required ports (80 & whatever your DB needs) and it would be nearly seamless to the outside. > > > Anthony Ford, > KF5IBN, > ford.anthonyj at gmail.com > On Wed, Apr 20, 2016 at 5:10 PM, Alex Hall > wrote: > Thanks. I'd looked on that page, but couldn't remember why it failed. Now, having tried it again, I do. I'm on 64-bit Windows, which the readme for Windows (linked to on the page you sent) says is problematic. I followed the instructions, but when Apache starts, it gives me an error that mod_wsgi.so is not a valid win32 application. Plus, the Windows readme is full of warnings, caviats, and the like. > > Is there a web server that is as robust as Apache, but that is more friendly to Flask? I've never had so much trouble getting Python to work, and that counts trying to use Py2Exe on an app that uses WX. :) > > On Wed, Apr 20, 2016 at 4:48 PM, David Lord > wrote: > The docs link to this : > > Occassionally precompiled binaries will be made available for mod_wsgi. These may not be updated on every release because more often than not code changes are being made which relate only to mod_wsgi daemon mode, or mod_wsgi-express, neither of which are available for Windows. > > When pre-compiled mod_wsgi binaries are made available they will be downloadable from the github release page for the mod_wsgi project at https://github.com/GrahamDumpleton/mod_wsgi/releases . > > Look back at older releases if the most current version doesn?t have them associated with it. > > Looking at the latest release on the linked page shows that the last Windows builds needed generating for the 4.4.12 release , which has a Windows download link. Within that archive you would extract /Apache24-win32-VC9/modules/mod_wsgi-py27-VC9.so. (Assuming you?re using the 32-bit install which is the default on Windows.) > > On 04/20/2016 01:31 PM, Alex Hall wrote: > > > >> Hello list, >> The other major difficulty I'm running into is getting Apache to host my Flask project. I have WAMP installed on Windows 7 64-bit, which gives me Apache2.4 >> >> The instructions from Flask's site say to use Mod_WSGI, and offer a link to setup instructions. However, the Flask docs then state that the linked page is Unix-only, and offer nothing for Windows. I went to the page on the off chance that I could gleen something useful, and found that it's only for Apache 2.2 or below. I've searched out how to install Mod_WSGI on Apache2.4, and only been able to find confusing instructions. For instance, one page said I'd need to know the version, not of Apache, but of the MS compiler that was used to generate my version of Apache. Others point me to download pages, but I'm never able to find installers or scripts for Apache2.4 and Python2.7. >> >> What's the trick to getting Flask hosted by Apache2.4 under Windows 7? I can't use a shared or cloud server, because this project is an intranet one that must be on my work's local network to talk to the databases I'm querying. It'll have to be hosted under either IIS or Apache, and I really dislike IIS. Hopefully this is possible and I've just managed to miss the instructions that will reveal the secrets. If anyone has any suggestions, I'd greatly appreciate hearing them. Thanks in advance! >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask > > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Wed Apr 20 23:49:30 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Wed, 20 Apr 2016 23:49:30 -0400 Subject: [Flask] Using Flask with Apache2.4 on Windows 7? In-Reply-To: References: <5717EB15.9060803@gmail.com> Message-ID: I would say any really. There's a lot of guides for Ubuntu, so I'd go with them if you aren't familiar with Linux. As for the raspberry Pi, I'd say go for it. If it's a fairly straightforward site, it shouldn't be a problem. If your supporting a few hundred users per minute it might be a problem, but that doesn't sound like your case. I've had issues with sd card corruption, but that's usually only with power instability. But once you get things configured, it's easy to clone the sd card. This works great if your db isn't on the pi (which it sounds like it isn't). Then there shouldn't be any issues with keeping things backed up. But any system can potentially be a good Linux box. I ran my webserver and remote file server off an old Pentium 4 laptop running Debian for like 4 years. -- Anthony Ford On Apr 20, 2016 9:21 PM, "Alex Hall" wrote: > So, Apache on Windows isn't the best idea, and it's not just that I'm > missing something? That's good to know. Well, it's frustrating, but at > least I know it's not me missing the obvious. I'm considering a Raspberry > Pi, so it can always be on. My test machine sleeps at night and isn't the > most capable--an old Dell--so a dedicated, small device seems a good > option. This is an intranet-only site for my work, so it has to be up as > much as possible but won't see heavy traffic. Is the Raspi a valid option > for hosting Flask? Is there a Linux distort that can do the job better, > running in a VM? Or will any Linux do the job? > > On Apr 20, 2016, at 17:25, Anthony Ford wrote: > > Nginx is an option, but it's preferred approach is to run your app in > uwsgi, which is not windows friendly. > > Perhaps with some effort you could get it running? > > How about a VM? Could you prop up a really light linux VM on the machine > in question? Then you could run Apache or Nginx on a more widely supported > platform. You could simply port-bind the required ports (80 & whatever your > DB needs) and it would be nearly seamless to the outside. > > > Anthony Ford, > KF5IBN, > ford.anthonyj at gmail.com > > On Wed, Apr 20, 2016 at 5:10 PM, Alex Hall wrote: > >> Thanks. I'd looked on that page, but couldn't remember why it failed. >> Now, having tried it again, I do. I'm on 64-bit Windows, which the readme >> for Windows (linked to on the page you sent) says is problematic. I >> followed the instructions, but when Apache starts, it gives me an error >> that mod_wsgi.so is not a valid win32 application. Plus, the Windows readme >> is full of warnings, caviats, and the like. >> >> Is there a web server that is as robust as Apache, but that is more >> friendly to Flask? I've never had so much trouble getting Python to work, >> and that counts trying to use Py2Exe on an app that uses WX. :) >> >> On Wed, Apr 20, 2016 at 4:48 PM, David Lord wrote: >> >>> The docs >>> link to this >>> >>> : >>> >>> Occassionally precompiled binaries will be made available for mod_wsgi. >>> These may not be updated on every release because more often than not code >>> changes are being made which relate only to mod_wsgi daemon mode, or >>> mod_wsgi-express, neither of which are available for Windows. >>> >>> When pre-compiled mod_wsgi binaries are made available they will be >>> downloadable from the github release page for the mod_wsgi project at >>> >>> https://github.com/GrahamDumpleton/mod_wsgi/releases. >>> >>> Look back at older releases if the most current version doesn?t have >>> them associated with it. >>> >>> Looking at the latest release on the linked page shows that the last >>> Windows builds needed generating for the 4.4.12 release >>> , >>> which has a Windows download link. Within that archive you would extract >>> /Apache24-win32-VC9/modules/mod_wsgi-py27-VC9.so. (Assuming you?re >>> using the 32-bit install which is the default on Windows.) >>> >>> On 04/20/2016 01:31 PM, Alex Hall wrote: >>> >>> >>> Hello list, >>> The other major difficulty I'm running into is getting Apache to host my >>> Flask project. I have WAMP installed on Windows 7 64-bit, which gives me >>> Apache2.4 >>> >>> The instructions from Flask's site say to use Mod_WSGI, and offer a link >>> to setup instructions. However, the Flask docs then state that the linked >>> page is Unix-only, and offer nothing for Windows. I went to the page on the >>> off chance that I could gleen something useful, and found that it's only >>> for Apache 2.2 or below. I've searched out how to install Mod_WSGI on >>> Apache2.4, and only been able to find confusing instructions. For instance, >>> one page said I'd need to know the version, not of Apache, but of the MS >>> compiler that was used to generate my version of Apache. Others point me to >>> download pages, but I'm never able to find installers or scripts for >>> Apache2.4 and Python2.7. >>> >>> What's the trick to getting Flask hosted by Apache2.4 under Windows 7? I >>> can't use a shared or cloud server, because this project is an intranet one >>> that must be on my work's local network to talk to the databases I'm >>> querying. It'll have to be hosted under either IIS or Apache, and I really >>> dislike IIS. Hopefully this is possible and I've just managed to miss the >>> instructions that will reveal the secrets. If anyone has any suggestions, >>> I'd greatly appreciate hearing them. Thanks in advance! >>> >>> -- >>> Alex Hall >>> Automatic Distributors, IT department >>> ahall at autodist.com >>> >>> >>> _______________________________________________ >>> Flask mailing listFlask at python.orghttps://mail.python.org/mailman/listinfo/flask >>> >>> >>> >>> ? >>> >>> _______________________________________________ >>> Flask mailing list >>> Flask at python.org >>> https://mail.python.org/mailman/listinfo/flask >>> >>> >> >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Thu Apr 21 08:13:13 2016 From: ahall at autodist.com (Alex Hall) Date: Thu, 21 Apr 2016 08:13:13 -0400 Subject: [Flask] Access form data in view function Message-ID: Hello all, Further to my question about multiple select fields yesterday, how does a view function access form data in general? I know I use the global(?) request object's "form" property, but beyond that I'm not sure. I can access StringField values (I'm using WTF) by using request.form.fieldID. But single select fields, multiple select fields, the status of checkboxes or radio buttons, and so on I can't work out or find online. One resource said, for checkboxes, to use request.form.getlist("checkboxID"), but that gave me an empty list despite that checkbox being checked. What am I missing? I know people usually use validators, but I need the values and statuses of elements in my form-processing view function because I'm dynamically constructing an SQL query based on the form's information. -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Thu Apr 21 08:21:15 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Thu, 21 Apr 2016 08:21:15 -0400 Subject: [Flask] Access form data in view function In-Reply-To: References: Message-ID: Have you tried using Python's dir builtin on the form object inside the request object? On Thu, Apr 21, 2016 at 8:13 AM, Alex Hall wrote: > Hello all, > Further to my question about multiple select fields yesterday, how does a > view function access form data in general? I know I use the global(?) > request object's "form" property, but beyond that I'm not sure. I can access > StringField values (I'm using WTF) by using request.form.fieldID. But single > select fields, multiple select fields, the status of checkboxes or radio > buttons, and so on I can't work out or find online. One resource said, for > checkboxes, to use request.form.getlist("checkboxID"), but that gave me an > empty list despite that checkbox being checked. What am I missing? I know > people usually use validators, but I need the values and statuses of > elements in my form-processing view function because I'm dynamically > constructing an SQL query based on the form's information. > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > From ahall at autodist.com Thu Apr 21 08:33:09 2016 From: ahall at autodist.com (Alex Hall) Date: Thu, 21 Apr 2016 08:33:09 -0400 Subject: [Flask] Access form data in view function In-Reply-To: References: Message-ID: No, but that was a good idea. It gave me all the built-in functions, and I saw "values" among them. When I print request.form.values, I see only 'orderNumber' (my text field) and u''. I should see at least my checkbox, which I made sure to uncheck the first time and check the second time, but I don't. I also double checked my template, and the source of the webpage in Firefox, but all elements are definitely inside the form element. Does "values" do something other than what I'm thinking, or does this mean my form is somehow missing the rest of its fields? On Thu, Apr 21, 2016 at 8:21 AM, Corey Boyle wrote: > Have you tried using Python's dir builtin on the form object inside > the request object? > > On Thu, Apr 21, 2016 at 8:13 AM, Alex Hall wrote: > > Hello all, > > Further to my question about multiple select fields yesterday, how does a > > view function access form data in general? I know I use the global(?) > > request object's "form" property, but beyond that I'm not sure. I can > access > > StringField values (I'm using WTF) by using request.form.fieldID. But > single > > select fields, multiple select fields, the status of checkboxes or radio > > buttons, and so on I can't work out or find online. One resource said, > for > > checkboxes, to use request.form.getlist("checkboxID"), but that gave me > an > > empty list despite that checkbox being checked. What am I missing? I know > > people usually use validators, but I need the values and statuses of > > elements in my form-processing view function because I'm dynamically > > constructing an SQL query based on the form's information. > > > > -- > > Alex Hall > > Automatic Distributors, IT department > > ahall at autodist.com > > > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > > > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Thu Apr 21 09:07:49 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Thu, 21 Apr 2016 09:07:49 -0400 Subject: [Flask] Access form data in view function In-Reply-To: References: Message-ID: Paste your latest HTML into a pastebin so we can see it. On Thu, Apr 21, 2016 at 8:33 AM, Alex Hall wrote: > No, but that was a good idea. It gave me all the built-in functions, and I > saw "values" among them. When I print request.form.values, I see only > 'orderNumber' (my text field) and u''. I should see at least my checkbox, > which I made sure to uncheck the first time and check the second time, but I > don't. I also double checked my template, and the source of the webpage in > Firefox, but all elements are definitely inside the form element. Does > "values" do something other than what I'm thinking, or does this mean my > form is somehow missing the rest of its fields? > > On Thu, Apr 21, 2016 at 8:21 AM, Corey Boyle wrote: >> >> Have you tried using Python's dir builtin on the form object inside >> the request object? >> >> On Thu, Apr 21, 2016 at 8:13 AM, Alex Hall wrote: >> > Hello all, >> > Further to my question about multiple select fields yesterday, how does >> > a >> > view function access form data in general? I know I use the global(?) >> > request object's "form" property, but beyond that I'm not sure. I can >> > access >> > StringField values (I'm using WTF) by using request.form.fieldID. But >> > single >> > select fields, multiple select fields, the status of checkboxes or radio >> > buttons, and so on I can't work out or find online. One resource said, >> > for >> > checkboxes, to use request.form.getlist("checkboxID"), but that gave me >> > an >> > empty list despite that checkbox being checked. What am I missing? I >> > know >> > people usually use validators, but I need the values and statuses of >> > elements in my form-processing view function because I'm dynamically >> > constructing an SQL query based on the form's information. >> > >> > -- >> > Alex Hall >> > Automatic Distributors, IT department >> > ahall at autodist.com >> > >> > _______________________________________________ >> > Flask mailing list >> > Flask at python.org >> > https://mail.python.org/mailman/listinfo/flask >> > > > > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com From ahall at autodist.com Thu Apr 21 09:19:30 2016 From: ahall at autodist.com (Alex Hall) Date: Thu, 21 Apr 2016 09:19:30 -0400 Subject: [Flask] Access form data in view function In-Reply-To: References: Message-ID: I hope I've done this right. I've never used that site, and it's a bit difficult to use with a screen reader. This should link to the html generated by my template and form class. http://pastebin.com/edttHiV7 On Thu, Apr 21, 2016 at 9:07 AM, Corey Boyle wrote: > Paste your latest HTML into a pastebin so we can see it. > > On Thu, Apr 21, 2016 at 8:33 AM, Alex Hall wrote: > > No, but that was a good idea. It gave me all the built-in functions, and > I > > saw "values" among them. When I print request.form.values, I see only > > 'orderNumber' (my text field) and u''. I should see at least my checkbox, > > which I made sure to uncheck the first time and check the second time, > but I > > don't. I also double checked my template, and the source of the webpage > in > > Firefox, but all elements are definitely inside the form element. Does > > "values" do something other than what I'm thinking, or does this mean my > > form is somehow missing the rest of its fields? > > > > On Thu, Apr 21, 2016 at 8:21 AM, Corey Boyle > wrote: > >> > >> Have you tried using Python's dir builtin on the form object inside > >> the request object? > >> > >> On Thu, Apr 21, 2016 at 8:13 AM, Alex Hall wrote: > >> > Hello all, > >> > Further to my question about multiple select fields yesterday, how > does > >> > a > >> > view function access form data in general? I know I use the global(?) > >> > request object's "form" property, but beyond that I'm not sure. I can > >> > access > >> > StringField values (I'm using WTF) by using request.form.fieldID. But > >> > single > >> > select fields, multiple select fields, the status of checkboxes or > radio > >> > buttons, and so on I can't work out or find online. One resource said, > >> > for > >> > checkboxes, to use request.form.getlist("checkboxID"), but that gave > me > >> > an > >> > empty list despite that checkbox being checked. What am I missing? I > >> > know > >> > people usually use validators, but I need the values and statuses of > >> > elements in my form-processing view function because I'm dynamically > >> > constructing an SQL query based on the form's information. > >> > > >> > -- > >> > Alex Hall > >> > Automatic Distributors, IT department > >> > ahall at autodist.com > >> > > >> > _______________________________________________ > >> > Flask mailing list > >> > Flask at python.org > >> > https://mail.python.org/mailman/listinfo/flask > >> > > > > > > > > > > > -- > > Alex Hall > > Automatic Distributors, IT department > > ahall at autodist.com > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Thu Apr 21 09:43:16 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Thu, 21 Apr 2016 09:43:16 -0400 Subject: [Flask] alternatives for comparison operators in Jinja2? Message-ID: Does anyone know if there are alternatives for the documented comparison operators in Jinja2? I have an if statement in my template where I need to use the "<" symbol, but that messes with the syntax highlighting in my editor because it thinks I am starting an html tag. From brijeshb42 at gmail.com Thu Apr 21 09:49:38 2016 From: brijeshb42 at gmail.com (Brijesh Bittu) Date: Thu, 21 Apr 2016 19:19:38 +0530 Subject: [Flask] alternatives for comparison operators in Jinja2? In-Reply-To: References: Message-ID: You just need to install jinja highlight plugin for your text editor and nothing else. For ex, for sublime, the plugin is here https://packagecontrol.io/packages/Jinja2 On Thu, Apr 21, 2016 at 7:13 PM, Corey Boyle wrote: > Does anyone know if there are alternatives for the documented > comparison operators in Jinja2? > > I have an if statement in my template where I need to use the "<" > symbol, but that messes with the syntax highlighting in my editor > because it thinks I am starting an html tag. > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Thu Apr 21 09:57:16 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Thu, 21 Apr 2016 09:57:16 -0400 Subject: [Flask] alternatives for comparison operators in Jinja2? In-Reply-To: References: Message-ID: Thanks, I'm using Geany at the moment. I will look into that. On Thu, Apr 21, 2016 at 9:49 AM, Brijesh Bittu wrote: > You just need to install jinja highlight plugin for your text editor and > nothing else. > For ex, for sublime, the plugin is here > https://packagecontrol.io/packages/Jinja2 > > On Thu, Apr 21, 2016 at 7:13 PM, Corey Boyle wrote: >> >> Does anyone know if there are alternatives for the documented >> comparison operators in Jinja2? >> >> I have an if statement in my template where I need to use the "<" >> symbol, but that messes with the syntax highlighting in my editor >> because it thinks I am starting an html tag. >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask > > From ahall at autodist.com Thu Apr 21 16:02:16 2016 From: ahall at autodist.com (Alex Hall) Date: Thu, 21 Apr 2016 16:02:16 -0400 Subject: [Flask] Access form data in view function In-Reply-To: References: Message-ID: One more update: my form seems to only pass one field, no matter what. I made a little loop in the function that processes the form: for i, j in request.form.iteritems(): print "form[{i}]={j}".format(i=i, j=j) This only ever prints my "orderNumber" text field, whether that field has a value or not. It never prints the other text field in the form, the checkbox, or either of the multiple select fields. I've been over the form template, html, and class again and again, trying to spot what I did differently for the orderNumber field that makes it stick when nothing else does. I've even reversed the order of fields in the form, to see if it's just the first field in the form that gets saved, but that didn't change anything. I'm really at a loss, and I've spent hours googling this to no avail. It makes no sense that the form would grab one field, but no others. I can't figure out what I could possibly be doing, and no one I could find has this problem. What code would it help to send to the list for you all to look at? Thanks. On Thu, Apr 21, 2016 at 8:13 AM, Alex Hall wrote: > Hello all, > Further to my question about multiple select fields yesterday, how does a > view function access form data in general? I know I use the global(?) > request object's "form" property, but beyond that I'm not sure. I can > access StringField values (I'm using WTF) by using request.form.fieldID. > But single select fields, multiple select fields, the status of checkboxes > or radio buttons, and so on I can't work out or find online. One resource > said, for checkboxes, to use request.form.getlist("checkboxID"), but that > gave me an empty list despite that checkbox being checked. What am I > missing? I know people usually use validators, but I need the values and > statuses of elements in my form-processing view function because I'm > dynamically constructing an SQL query based on the form's information. > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Thu Apr 21 16:29:57 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Thu, 21 Apr 2016 16:29:57 -0400 Subject: [Flask] Access form data in view function In-Reply-To: References: Message-ID: Can you upload your full app? Or at least a demo app with your view and your template? Also, I think you are still confusing the form object created by WTForms with the request.form object, which is completely different. Anthony Ford, KF5IBN, ford.anthonyj at gmail.com On Thu, Apr 21, 2016 at 4:02 PM, Alex Hall wrote: > One more update: my form seems to only pass one field, no matter what. I > made a little loop in the function that processes the form: > > for i, j in request.form.iteritems(): > print "form[{i}]={j}".format(i=i, j=j) > > This only ever prints my "orderNumber" text field, whether that field has > a value or not. It never prints the other text field in the form, the > checkbox, or either of the multiple select fields. I've been over the form > template, html, and class again and again, trying to spot what I did > differently for the orderNumber field that makes it stick when nothing else > does. I've even reversed the order of fields in the form, to see if it's > just the first field in the form that gets saved, but that didn't change > anything. I'm really at a loss, and I've spent hours googling this to no > avail. It makes no sense that the form would grab one field, but no others. > I can't figure out what I could possibly be doing, and no one I could find > has this problem. What code would it help to send to the list for you all > to look at? Thanks. > > On Thu, Apr 21, 2016 at 8:13 AM, Alex Hall wrote: > >> Hello all, >> Further to my question about multiple select fields yesterday, how does a >> view function access form data in general? I know I use the global(?) >> request object's "form" property, but beyond that I'm not sure. I can >> access StringField values (I'm using WTF) by using request.form.fieldID. >> But single select fields, multiple select fields, the status of checkboxes >> or radio buttons, and so on I can't work out or find online. One resource >> said, for checkboxes, to use request.form.getlist("checkboxID"), but that >> gave me an empty list despite that checkbox being checked. What am I >> missing? I know people usually use validators, but I need the values and >> statuses of elements in my form-processing view function because I'm >> dynamically constructing an SQL query based on the form's information. >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> > > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Thu Apr 21 18:59:02 2016 From: ahall at autodist.com (Alex Hall) Date: Thu, 21 Apr 2016 18:59:02 -0400 Subject: [Flask] Access form data in view function In-Reply-To: References: Message-ID: <0BD0C390-4953-46A8-AB89-35A5325A2268@autodist.com> All, Thanks for the help. It turns out that I missed something incredibly obvious. The problem was that, days ago, I'd added a test to my JS to make sure data was going from the form to the Python function. Instead of serializing the form, I was sending just one value. I never removed that test, and forgot I had it in there. I've removed it and adjusted the script, and am now getting a 500 error, but I think once i find the scripting problem that causes that I'll be in much better shape than i was. I've also combined two functions into one, so I can access the form object created and passed to the view instead of request. form. I didn't catch that I wasn't supposed to use request.form until someone here pointed it out. Sent from my iPhone > On Apr 21, 2016, at 16:29, Anthony Ford wrote: > > Can you upload your full app? Or at least a demo app with your view and your template? > > Also, I think you are still confusing the form object created by WTForms with the request.form object, which is completely different. > > > Anthony Ford, > KF5IBN, > ford.anthonyj at gmail.com > >> On Thu, Apr 21, 2016 at 4:02 PM, Alex Hall wrote: >> One more update: my form seems to only pass one field, no matter what. I made a little loop in the function that processes the form: >> >> for i, j in request.form.iteritems(): >> print "form[{i}]={j}".format(i=i, j=j) >> >> This only ever prints my "orderNumber" text field, whether that field has a value or not. It never prints the other text field in the form, the checkbox, or either of the multiple select fields. I've been over the form template, html, and class again and again, trying to spot what I did differently for the orderNumber field that makes it stick when nothing else does. I've even reversed the order of fields in the form, to see if it's just the first field in the form that gets saved, but that didn't change anything. I'm really at a loss, and I've spent hours googling this to no avail. It makes no sense that the form would grab one field, but no others. I can't figure out what I could possibly be doing, and no one I could find has this problem. What code would it help to send to the list for you all to look at? Thanks. >> >>> On Thu, Apr 21, 2016 at 8:13 AM, Alex Hall wrote: >> >>> Hello all, >>> Further to my question about multiple select fields yesterday, how does a view function access form data in general? I know I use the global(?) request object's "form" property, but beyond that I'm not sure. I can access StringField values (I'm using WTF) by using request.form.fieldID. But single select fields, multiple select fields, the status of checkboxes or radio buttons, and so on I can't work out or find online. One resource said, for checkboxes, to use request.form.getlist("checkboxID"), but that gave me an empty list despite that checkbox being checked. What am I missing? I know people usually use validators, but I need the values and statuses of elements in my form-processing view function because I'm dynamically constructing an SQL query based on the form's information. >>> >>> -- >>> Alex Hall >>> Automatic Distributors, IT department >>> ahall at autodist.com >> >> >> >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gabor at szabgab.com Fri Apr 22 02:06:05 2016 From: gabor at szabgab.com (Gabor Szabo) Date: Fri, 22 Apr 2016 09:06:05 +0300 Subject: [Flask] How to debug exceptions on the production server? Message-ID: Hi, I had some code that on the development server running in debug mode worked fine, but on the production server gave me an "Internal Error". The cause was some difference in data. I assumed a dictionary key to be always present, but on the production server some of the data had that key missing. My real issue however was really that I have not got any indication of the nature of the problem. The error logs (both uwsgi and nginx) had no information about the error. After seeing the "Internal Error" page I wrapped the code in a try-block and tried to print the exception. A very simplified version of the code that already demonstrate the problem looks like this: @app.route("/sample") def sample(): d = { } try: x = d['name'] except Exception as e: return(type(e)) return 'ok' This code just gives me further "Internal Errors" on the production server. Apparently the call to type(e) generates another exception. In debug mode it gives me a TypeError: exceptions.KeyError object is not an iterator error. Am I doing something totally wrong here? Gabor -------------- next part -------------- An HTML attachment was scrubbed... URL: From alejoar at gmail.com Fri Apr 22 03:37:40 2016 From: alejoar at gmail.com (Alejo Arias) Date: Fri, 22 Apr 2016 09:37:40 +0200 Subject: [Flask] How to debug exceptions on the production server? In-Reply-To: References: Message-ID: Hi Gabor, I'm not sure why your code raises a TypeError, it doesn't seem to be wrong to me, maybe someone else can help you there. What I can tell you though is a way to avoid using the try-except at all. I would use the 'get' method of the dictionary so that trying to access a key that doesn't exist doesn't raise an exception. For example: >>> d = {} >>> x = d.get('name') >>> x is None True You can also pass a second parameter to default the value to something else instead of None: >>> x = d.get('name', 0) >>> x 0 Hope that helps. Regards, Alejo On 22 April 2016 at 08:06, Gabor Szabo wrote: > Hi, > > I had some code that on the development server running in debug mode > worked fine, but on the production server gave me an "Internal Error". The > cause was some difference in data. I assumed a dictionary key to be always > present, but on the production server some of the data had that key missing. > > My real issue however was really that I have not got any indication of the > nature of the problem. > The error logs (both uwsgi and nginx) had no information about the error. > After seeing the "Internal Error" page I wrapped the code in a try-block > and tried to print the exception. A very simplified version of the code > that already demonstrate the problem looks like this: > > @app.route("/sample") > def sample(): > d = { > } > try: > x = d['name'] > except Exception as e: > return(type(e)) > return 'ok' > > > This code just gives me further "Internal Errors" on the production > server. Apparently the call to type(e) generates another exception. > > In debug mode it gives me a > > TypeError: exceptions.KeyError object is not an iterator > > error. > > Am I doing something totally wrong here? > > Gabor > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Fri Apr 22 08:18:03 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Fri, 22 Apr 2016 08:18:03 -0400 Subject: [Flask] How to debug exceptions on the production server? In-Reply-To: References: Message-ID: You could also have your production app send you an email with details about the exception. The Flask book covers that. http://flaskbook.com/ On Apr 22, 2016 3:38 AM, "Alejo Arias" wrote: > Hi Gabor, > > I'm not sure why your code raises a TypeError, it doesn't seem to be wrong > to me, maybe someone else can help you there. > > What I can tell you though is a way to avoid using the try-except at all. > I would use the 'get' method of the dictionary so that trying to access a > key that doesn't exist doesn't raise an exception. > > For example: > > >>> d = {} > >>> x = d.get('name') > >>> x is None > True > > You can also pass a second parameter to default the value to something > else instead of None: > > >>> x = d.get('name', 0) > >>> x > 0 > > Hope that helps. > > Regards, > Alejo > > On 22 April 2016 at 08:06, Gabor Szabo wrote: > >> Hi, >> >> I had some code that on the development server running in debug mode >> worked fine, but on the production server gave me an "Internal Error". The >> cause was some difference in data. I assumed a dictionary key to be always >> present, but on the production server some of the data had that key missing. >> >> My real issue however was really that I have not got any indication of >> the nature of the problem. >> The error logs (both uwsgi and nginx) had no information about the error. >> After seeing the "Internal Error" page I wrapped the code in a try-block >> and tried to print the exception. A very simplified version of the code >> that already demonstrate the problem looks like this: >> >> @app.route("/sample") >> def sample(): >> d = { >> } >> try: >> x = d['name'] >> except Exception as e: >> return(type(e)) >> return 'ok' >> >> >> This code just gives me further "Internal Errors" on the production >> server. Apparently the call to type(e) generates another exception. >> >> In debug mode it gives me a >> >> TypeError: exceptions.KeyError object is not an iterator >> >> error. >> >> Am I doing something totally wrong here? >> >> Gabor >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lawrence at betterlife.io Fri Apr 22 08:42:00 2016 From: lawrence at betterlife.io (Lawrence) Date: Fri, 22 Apr 2016 20:42:00 +0800 Subject: [Flask] How to debug exceptions on the production server? In-Reply-To: References: Message-ID: <1461328925048-904c1ecd-8d65b05b-7a378301@betterlife.io> Use service like rollbar or sentry could also be an option. They can capture all the details for the exception and will be very helpful for you to replay whats happening when the exception occurs. Sent using CloudMagic Email [https://cloudmagic.com/k/d/mailapp?ct=pi&cv=7.9.6&pv=9.3&source=email_footer_2] On Fri, Apr 22, 2016 at 8:18 PM, Corey wrote: You could also have your production app send you an email with details about the exception. The Flask book covers that. http://flaskbook.com/ [http://flaskbook.com/] On Apr 22, 2016 3:38 AM, "Alejo Arias" < alejoar at gmail.com [alejoar at gmail.com] > wrote: Hi Gabor, I'm not sure why your code raises a TypeError, it doesn't seem to be wrong to me, maybe someone else can help you there. What I can tell you though is a way to avoid using the try-except at all. I would use the 'get' method of the dictionary so that trying to access a key that doesn't exist doesn't raise an exception. For example: >>> d = {} >>> x = d.get('name') >>> x is None True You can also pass a second parameter to default the value to something else instead of None: >>> x = d.get('name', 0) >>> x 0 Hope that helps. Regards, Alejo On 22 April 2016 at 08:06, Gabor Szabo < gabor at szabgab.com [gabor at szabgab.com] > wrote: Hi, I had some code that on the development server running in debug mode worked fine, but on the production server gave me an "Internal Error". The cause was some difference in data. I assumed a dictionary key to be always present, but on the production server some of the data had that key missing. My real issue however was really that I have not got any indication of the nature of the problem. The error logs (both uwsgi and nginx) had no information about the error. After seeing the "Internal Error" page I wrapped the code in a try-block and tried to print the exception. A very simplified version of the code that already demonstrate the problem looks like this: @app.route("/sample") def sample(): d = { } try: x = d['name'] except Exception as e: return(type(e)) return 'ok' This code just gives me further "Internal Errors" on the production server. Apparently the call to type(e) generates another exception. In debug mode it gives me a TypeError: exceptions.KeyError object is not an iterator error. Am I doing something totally wrong here? Gabor _________________________ ______________________ Flask mailing list Flask at python.org [Flask at python.org] https://mail.python.org/mailman/listinfo/flask [https://mail.python.org/mailman/listinfo/flask] _________________________ ______________________ Flask mailing list Flask at python.org [Flask at python.org] https://mail.python.org/mailman/listinfo/flask [https://mail.python.org/mailman/listinfo/flask] -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidism at gmail.com Fri Apr 22 08:44:54 2016 From: davidism at gmail.com (David Lord) Date: Fri, 22 Apr 2016 05:44:54 -0700 Subject: [Flask] How to debug exceptions on the production server? In-Reply-To: References: Message-ID: <75af80e7-a1e3-eccb-ea94-a9eb5d41a1f7@gmail.com> http://stackoverflow.com/questions/32722143/flask-application-traceback-doesnt-show-up-in-server-log On 04/21/2016 11:06 PM, Gabor Szabo wrote: > Hi, > > I had some code that on the development server running in debug mode > worked fine, but on the production server gave me an "Internal Error". > The cause was some difference in data. I assumed a dictionary key to > be always present, but on the production server some of the data had > that key missing. > > My real issue however was really that I have not got any indication of > the nature of the problem. > The error logs (both uwsgi and nginx) had no information about the error. > After seeing the "Internal Error" page I wrapped the code in a > try-block and tried to print the exception. A very simplified version > of the code that already demonstrate the problem looks like this: > > @app.route("/sample") > def sample(): > d = { > } > try: > x = d['name'] > except Exception as e: > return(type(e)) > return 'ok' > > > This code just gives me further "Internal Errors" on the production > server. Apparently the call to type(e) generates another exception. > > In debug mode it gives me a > > TypeError: exceptions.KeyError object is not an iterator > > error. > > Am I doing something totally wrong here? > > Gabor > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Fri Apr 22 09:25:49 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Fri, 22 Apr 2016 09:25:49 -0400 Subject: [Flask] Access form data in view function In-Reply-To: <0BD0C390-4953-46A8-AB89-35A5325A2268@autodist.com> References: <0BD0C390-4953-46A8-AB89-35A5325A2268@autodist.com> Message-ID: @Alex - Not sure if you still need this or not. I put this example code together, let me know if it helps. https://dl.dropboxusercontent.com/u/3594910/random/myapp.py On Thu, Apr 21, 2016 at 6:59 PM, Alex Hall wrote: > All, > Thanks for the help. It turns out that I missed something incredibly > obvious. The problem was that, days ago, I'd added a test to my JS to make > sure data was going from the form to the Python function. Instead of > serializing the form, I was sending just one value. I never removed that > test, and forgot I had it in there. I've removed it and adjusted the script, > and am now getting a 500 error, but I think once i find the scripting > problem that causes that I'll be in much better shape than i was. I've also > combined two functions into one, so I can access the form object created and > passed to the view instead of request. form. I didn't catch that I wasn't > supposed to use request.form until someone here pointed it out. > > Sent from my iPhone > > On Apr 21, 2016, at 16:29, Anthony Ford wrote: > > Can you upload your full app? Or at least a demo app with your view and your > template? > > Also, I think you are still confusing the form object created by WTForms > with the request.form object, which is completely different. > > > Anthony Ford, > KF5IBN, > ford.anthonyj at gmail.com > > On Thu, Apr 21, 2016 at 4:02 PM, Alex Hall wrote: >> >> One more update: my form seems to only pass one field, no matter what. I >> made a little loop in the function that processes the form: >> >> for i, j in request.form.iteritems(): >> print "form[{i}]={j}".format(i=i, j=j) >> >> This only ever prints my "orderNumber" text field, whether that field has >> a value or not. It never prints the other text field in the form, the >> checkbox, or either of the multiple select fields. I've been over the form >> template, html, and class again and again, trying to spot what I did >> differently for the orderNumber field that makes it stick when nothing else >> does. I've even reversed the order of fields in the form, to see if it's >> just the first field in the form that gets saved, but that didn't change >> anything. I'm really at a loss, and I've spent hours googling this to no >> avail. It makes no sense that the form would grab one field, but no others. >> I can't figure out what I could possibly be doing, and no one I could find >> has this problem. What code would it help to send to the list for you all to >> look at? Thanks. >> >> On Thu, Apr 21, 2016 at 8:13 AM, Alex Hall wrote: >>> >>> Hello all, >>> Further to my question about multiple select fields yesterday, how does a >>> view function access form data in general? I know I use the global(?) >>> request object's "form" property, but beyond that I'm not sure. I can access >>> StringField values (I'm using WTF) by using request.form.fieldID. But single >>> select fields, multiple select fields, the status of checkboxes or radio >>> buttons, and so on I can't work out or find online. One resource said, for >>> checkboxes, to use request.form.getlist("checkboxID"), but that gave me an >>> empty list despite that checkbox being checked. What am I missing? I know >>> people usually use validators, but I need the values and statuses of >>> elements in my form-processing view function because I'm dynamically >>> constructing an SQL query based on the form's information. >>> >>> -- >>> Alex Hall >>> Automatic Distributors, IT department >>> ahall at autodist.com >> >> >> >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > From ahall at autodist.com Fri Apr 22 10:02:33 2016 From: ahall at autodist.com (Alex Hall) Date: Fri, 22 Apr 2016 10:02:33 -0400 Subject: [Flask] Access form data in view function In-Reply-To: References: <0BD0C390-4953-46A8-AB89-35A5325A2268@autodist.com> Message-ID: Thanks. I've now seen this done two ways: do you access form data through request.form, or through the form object you create and send when you render? In your example, you used request.form, but I've seen it done like this: myForm = forms.LoginForm() if request.method = get: return render_template("myLoginPage.html", form=myForm) return myForm.username #as opposed to request.form.username There's also use of the data property on form class members, but that, too, is only used sometimes? I know what you were doing with the request.form.get("name", None)--getting either the field content or None--but when would you use the data property? I'm still fighting with JS, so can't test on my own form to make sure I have things back to normal. Hopefully I'll get this script worked out soon (you wouldn't believe how hard it is to find a JS debugger that works with screen readers; so far, I haven't done it). Thanks in advance for clarification on the above questions. I think, once I have those down, I'll understand form handling "for real". On Fri, Apr 22, 2016 at 9:25 AM, Corey Boyle wrote: > @Alex - Not sure if you still need this or not. I put this example > code together, let me know if it helps. > https://dl.dropboxusercontent.com/u/3594910/random/myapp.py > > On Thu, Apr 21, 2016 at 6:59 PM, Alex Hall wrote: > > All, > > Thanks for the help. It turns out that I missed something incredibly > > obvious. The problem was that, days ago, I'd added a test to my JS to > make > > sure data was going from the form to the Python function. Instead of > > serializing the form, I was sending just one value. I never removed that > > test, and forgot I had it in there. I've removed it and adjusted the > script, > > and am now getting a 500 error, but I think once i find the scripting > > problem that causes that I'll be in much better shape than i was. I've > also > > combined two functions into one, so I can access the form object created > and > > passed to the view instead of request. form. I didn't catch that I wasn't > > supposed to use request.form until someone here pointed it out. > > > > Sent from my iPhone > > > > On Apr 21, 2016, at 16:29, Anthony Ford wrote: > > > > Can you upload your full app? Or at least a demo app with your view and > your > > template? > > > > Also, I think you are still confusing the form object created by WTForms > > with the request.form object, which is completely different. > > > > > > Anthony Ford, > > KF5IBN, > > ford.anthonyj at gmail.com > > > > On Thu, Apr 21, 2016 at 4:02 PM, Alex Hall wrote: > >> > >> One more update: my form seems to only pass one field, no matter what. I > >> made a little loop in the function that processes the form: > >> > >> for i, j in request.form.iteritems(): > >> print "form[{i}]={j}".format(i=i, j=j) > >> > >> This only ever prints my "orderNumber" text field, whether that field > has > >> a value or not. It never prints the other text field in the form, the > >> checkbox, or either of the multiple select fields. I've been over the > form > >> template, html, and class again and again, trying to spot what I did > >> differently for the orderNumber field that makes it stick when nothing > else > >> does. I've even reversed the order of fields in the form, to see if it's > >> just the first field in the form that gets saved, but that didn't change > >> anything. I'm really at a loss, and I've spent hours googling this to no > >> avail. It makes no sense that the form would grab one field, but no > others. > >> I can't figure out what I could possibly be doing, and no one I could > find > >> has this problem. What code would it help to send to the list for you > all to > >> look at? Thanks. > >> > >> On Thu, Apr 21, 2016 at 8:13 AM, Alex Hall wrote: > >>> > >>> Hello all, > >>> Further to my question about multiple select fields yesterday, how > does a > >>> view function access form data in general? I know I use the global(?) > >>> request object's "form" property, but beyond that I'm not sure. I can > access > >>> StringField values (I'm using WTF) by using request.form.fieldID. But > single > >>> select fields, multiple select fields, the status of checkboxes or > radio > >>> buttons, and so on I can't work out or find online. One resource said, > for > >>> checkboxes, to use request.form.getlist("checkboxID"), but that gave > me an > >>> empty list despite that checkbox being checked. What am I missing? I > know > >>> people usually use validators, but I need the values and statuses of > >>> elements in my form-processing view function because I'm dynamically > >>> constructing an SQL query based on the form's information. > >>> > >>> -- > >>> Alex Hall > >>> Automatic Distributors, IT department > >>> ahall at autodist.com > >> > >> > >> > >> > >> -- > >> Alex Hall > >> Automatic Distributors, IT department > >> ahall at autodist.com > >> > >> _______________________________________________ > >> Flask mailing list > >> Flask at python.org > >> https://mail.python.org/mailman/listinfo/flask > >> > > > > > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > > > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From Stephen.Mazzei at asrcfederal.com Fri Apr 22 11:09:34 2016 From: Stephen.Mazzei at asrcfederal.com (Mazzei, Stephen Andrew) Date: Fri, 22 Apr 2016 15:09:34 +0000 Subject: [Flask] Unpacking python list Message-ID: Good morning, I have some back end python code pulling from a database generating the following list: ['Stephen Mazzei', 'cv7457', 'mazzei.s', 'non-employee', None, 'Stephen.Mazzei at asrcfederal.com', 'ASRC Federal Data Solutions', None, 'BECKETT RIDGE TECHNICAL CENTER', 'USA', 'HPC', 0, 10L, '10.0', '02/16/2016 09:22 AM', 'unlocked'] I then have in the jinja/html page a {% for item in list %}

{{item}}

{% endfor %} This generates the following on the HTML page Stephen Mazzei cv7457 mazzei.s non-employee None Stephen.Mazzei at asrcfederal.com ASRC Federal Data Solutions None BECKETT RIDGE TECHNICAL CENTER USA HPC 0 10 10.0 02/16/2016 09:22 AM unlocked In all the other pages I have written, I have been to do {% for item1, item2, item3, etc...., item16 in list %} And then use the values as needed in the templates. For some reason when doing this on this one page, I receive the error: ValueError: need more than 14 values to unpack If I take off the last two values it still errors but with ValueError: need more than 6 values to unpack Any ideas??? --- Stephen A. Mazzei Systems Administrator | AFDS, ASRC Federal Data Solutions - P&G HPC Account | 513-634-9965 ________________________________ The preceding message (including attachments) is covered by the Electronic Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended only for the person or entity to which it is addressed, and may contain information that is confidential, protected by attorney-client or other privilege, or otherwise protected from disclosure by law. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error and destroy the original message and all copies. -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Fri Apr 22 11:28:50 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Fri, 22 Apr 2016 11:28:50 -0400 Subject: [Flask] Access form data in view function In-Reply-To: References: <0BD0C390-4953-46A8-AB89-35A5325A2268@autodist.com> Message-ID: So I think the different method you are seeing is the use of the extension Flask-WTF. When using that extension, you create a form object that uses request.form under the hood. The form object is then used for two different but related tasks. One to process data that has been submitted, and secondly to pass a form object into the template that can generate the HTML for you. You could also add in Flask-Bootstrap which has support for Flask-WTF. Using request.form directly is not necessarily a bad thing. ~Disclamer~ I don't necessarily know what I am talking about. Flask is a new thing for me too. On Fri, Apr 22, 2016 at 10:02 AM, Alex Hall wrote: > Thanks. I've now seen this done two ways: do you access form data through > request.form, or through the form object you create and send when you > render? In your example, you used request.form, but I've seen it done like > this: > > myForm = forms.LoginForm() > if request.method = get: > return render_template("myLoginPage.html", form=myForm) > return myForm.username #as opposed to request.form.username > > There's also use of the data property on form class members, but that, too, > is only used sometimes? I know what you were doing with the > request.form.get("name", None)--getting either the field content or > None--but when would you use the data property? > > I'm still fighting with JS, so can't test on my own form to make sure I have > things back to normal. Hopefully I'll get this script worked out soon (you > wouldn't believe how hard it is to find a JS debugger that works with screen > readers; so far, I haven't done it). Thanks in advance for clarification on > the above questions. I think, once I have those down, I'll understand form > handling "for real". > > On Fri, Apr 22, 2016 at 9:25 AM, Corey Boyle wrote: >> >> @Alex - Not sure if you still need this or not. I put this example >> code together, let me know if it helps. >> https://dl.dropboxusercontent.com/u/3594910/random/myapp.py >> >> On Thu, Apr 21, 2016 at 6:59 PM, Alex Hall wrote: >> > All, >> > Thanks for the help. It turns out that I missed something incredibly >> > obvious. The problem was that, days ago, I'd added a test to my JS to >> > make >> > sure data was going from the form to the Python function. Instead of >> > serializing the form, I was sending just one value. I never removed that >> > test, and forgot I had it in there. I've removed it and adjusted the >> > script, >> > and am now getting a 500 error, but I think once i find the scripting >> > problem that causes that I'll be in much better shape than i was. I've >> > also >> > combined two functions into one, so I can access the form object created >> > and >> > passed to the view instead of request. form. I didn't catch that I >> > wasn't >> > supposed to use request.form until someone here pointed it out. >> > >> > Sent from my iPhone >> > >> > On Apr 21, 2016, at 16:29, Anthony Ford wrote: >> > >> > Can you upload your full app? Or at least a demo app with your view and >> > your >> > template? >> > >> > Also, I think you are still confusing the form object created by WTForms >> > with the request.form object, which is completely different. >> > >> > >> > Anthony Ford, >> > KF5IBN, >> > ford.anthonyj at gmail.com >> > >> > On Thu, Apr 21, 2016 at 4:02 PM, Alex Hall wrote: >> >> >> >> One more update: my form seems to only pass one field, no matter what. >> >> I >> >> made a little loop in the function that processes the form: >> >> >> >> for i, j in request.form.iteritems(): >> >> print "form[{i}]={j}".format(i=i, j=j) >> >> >> >> This only ever prints my "orderNumber" text field, whether that field >> >> has >> >> a value or not. It never prints the other text field in the form, the >> >> checkbox, or either of the multiple select fields. I've been over the >> >> form >> >> template, html, and class again and again, trying to spot what I did >> >> differently for the orderNumber field that makes it stick when nothing >> >> else >> >> does. I've even reversed the order of fields in the form, to see if >> >> it's >> >> just the first field in the form that gets saved, but that didn't >> >> change >> >> anything. I'm really at a loss, and I've spent hours googling this to >> >> no >> >> avail. It makes no sense that the form would grab one field, but no >> >> others. >> >> I can't figure out what I could possibly be doing, and no one I could >> >> find >> >> has this problem. What code would it help to send to the list for you >> >> all to >> >> look at? Thanks. >> >> >> >> On Thu, Apr 21, 2016 at 8:13 AM, Alex Hall wrote: >> >>> >> >>> Hello all, >> >>> Further to my question about multiple select fields yesterday, how >> >>> does a >> >>> view function access form data in general? I know I use the global(?) >> >>> request object's "form" property, but beyond that I'm not sure. I can >> >>> access >> >>> StringField values (I'm using WTF) by using request.form.fieldID. But >> >>> single >> >>> select fields, multiple select fields, the status of checkboxes or >> >>> radio >> >>> buttons, and so on I can't work out or find online. One resource said, >> >>> for >> >>> checkboxes, to use request.form.getlist("checkboxID"), but that gave >> >>> me an >> >>> empty list despite that checkbox being checked. What am I missing? I >> >>> know >> >>> people usually use validators, but I need the values and statuses of >> >>> elements in my form-processing view function because I'm dynamically >> >>> constructing an SQL query based on the form's information. >> >>> >> >>> -- >> >>> Alex Hall >> >>> Automatic Distributors, IT department >> >>> ahall at autodist.com >> >> >> >> >> >> >> >> >> >> -- >> >> Alex Hall >> >> Automatic Distributors, IT department >> >> ahall at autodist.com >> >> >> >> _______________________________________________ >> >> Flask mailing list >> >> Flask at python.org >> >> https://mail.python.org/mailman/listinfo/flask >> >> >> > >> > >> > _______________________________________________ >> > Flask mailing list >> > Flask at python.org >> > https://mail.python.org/mailman/listinfo/flask >> > > > > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com From coreybrett at gmail.com Fri Apr 22 11:32:36 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Fri, 22 Apr 2016 11:32:36 -0400 Subject: [Flask] Unpacking python list In-Reply-To: References: Message-ID: Is "list" a list with a single set of strings in it, or is "list" a list that contains lists that contain strings? (probably not the clearest question) On Fri, Apr 22, 2016 at 11:09 AM, Mazzei, Stephen Andrew wrote: > Good morning, > > > > I have some back end python code pulling from a database generating the > following list: > > ['Stephen Mazzei', 'cv7457', 'mazzei.s', 'non-employee', None, > 'Stephen.Mazzei at asrcfederal.com', 'ASRC Federal Data Solutions', None, > 'BECKETT RIDGE TECHNICAL CENTER', 'USA', 'HPC', 0, 10L, '10.0', '02/16/2016 > 09:22 AM', 'unlocked'] > > > > I then have in the jinja/html page a > > {% for item in list %} > >

{{item}}

> > {% endfor %} > > > > This generates the following on the HTML page > > Stephen Mazzei > > cv7457 > > mazzei.s > > non-employee > > None > > Stephen.Mazzei at asrcfederal.com > > ASRC Federal Data Solutions > > None > > BECKETT RIDGE TECHNICAL CENTER > > USA > > HPC > > 0 > > 10 > > 10.0 > > 02/16/2016 09:22 AM > > unlocked > > > > In all the other pages I have written, I have been to do > > {% for item1, item2, item3, etc?., item16 in list %} > > > > And then use the values as needed in the templates. For some reason when > doing this on this one page, I receive the error: > > ValueError: need more than 14 values to unpack > > > > If I take off the last two values it still errors but with > > ValueError: need more than 6 values to unpack > > > > > > Any ideas??? > > > > > > > > --- > > Stephen A. Mazzei > > Systems Administrator | AFDS, ASRC Federal Data Solutions - P&G HPC Account > | 513-634-9965 > > > > > ________________________________ > > The preceding message (including attachments) is covered by the Electronic > Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended only > for the person or entity to which it is addressed, and may contain > information that is confidential, protected by attorney-client or other > privilege, or otherwise protected from disclosure by law. If you are not the > intended recipient, you are hereby notified that any retention, > dissemination, distribution, or copying of this communication is strictly > prohibited. Please reply to the sender that you have received the message in > error and destroy the original message and all copies. > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > From ahall at autodist.com Fri Apr 22 11:33:39 2016 From: ahall at autodist.com (Alex Hall) Date: Fri, 22 Apr 2016 11:33:39 -0400 Subject: [Flask] Access form data in view function In-Reply-To: References: <0BD0C390-4953-46A8-AB89-35A5325A2268@autodist.com> Message-ID: Yes, I'm using the Flask-wtf extension. Every tutorial says to use it, so I installed it and have so far found it to be quite easy. I didn't realize that it causes the way you interact with forms to change, though. On Fri, Apr 22, 2016 at 11:28 AM, Corey Boyle wrote: > So I think the different method you are seeing is the use of the > extension Flask-WTF. > When using that extension, you create a form object that uses > request.form under the hood. > The form object is then used for two different but related tasks. > One to process data that has been submitted, and secondly to pass a > form object into the template that can generate the HTML for you. > You could also add in Flask-Bootstrap which has support for Flask-WTF. > Using request.form directly is not necessarily a bad thing. > > ~Disclamer~ > I don't necessarily know what I am talking about. Flask is a new thing > for me too. > > On Fri, Apr 22, 2016 at 10:02 AM, Alex Hall wrote: > > Thanks. I've now seen this done two ways: do you access form data through > > request.form, or through the form object you create and send when you > > render? In your example, you used request.form, but I've seen it done > like > > this: > > > > myForm = forms.LoginForm() > > if request.method = get: > > return render_template("myLoginPage.html", form=myForm) > > return myForm.username #as opposed to request.form.username > > > > There's also use of the data property on form class members, but that, > too, > > is only used sometimes? I know what you were doing with the > > request.form.get("name", None)--getting either the field content or > > None--but when would you use the data property? > > > > I'm still fighting with JS, so can't test on my own form to make sure I > have > > things back to normal. Hopefully I'll get this script worked out soon > (you > > wouldn't believe how hard it is to find a JS debugger that works with > screen > > readers; so far, I haven't done it). Thanks in advance for clarification > on > > the above questions. I think, once I have those down, I'll understand > form > > handling "for real". > > > > On Fri, Apr 22, 2016 at 9:25 AM, Corey Boyle > wrote: > >> > >> @Alex - Not sure if you still need this or not. I put this example > >> code together, let me know if it helps. > >> https://dl.dropboxusercontent.com/u/3594910/random/myapp.py > >> > >> On Thu, Apr 21, 2016 at 6:59 PM, Alex Hall wrote: > >> > All, > >> > Thanks for the help. It turns out that I missed something incredibly > >> > obvious. The problem was that, days ago, I'd added a test to my JS to > >> > make > >> > sure data was going from the form to the Python function. Instead of > >> > serializing the form, I was sending just one value. I never removed > that > >> > test, and forgot I had it in there. I've removed it and adjusted the > >> > script, > >> > and am now getting a 500 error, but I think once i find the scripting > >> > problem that causes that I'll be in much better shape than i was. I've > >> > also > >> > combined two functions into one, so I can access the form object > created > >> > and > >> > passed to the view instead of request. form. I didn't catch that I > >> > wasn't > >> > supposed to use request.form until someone here pointed it out. > >> > > >> > Sent from my iPhone > >> > > >> > On Apr 21, 2016, at 16:29, Anthony Ford > wrote: > >> > > >> > Can you upload your full app? Or at least a demo app with your view > and > >> > your > >> > template? > >> > > >> > Also, I think you are still confusing the form object created by > WTForms > >> > with the request.form object, which is completely different. > >> > > >> > > >> > Anthony Ford, > >> > KF5IBN, > >> > ford.anthonyj at gmail.com > >> > > >> > On Thu, Apr 21, 2016 at 4:02 PM, Alex Hall > wrote: > >> >> > >> >> One more update: my form seems to only pass one field, no matter > what. > >> >> I > >> >> made a little loop in the function that processes the form: > >> >> > >> >> for i, j in request.form.iteritems(): > >> >> print "form[{i}]={j}".format(i=i, j=j) > >> >> > >> >> This only ever prints my "orderNumber" text field, whether that field > >> >> has > >> >> a value or not. It never prints the other text field in the form, the > >> >> checkbox, or either of the multiple select fields. I've been over the > >> >> form > >> >> template, html, and class again and again, trying to spot what I did > >> >> differently for the orderNumber field that makes it stick when > nothing > >> >> else > >> >> does. I've even reversed the order of fields in the form, to see if > >> >> it's > >> >> just the first field in the form that gets saved, but that didn't > >> >> change > >> >> anything. I'm really at a loss, and I've spent hours googling this to > >> >> no > >> >> avail. It makes no sense that the form would grab one field, but no > >> >> others. > >> >> I can't figure out what I could possibly be doing, and no one I could > >> >> find > >> >> has this problem. What code would it help to send to the list for you > >> >> all to > >> >> look at? Thanks. > >> >> > >> >> On Thu, Apr 21, 2016 at 8:13 AM, Alex Hall > wrote: > >> >>> > >> >>> Hello all, > >> >>> Further to my question about multiple select fields yesterday, how > >> >>> does a > >> >>> view function access form data in general? I know I use the > global(?) > >> >>> request object's "form" property, but beyond that I'm not sure. I > can > >> >>> access > >> >>> StringField values (I'm using WTF) by using request.form.fieldID. > But > >> >>> single > >> >>> select fields, multiple select fields, the status of checkboxes or > >> >>> radio > >> >>> buttons, and so on I can't work out or find online. One resource > said, > >> >>> for > >> >>> checkboxes, to use request.form.getlist("checkboxID"), but that gave > >> >>> me an > >> >>> empty list despite that checkbox being checked. What am I missing? I > >> >>> know > >> >>> people usually use validators, but I need the values and statuses of > >> >>> elements in my form-processing view function because I'm dynamically > >> >>> constructing an SQL query based on the form's information. > >> >>> > >> >>> -- > >> >>> Alex Hall > >> >>> Automatic Distributors, IT department > >> >>> ahall at autodist.com > >> >> > >> >> > >> >> > >> >> > >> >> -- > >> >> Alex Hall > >> >> Automatic Distributors, IT department > >> >> ahall at autodist.com > >> >> > >> >> _______________________________________________ > >> >> Flask mailing list > >> >> Flask at python.org > >> >> https://mail.python.org/mailman/listinfo/flask > >> >> > >> > > >> > > >> > _______________________________________________ > >> > Flask mailing list > >> > Flask at python.org > >> > https://mail.python.org/mailman/listinfo/flask > >> > > > > > > > > > > > -- > > Alex Hall > > Automatic Distributors, IT department > > ahall at autodist.com > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From Stephen.Mazzei at asrcfederal.com Fri Apr 22 11:36:22 2016 From: Stephen.Mazzei at asrcfederal.com (Mazzei, Stephen Andrew) Date: Fri, 22 Apr 2016 15:36:22 +0000 Subject: [Flask] Unpacking python list In-Reply-To: References: Message-ID: !!!! It was counting the character count of the first variable not the number of items in the list!!! Thank you for pointing that out! I turned the list into a tuple and it now works as expected. Thank you --- Stephen A. Mazzei Systems Administrator | AFDS, ASRC Federal Data Solutions - P&G HPC Account | 513-634-9965 From: Federico Di Nella [mailto:federicodinella at gmail.com] Sent: Friday, April 22, 2016 11:28 AM To: Mazzei, Stephen Andrew Cc: flask at python.org Subject: Re: [Flask] Unpacking python list Hey Stephen, In your second for loop: it's unpacking each of the strings in your list to all those item# variables. If you notice, your 1st string is 14 characters long and you were trying to unpack it to 16 variables. You removed 2 variables from the loop and the 1st string works fine, but it now complains about the 2nd one that has a length of 6. Hope that helps, sorry if I messed up replying to your post. It's my first time writing on the mailing list. Cheers, Federico On Fri, Apr 22, 2016 at 4:09 PM, Mazzei, Stephen Andrew > wrote: Good morning, I have some back end python code pulling from a database generating the following list: ['Stephen Mazzei', 'cv7457', 'mazzei.s', 'non-employee', None, 'Stephen.Mazzei at asrcfederal.com', 'ASRC Federal Data Solutions', None, 'BECKETT RIDGE TECHNICAL CENTER', 'USA', 'HPC', 0, 10L, '10.0', '02/16/2016 09:22 AM', 'unlocked'] I then have in the jinja/html page a {% for item in list %}

{{item}}

{% endfor %} This generates the following on the HTML page Stephen Mazzei cv7457 mazzei.s non-employee None Stephen.Mazzei at asrcfederal.com ASRC Federal Data Solutions None BECKETT RIDGE TECHNICAL CENTER USA HPC 0 10 10.0 02/16/2016 09:22 AM unlocked In all the other pages I have written, I have been to do {% for item1, item2, item3, etc?., item16 in list %} And then use the values as needed in the templates. For some reason when doing this on this one page, I receive the error: ValueError: need more than 14 values to unpack If I take off the last two values it still errors but with ValueError: need more than 6 values to unpack Any ideas??? --- Stephen A. Mazzei Systems Administrator | AFDS, ASRC Federal Data Solutions - P&G HPC Account | 513-634-9965 ________________________________ The preceding message (including attachments) is covered by the Electronic Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended only for the person or entity to which it is addressed, and may contain information that is confidential, protected by attorney-client or other privilege, or otherwise protected from disclosure by law. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error and destroy the original message and all copies. _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask ________________________________ The preceding message (including attachments) is covered by the Electronic Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended only for the person or entity to which it is addressed, and may contain information that is confidential, protected by attorney-client or other privilege, or otherwise protected from disclosure by law. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error and destroy the original message and all copies. -------------- next part -------------- An HTML attachment was scrubbed... URL: From federicodinella at gmail.com Fri Apr 22 11:27:43 2016 From: federicodinella at gmail.com (Federico Di Nella) Date: Fri, 22 Apr 2016 16:27:43 +0100 Subject: [Flask] Unpacking python list In-Reply-To: References: Message-ID: Hey Stephen, In your second for loop: it's unpacking each of the strings in your list to all those item# variables. If you notice, your 1st string is 14 characters long and you were trying to unpack it to 16 variables. You removed 2 variables from the loop and the 1st string works fine, but it now complains about the 2nd one that has a length of 6. Hope that helps, sorry if I messed up replying to your post. It's my first time writing on the mailing list. Cheers, Federico On Fri, Apr 22, 2016 at 4:09 PM, Mazzei, Stephen Andrew < Stephen.Mazzei at asrcfederal.com> wrote: > Good morning, > > > > I have some back end python code pulling from a database generating the > following list: > > ['Stephen Mazzei', 'cv7457', 'mazzei.s', 'non-employee', None, ' > Stephen.Mazzei at asrcfederal.com', 'ASRC Federal Data Solutions', None, > 'BECKETT RIDGE TECHNICAL CENTER', 'USA', 'HPC', 0, 10L, '10.0', '02/16/2016 > 09:22 AM', 'unlocked'] > > > > I then have in the jinja/html page a > > {% for item in list %} > >

{{item}}

> > {% endfor %} > > > > This generates the following on the HTML page > > Stephen Mazzei > > cv7457 > > mazzei.s > > non-employee > > None > > Stephen.Mazzei at asrcfederal.com > > ASRC Federal Data Solutions > > None > > BECKETT RIDGE TECHNICAL CENTER > > USA > > HPC > > 0 > > 10 > > 10.0 > > 02/16/2016 09:22 AM > > unlocked > > > > In all the other pages I have written, I have been to do > > {% for item1, item2, item3, etc?., item16 in list %} > > > > And then use the values as needed in the templates. For some reason when > doing this on this one page, I receive the error: > > ValueError: need more than 14 values to unpack > > > > If I take off the last two values it still errors but with > > ValueError: need more than 6 values to unpack > > > > > > Any ideas??? > > > > > > > > --- > > Stephen A. Mazzei > > Systems Administrator | AFDS, ASRC Federal Data Solutions - P&G HPC > Account | 513-634-9965 > > > > ------------------------------ > > The preceding message (including attachments) is covered by the Electronic > Communication Privacy Act, 18 U.S.C. sections 2510-2512, is intended only > for the person or entity to which it is addressed, and may contain > information that is confidential, protected by attorney-client or other > privilege, or otherwise protected from disclosure by law. If you are not > the intended recipient, you are hereby notified that any retention, > dissemination, distribution, or copying of this communication is strictly > prohibited. Please reply to the sender that you have received the message > in error and destroy the original message and all copies. > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From plozano94 at gmail.com Fri Apr 22 12:46:21 2016 From: plozano94 at gmail.com (Pablo Lozano) Date: Fri, 22 Apr 2016 18:46:21 +0200 Subject: [Flask] When I execute, it start runnig two times. Message-ID: When I execute my flaskr.py script, I put a print to debug and it appears two times in console, so the code is running two times , some help? -------------- next part -------------- An HTML attachment was scrubbed... URL: From federicodinella at gmail.com Fri Apr 22 12:49:26 2016 From: federicodinella at gmail.com (Federico Di Nella) Date: Fri, 22 Apr 2016 17:49:26 +0100 Subject: [Flask] When I execute, it start runnig two times. In-Reply-To: References: Message-ID: Hi Pablo, do you mind pasting the relevant code that you wrote? (not the entire file, just the part where you wrote the print statement) It will be easier to help you that way. Cheers, Federico On Fri, Apr 22, 2016 at 5:46 PM, Pablo Lozano wrote: > When I execute my flaskr.py script, I put a print to debug and it appears > two times in console, so the code is running two times , some help? > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidism at gmail.com Fri Apr 22 13:12:06 2016 From: davidism at gmail.com (David Lord) Date: Fri, 22 Apr 2016 10:12:06 -0700 Subject: [Flask] When I execute, it start runnig two times. In-Reply-To: References: Message-ID: <571A5B66.2030400@gmail.com> http://stackoverflow.com/questions/25504149/why-does-running-the-flask-dev-server-run-itself-twice On 04/22/2016 09:46 AM, Pablo Lozano wrote: > When I execute my flaskr.py script, I put a print to debug and it > appears two times in console, so the code is running two times , some > help? > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Sun Apr 24 13:31:44 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Sun, 24 Apr 2016 13:31:44 -0400 Subject: [Flask] client side cached js/css files Message-ID: Does anyone have recommendations for dealing with client side cached js/css files when pushing out new versions? I was thinking about embedding version numbers into the files and incrementing them whenever I commit new versions. Or maybe adding something like ?ver=123 to the end of all resource links and incrementing that. Am I even asking the right question? From alejoar at gmail.com Sun Apr 24 13:42:00 2016 From: alejoar at gmail.com (Alejo Arias) Date: Sun, 24 Apr 2016 19:42:00 +0200 Subject: [Flask] client side cached js/css files In-Reply-To: References: Message-ID: Usually web developers use utilities like grunt to deal with this problem. Caching of files depends solely on the filename, so what certain grunt plugins do is simply change the filename of the js scripts to something new for each build (for instance, instead of yourscript.js, it ends up being called yourscript.201604241939.js and all references to the file are automatically updated to that name). I never came to this problem while using only flask, but it would certainly be nice to have an extension that does this job (if it doesn't exist yet?). We could make an extension with this functionality if there's interest and if it doesn't exist yet, thoughts? On 24 April 2016 at 19:31, Corey Boyle wrote: > Does anyone have recommendations for dealing with client side cached > js/css files when pushing out new versions? I was thinking about > embedding version numbers into the files and incrementing them > whenever I commit new versions. Or maybe adding something like > ?ver=123 to the end of all resource links and incrementing that. > > Am I even asking the right question? > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeff at jeffwidman.com Sun Apr 24 14:02:38 2016 From: jeff at jeffwidman.com (Jeff Widman) Date: Sun, 24 Apr 2016 11:02:38 -0700 Subject: [Flask] client side cached js/css files In-Reply-To: References: Message-ID: Check out flask-webpack extension... The creator has a good video and blog post and using it will provide an introduction to tools like webpack (browserify, grunt, gulp, etc) On Apr 24, 2016 10:32 AM, "Corey Boyle" wrote: > Does anyone have recommendations for dealing with client side cached > js/css files when pushing out new versions? I was thinking about > embedding version numbers into the files and incrementing them > whenever I commit new versions. Or maybe adding something like > ?ver=123 to the end of all resource links and incrementing that. > > Am I even asking the right question? > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Mon Apr 25 12:16:11 2016 From: ahall at autodist.com (Alex Hall) Date: Mon, 25 Apr 2016 12:16:11 -0400 Subject: [Flask] Possibly OT: result of form submission with Ajax is page's own sourcecode Message-ID: Hello all, I'm sorry if this is off topic. I've never seen this before, and I'm pretty new to web development. Hopefully it turns out to be something Flask is doing. I have a page made from templates and hosted by Flask. The page includes a form, with a couple JQuery datepickers, input fields, hidden fields, dropdown, and a checkbox. My JS normally posts the form to itself, which my view function handles. That view function returns the rendered template if the form was sent via GET or failed validation, else it grabs the form contents, queries a database, and sends back some JSON for JS to parse. Today, as I was adding the datepickers and doing some other changes, my form suddenly started displaying an error in the web console that it couldn't parse the JSON. When I told it to print the JSON, I got back a string that is simply the page's own source code, given back to it. Flask's command line is showing no errors, and my view function is working properly. Somehow, though, the form is being handed HTML code of the page instead of JSON. The only error is when the JS tries to parse this, since it can't. Other than that, I'm seeing no problems anywhere--no syntax problems, nothing missing, nothing at all. I don't know why the result of an Ajax call in JS would be my page's source code, or if that means anything in particular. Hopefully I'm making sense, and am not too off topic. Thanks in advance for any thoughts. -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From alejoar at gmail.com Mon Apr 25 13:03:55 2016 From: alejoar at gmail.com (Alejo Arias) Date: Mon, 25 Apr 2016 19:03:55 +0200 Subject: [Flask] Possibly OT: result of form submission with Ajax is page's own sourcecode In-Reply-To: References: Message-ID: Hi Alex, You should post an example of your code, but it sounds like what's happening is that you are using the same endpoint to return a json (when the form validates correctly) and a render_template when the validation fails. Then you submit something that doesn't validate and get the result you are experiencing. What I would do is create two endpoints instead, one that only renders the template and the other that only processes the form and always returns json that's readable by your js script. Regards, Alejo On 25 April 2016 at 18:16, Alex Hall wrote: > Hello all, > I'm sorry if this is off topic. I've never seen this before, and I'm > pretty new to web development. Hopefully it turns out to be something Flask > is doing. > > I have a page made from templates and hosted by Flask. The page includes a > form, with a couple JQuery datepickers, input fields, hidden fields, > dropdown, and a checkbox. My JS normally posts the form to itself, which my > view function handles. That view function returns the rendered template if > the form was sent via GET or failed validation, else it grabs the form > contents, queries a database, and sends back some JSON for JS to parse. > > Today, as I was adding the datepickers and doing some other changes, my > form suddenly started displaying an error in the web console that it > couldn't parse the JSON. When I told it to print the JSON, I got back a > string that is simply the page's own source code, given back to it. Flask's > command line is showing no errors, and my view function is working > properly. Somehow, though, the form is being handed HTML code of the page > instead of JSON. The only error is when the JS tries to parse this, since > it can't. Other than that, I'm seeing no problems anywhere--no syntax > problems, nothing missing, nothing at all. I don't know why the result of > an Ajax call in JS would be my page's source code, or if that means > anything in particular. Hopefully I'm making sense, and am not too off > topic. Thanks in advance for any thoughts. > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Mon Apr 25 13:51:24 2016 From: ahall at autodist.com (Alex Hall) Date: Mon, 25 Apr 2016 13:51:24 -0400 Subject: [Flask] Possibly OT: result of form submission with Ajax is page's own sourcecode In-Reply-To: References: Message-ID: I can try making separate functions. I think you explained a larger point that I was missing, though: the "return" in my view function returns the response. That means that I'm not just displaying the page, I'm telling my Ajax function that the page itself, as rendered from the template, *is* the JSON response. I've adapted my code to return an error, in JSON form, if the form is sent via post and fails validation, and the JSON of the database lookup if it passes validation and is post. If it's get, then return the template. This should let the page load when browsed to or refreshed, and will avoid returning the page code as the Ajax response. Now to figure out why validation is failing on a form with only a couple validators that shouldn't be stopping it. But that's another thread. :) Thanks for the help and the jog to my thinking about this. On Mon, Apr 25, 2016 at 1:03 PM, Alejo Arias wrote: > Hi Alex, > > You should post an example of your code, but it sounds like what's > happening is that you are using the same endpoint to return a json (when > the form validates correctly) and a render_template when the validation > fails. Then you submit something that doesn't validate and get the result > you are experiencing. > > What I would do is create two endpoints instead, one that only renders the > template and the other that only processes the form and always returns json > that's readable by your js script. > > Regards, > Alejo > > On 25 April 2016 at 18:16, Alex Hall wrote: > >> Hello all, >> I'm sorry if this is off topic. I've never seen this before, and I'm >> pretty new to web development. Hopefully it turns out to be something Flask >> is doing. >> >> I have a page made from templates and hosted by Flask. The page includes >> a form, with a couple JQuery datepickers, input fields, hidden fields, >> dropdown, and a checkbox. My JS normally posts the form to itself, which my >> view function handles. That view function returns the rendered template if >> the form was sent via GET or failed validation, else it grabs the form >> contents, queries a database, and sends back some JSON for JS to parse. >> >> Today, as I was adding the datepickers and doing some other changes, my >> form suddenly started displaying an error in the web console that it >> couldn't parse the JSON. When I told it to print the JSON, I got back a >> string that is simply the page's own source code, given back to it. Flask's >> command line is showing no errors, and my view function is working >> properly. Somehow, though, the form is being handed HTML code of the page >> instead of JSON. The only error is when the JS tries to parse this, since >> it can't. Other than that, I'm seeing no problems anywhere--no syntax >> problems, nothing missing, nothing at all. I don't know why the result of >> an Ajax call in JS would be my page's source code, or if that means >> anything in particular. Hopefully I'm making sense, and am not too off >> topic. Thanks in advance for any thoughts. >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Mon Apr 25 14:48:01 2016 From: ahall at autodist.com (Alex Hall) Date: Mon, 25 Apr 2016 14:48:01 -0400 Subject: [Flask] Form with no validators failing validation Message-ID: Hi list, As the subject says, my form is doing something odd. Though I've defined no validators for it at all, it's suddenly failing validation. I've tried validate() and validate_on_submit() with no change. My form is quite simple: class OrderSearchForm(Form): orderNumber = StringField("orderNumber") #orderNumber = StringField("orderNumber", validators=[Length(-1, 7, "If you enter an order number, it must be 5 or 7 characters.")]) orderGeneration = IntegerField("orderGeneration") startDate = StringField("startDate") endDate = StringField("endDate") hiddenStartDate = HiddenField("hiddenStartDate") hiddenEndDate = HiddenField("hiddenEndDate") maxResults = StringField("maxResults") hasErrors = BooleanField("hasErrors") users = SelectMultipleField("Users", choices=[(u, u) for u in userNames]) locations = SelectMultipleField("warehouses", choices=[(l, l) for l in locations]) I've defined usernames and locations already. When I output the field values, I see that my hidden date fields have values while my visible ones don't, and that everything else is fine--empty if I didn't enter data, presenting the text entered or options selected if I did anything to that field. That is, the form data seems to be passing back to the function with no problem, but it always fails. Here's my function: @app.route("/orderSearch", methods=searchMethods) def orderSearch(): searchForm = OrderSearchForm() #now that the form is constructed, we can set the label text properties of the elements searchForm.orderNumber.label.text = "Order number to search for" searchForm.orderGeneration.label.text = "Order generation (leave blank for all generations)" searchForm.startDate.label.text = "Starting date of search" searchForm.endDate.label.text = "End date of search" searchForm.maxResults.label.text = "Maximum results to return" searchForm.locations.label.text = "choose locations to include" searchForm.users.label.text = "user accounts to include" searchForm.hasErrors.label.text = "Only orders with errors" if request.method != "POST": print "Returning rendered template. Validated: %s. Method: %s." %(searchForm.validate(), request.method) return render_template("search.html", form=searchForm, title="Order Search") elif not searchForm.validate_on_submit(): print "Form failed validation." orderNumber = request.form.get("orderNumber", None) orderGeneration = request.form.get("orderGeneration", None) errorsOnly = bool(request.form.get("hasErrors", False)) locations = request.form.getlist("locations", None) users =request.form.getlist("users", None) startDate = request.form.getlist("startDate", None) endDate = request.form.getlist("endDate", None) hiddenStartDate = request.form.getlist("hiddenStartDate", None) hiddenEndDate = request.form.getlist("hiddenEndDate", None) maxResults = request.form.getlist("maxResults", None) print "Number: {number}\nGeneration: {generation}\nLocations: {locations}\nUsers: {users}\nErrors Only: {errorsOnly}\nStart Date: {startDate}\nEnd Date: {endDate}\nHidden Start Date: {hiddenStartDate}\nHidden End Date: {hiddenEndDate}".format(number=orderNumber, generation=orderGeneration, locations=locations, users=users, errorsOnly=errorsOnly, startDate=startDate, endDate=endDate, hiddenStartDate=hiddenStartDate, hiddenEndDate=hiddenEndDate) return json.dumps( { "errors": [ {"Number": 0, "Message": "The form failed validation."} ]} ) else: #the form was posted, and passed validation, so return the JSON print "Returning JSON." orderNumber = request.form.get("orderNumber", None) orderGeneration = request.form.get("orderGeneration", None) errorsOnly = bool(request.form.get("hasErrors", False)) locations = request.form.getlist("locations", None) users =request.form.getlist("users", None) maxResults = request.form.getlist("maxResults", None) print "Number: {number}\nGeneration: {generation}\nLocations: {locations}\nUsers: {users}\nErrors Only: {errorsOnly}".format(number=orderNumber, generation=orderGeneration, locations=locations, users=users, errorsOnly=errorsOnly) print request.form.hiddenStartDate print request.form.hiddenEndDate results = [] for result in DBInterface.getOrderDetails(orderNumber=orderNumber, orderGeneration=orderGeneration, locations=locations, users=users, errorsOnly=errorsOnly, limit=maxResults): results.append({ "username": result.user, "orderNumber": result.reference_3[:5], "orderGeneration": result.reference_3[5:7], "computer": result.computer, "errors": result.reference_9 }) return json.dumps(results) The only thing I've changed recently is the addition of the date fields, the visible two of which are tied via JS to JQueryUI date pickers and the hidden two of which are those pickers' altFields. They seem to work fine, though. I'm not sure why it would keep failing like this; again, there are no validators at all. I've killed the Flask server and restarted it, just to check that something odd wasn't going on there, but that didn't do anything. Is there anything else I could do? Any other code you'd need to see? -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ford.anthonyj at gmail.com Mon Apr 25 14:54:18 2016 From: ford.anthonyj at gmail.com (Anthony Ford) Date: Mon, 25 Apr 2016 14:54:18 -0400 Subject: [Flask] Form with no validators failing validation In-Reply-To: References: Message-ID: I'm about to board a flight, so forgive the short message and lack of links, but do you have csrf enabled? If so, there's a chance you might be running into that. You can force disable it in your form model and see if that resolves it, or you can include the form.hidden_tags in your template. I may have the spelling or capitalization wrong, so check the flask-wtf docs for details. --Anthony On Apr 25, 2016 2:49 PM, "Alex Hall" wrote: > Hi list, > As the subject says, my form is doing something odd. Though I've defined > no validators for it at all, it's suddenly failing validation. I've tried > validate() and validate_on_submit() with no change. My form is quite simple: > > class OrderSearchForm(Form): > orderNumber = StringField("orderNumber") > #orderNumber = StringField("orderNumber", validators=[Length(-1, 7, "If > you enter an order number, it must be 5 or 7 characters.")]) > orderGeneration = IntegerField("orderGeneration") > startDate = StringField("startDate") > endDate = StringField("endDate") > hiddenStartDate = HiddenField("hiddenStartDate") > hiddenEndDate = HiddenField("hiddenEndDate") > maxResults = StringField("maxResults") > hasErrors = BooleanField("hasErrors") > users = SelectMultipleField("Users", choices=[(u, u) for u in userNames]) > locations = SelectMultipleField("warehouses", choices=[(l, l) for l in > locations]) > > I've defined usernames and locations already. When I output the field > values, I see that my hidden date fields have values while my visible ones > don't, and that everything else is fine--empty if I didn't enter data, > presenting the text entered or options selected if I did anything to that > field. That is, the form data seems to be passing back to the function with > no problem, but it always fails. Here's my function: > > @app.route("/orderSearch", methods=searchMethods) > def orderSearch(): > searchForm = OrderSearchForm() > #now that the form is constructed, we can set the label text properties > of the elements > searchForm.orderNumber.label.text = "Order number to search for" > searchForm.orderGeneration.label.text = "Order generation (leave blank > for all generations)" > searchForm.startDate.label.text = "Starting date of search" > searchForm.endDate.label.text = "End date of search" > searchForm.maxResults.label.text = "Maximum results to return" > searchForm.locations.label.text = "choose locations to include" > searchForm.users.label.text = "user accounts to include" > searchForm.hasErrors.label.text = "Only orders with errors" > > if request.method != "POST": > print "Returning rendered template. Validated: %s. Method: %s." > %(searchForm.validate(), request.method) > return render_template("search.html", form=searchForm, title="Order > Search") > elif not searchForm.validate_on_submit(): > print "Form failed validation." > orderNumber = request.form.get("orderNumber", None) > orderGeneration = request.form.get("orderGeneration", None) > errorsOnly = bool(request.form.get("hasErrors", False)) > locations = request.form.getlist("locations", None) > users =request.form.getlist("users", None) > startDate = request.form.getlist("startDate", None) > endDate = request.form.getlist("endDate", None) > hiddenStartDate = request.form.getlist("hiddenStartDate", None) > hiddenEndDate = request.form.getlist("hiddenEndDate", None) > maxResults = request.form.getlist("maxResults", None) > print "Number: {number}\nGeneration: {generation}\nLocations: > {locations}\nUsers: {users}\nErrors Only: {errorsOnly}\nStart Date: > {startDate}\nEnd Date: {endDate}\nHidden Start Date: > {hiddenStartDate}\nHidden End Date: > {hiddenEndDate}".format(number=orderNumber, generation=orderGeneration, > locations=locations, users=users, errorsOnly=errorsOnly, > startDate=startDate, endDate=endDate, hiddenStartDate=hiddenStartDate, > hiddenEndDate=hiddenEndDate) > return json.dumps( > { "errors": [ > {"Number": 0, "Message": "The form failed validation."} > ]} > ) > else: #the form was posted, and passed validation, so return the JSON > print "Returning JSON." > orderNumber = request.form.get("orderNumber", None) > orderGeneration = request.form.get("orderGeneration", None) > errorsOnly = bool(request.form.get("hasErrors", False)) > locations = request.form.getlist("locations", None) > users =request.form.getlist("users", None) > maxResults = request.form.getlist("maxResults", None) > print "Number: {number}\nGeneration: {generation}\nLocations: > {locations}\nUsers: {users}\nErrors Only: > {errorsOnly}".format(number=orderNumber, generation=orderGeneration, > locations=locations, users=users, errorsOnly=errorsOnly) > print request.form.hiddenStartDate > print request.form.hiddenEndDate > results = [] > for result in DBInterface.getOrderDetails(orderNumber=orderNumber, > orderGeneration=orderGeneration, locations=locations, users=users, > errorsOnly=errorsOnly, limit=maxResults): > results.append({ > "username": result.user, > "orderNumber": result.reference_3[:5], > "orderGeneration": result.reference_3[5:7], > "computer": result.computer, > "errors": result.reference_9 > }) > return json.dumps(results) > > The only thing I've changed recently is the addition of the date fields, > the visible two of which are tied via JS to JQueryUI date pickers and the > hidden two of which are those pickers' altFields. They seem to work fine, > though. I'm not sure why it would keep failing like this; again, there are > no validators at all. I've killed the Flask server and restarted it, just > to check that something odd wasn't going on there, but that didn't do > anything. Is there anything else I could do? Any other code you'd need to > see? > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Mon Apr 25 15:01:18 2016 From: ahall at autodist.com (Alex Hall) Date: Mon, 25 Apr 2016 15:01:18 -0400 Subject: [Flask] Form with no validators failing validation In-Reply-To: References: Message-ID: I had it off, but was already using form.hidden_tag() anyway. I just turned it on, but got the same result. Good thought--I wouldn't have even considered CSRF--but sadly it didn't seem to make a difference. On Mon, Apr 25, 2016 at 2:54 PM, Anthony Ford wrote: > I'm about to board a flight, so forgive the short message and lack of > links, but do you have csrf enabled? If so, there's a chance you might be > running into that. You can force disable it in your form model and see if > that resolves it, or you can include the form.hidden_tags in your template. > > I may have the spelling or capitalization wrong, so check the flask-wtf > docs for details. > > --Anthony > On Apr 25, 2016 2:49 PM, "Alex Hall" wrote: > >> Hi list, >> As the subject says, my form is doing something odd. Though I've defined >> no validators for it at all, it's suddenly failing validation. I've tried >> validate() and validate_on_submit() with no change. My form is quite simple: >> >> class OrderSearchForm(Form): >> orderNumber = StringField("orderNumber") >> #orderNumber = StringField("orderNumber", validators=[Length(-1, 7, "If >> you enter an order number, it must be 5 or 7 characters.")]) >> orderGeneration = IntegerField("orderGeneration") >> startDate = StringField("startDate") >> endDate = StringField("endDate") >> hiddenStartDate = HiddenField("hiddenStartDate") >> hiddenEndDate = HiddenField("hiddenEndDate") >> maxResults = StringField("maxResults") >> hasErrors = BooleanField("hasErrors") >> users = SelectMultipleField("Users", choices=[(u, u) for u in userNames]) >> locations = SelectMultipleField("warehouses", choices=[(l, l) for l in >> locations]) >> >> I've defined usernames and locations already. When I output the field >> values, I see that my hidden date fields have values while my visible ones >> don't, and that everything else is fine--empty if I didn't enter data, >> presenting the text entered or options selected if I did anything to that >> field. That is, the form data seems to be passing back to the function with >> no problem, but it always fails. Here's my function: >> >> @app.route("/orderSearch", methods=searchMethods) >> def orderSearch(): >> searchForm = OrderSearchForm() >> #now that the form is constructed, we can set the label text properties >> of the elements >> searchForm.orderNumber.label.text = "Order number to search for" >> searchForm.orderGeneration.label.text = "Order generation (leave blank >> for all generations)" >> searchForm.startDate.label.text = "Starting date of search" >> searchForm.endDate.label.text = "End date of search" >> searchForm.maxResults.label.text = "Maximum results to return" >> searchForm.locations.label.text = "choose locations to include" >> searchForm.users.label.text = "user accounts to include" >> searchForm.hasErrors.label.text = "Only orders with errors" >> >> if request.method != "POST": >> print "Returning rendered template. Validated: %s. Method: %s." >> %(searchForm.validate(), request.method) >> return render_template("search.html", form=searchForm, title="Order >> Search") >> elif not searchForm.validate_on_submit(): >> print "Form failed validation." >> orderNumber = request.form.get("orderNumber", None) >> orderGeneration = request.form.get("orderGeneration", None) >> errorsOnly = bool(request.form.get("hasErrors", False)) >> locations = request.form.getlist("locations", None) >> users =request.form.getlist("users", None) >> startDate = request.form.getlist("startDate", None) >> endDate = request.form.getlist("endDate", None) >> hiddenStartDate = request.form.getlist("hiddenStartDate", None) >> hiddenEndDate = request.form.getlist("hiddenEndDate", None) >> maxResults = request.form.getlist("maxResults", None) >> print "Number: {number}\nGeneration: {generation}\nLocations: >> {locations}\nUsers: {users}\nErrors Only: {errorsOnly}\nStart Date: >> {startDate}\nEnd Date: {endDate}\nHidden Start Date: >> {hiddenStartDate}\nHidden End Date: >> {hiddenEndDate}".format(number=orderNumber, generation=orderGeneration, >> locations=locations, users=users, errorsOnly=errorsOnly, >> startDate=startDate, endDate=endDate, hiddenStartDate=hiddenStartDate, >> hiddenEndDate=hiddenEndDate) >> return json.dumps( >> { "errors": [ >> {"Number": 0, "Message": "The form failed validation."} >> ]} >> ) >> else: #the form was posted, and passed validation, so return the JSON >> print "Returning JSON." >> orderNumber = request.form.get("orderNumber", None) >> orderGeneration = request.form.get("orderGeneration", None) >> errorsOnly = bool(request.form.get("hasErrors", False)) >> locations = request.form.getlist("locations", None) >> users =request.form.getlist("users", None) >> maxResults = request.form.getlist("maxResults", None) >> print "Number: {number}\nGeneration: {generation}\nLocations: >> {locations}\nUsers: {users}\nErrors Only: >> {errorsOnly}".format(number=orderNumber, generation=orderGeneration, >> locations=locations, users=users, errorsOnly=errorsOnly) >> print request.form.hiddenStartDate >> print request.form.hiddenEndDate >> results = [] >> for result in DBInterface.getOrderDetails(orderNumber=orderNumber, >> orderGeneration=orderGeneration, locations=locations, users=users, >> errorsOnly=errorsOnly, limit=maxResults): >> results.append({ >> "username": result.user, >> "orderNumber": result.reference_3[:5], >> "orderGeneration": result.reference_3[5:7], >> "computer": result.computer, >> "errors": result.reference_9 >> }) >> return json.dumps(results) >> >> The only thing I've changed recently is the addition of the date fields, >> the visible two of which are tied via JS to JQueryUI date pickers and the >> hidden two of which are those pickers' altFields. They seem to work fine, >> though. I'm not sure why it would keep failing like this; again, there are >> no validators at all. I've killed the Flask server and restarted it, just >> to check that something odd wasn't going on there, but that didn't do >> anything. Is there anything else I could do? Any other code you'd need to >> see? >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From alejoar at gmail.com Mon Apr 25 15:08:17 2016 From: alejoar at gmail.com (Alejo Arias) Date: Mon, 25 Apr 2016 21:08:17 +0200 Subject: [Flask] Form with no validators failing validation In-Reply-To: References: Message-ID: Hi Alex, I don't know if you added this to your code already (it's not easy to read it on mobile) but did you try printing searchForm.errors after the validation? That will probably point out what the problem is. Regards, Alejo On Apr 25, 2016 21:02, "Alex Hall" wrote: I had it off, but was already using form.hidden_tag() anyway. I just turned it on, but got the same result. Good thought--I wouldn't have even considered CSRF--but sadly it didn't seem to make a difference. On Mon, Apr 25, 2016 at 2:54 PM, Anthony Ford wrote: > I'm about to board a flight, so forgive the short message and lack of > links, but do you have csrf enabled? If so, there's a chance you might be > running into that. You can force disable it in your form model and see if > that resolves it, or you can include the form.hidden_tags in your template. > > I may have the spelling or capitalization wrong, so check the flask-wtf > docs for details. > > --Anthony > On Apr 25, 2016 2:49 PM, "Alex Hall" wrote: > >> Hi list, >> As the subject says, my form is doing something odd. Though I've defined >> no validators for it at all, it's suddenly failing validation. I've tried >> validate() and validate_on_submit() with no change. My form is quite simple: >> >> class OrderSearchForm(Form): >> orderNumber = StringField("orderNumber") >> #orderNumber = StringField("orderNumber", validators=[Length(-1, 7, "If >> you enter an order number, it must be 5 or 7 characters.")]) >> orderGeneration = IntegerField("orderGeneration") >> startDate = StringField("startDate") >> endDate = StringField("endDate") >> hiddenStartDate = HiddenField("hiddenStartDate") >> hiddenEndDate = HiddenField("hiddenEndDate") >> maxResults = StringField("maxResults") >> hasErrors = BooleanField("hasErrors") >> users = SelectMultipleField("Users", choices=[(u, u) for u in userNames]) >> locations = SelectMultipleField("warehouses", choices=[(l, l) for l in >> locations]) >> >> I've defined usernames and locations already. When I output the field >> values, I see that my hidden date fields have values while my visible ones >> don't, and that everything else is fine--empty if I didn't enter data, >> presenting the text entered or options selected if I did anything to that >> field. That is, the form data seems to be passing back to the function with >> no problem, but it always fails. Here's my function: >> >> @app.route("/orderSearch", methods=searchMethods) >> def orderSearch(): >> searchForm = OrderSearchForm() >> #now that the form is constructed, we can set the label text properties >> of the elements >> searchForm.orderNumber.label.text = "Order number to search for" >> searchForm.orderGeneration.label.text = "Order generation (leave blank >> for all generations)" >> searchForm.startDate.label.text = "Starting date of search" >> searchForm.endDate.label.text = "End date of search" >> searchForm.maxResults.label.text = "Maximum results to return" >> searchForm.locations.label.text = "choose locations to include" >> searchForm.users.label.text = "user accounts to include" >> searchForm.hasErrors.label.text = "Only orders with errors" >> >> if request.method != "POST": >> print "Returning rendered template. Validated: %s. Method: %s." >> %(searchForm.validate(), request.method) >> return render_template("search.html", form=searchForm, title="Order >> Search") >> elif not searchForm.validate_on_submit(): >> print "Form failed validation." >> orderNumber = request.form.get("orderNumber", None) >> orderGeneration = request.form.get("orderGeneration", None) >> errorsOnly = bool(request.form.get("hasErrors", False)) >> locations = request.form.getlist("locations", None) >> users =request.form.getlist("users", None) >> startDate = request.form.getlist("startDate", None) >> endDate = request.form.getlist("endDate", None) >> hiddenStartDate = request.form.getlist("hiddenStartDate", None) >> hiddenEndDate = request.form.getlist("hiddenEndDate", None) >> maxResults = request.form.getlist("maxResults", None) >> print "Number: {number}\nGeneration: {generation}\nLocations: >> {locations}\nUsers: {users}\nErrors Only: {errorsOnly}\nStart Date: >> {startDate}\nEnd Date: {endDate}\nHidden Start Date: >> {hiddenStartDate}\nHidden End Date: >> {hiddenEndDate}".format(number=orderNumber, generation=orderGeneration, >> locations=locations, users=users, errorsOnly=errorsOnly, >> startDate=startDate, endDate=endDate, hiddenStartDate=hiddenStartDate, >> hiddenEndDate=hiddenEndDate) >> return json.dumps( >> { "errors": [ >> {"Number": 0, "Message": "The form failed validation."} >> ]} >> ) >> else: #the form was posted, and passed validation, so return the JSON >> print "Returning JSON." >> orderNumber = request.form.get("orderNumber", None) >> orderGeneration = request.form.get("orderGeneration", None) >> errorsOnly = bool(request.form.get("hasErrors", False)) >> locations = request.form.getlist("locations", None) >> users =request.form.getlist("users", None) >> maxResults = request.form.getlist("maxResults", None) >> print "Number: {number}\nGeneration: {generation}\nLocations: >> {locations}\nUsers: {users}\nErrors Only: >> {errorsOnly}".format(number=orderNumber, generation=orderGeneration, >> locations=locations, users=users, errorsOnly=errorsOnly) >> print request.form.hiddenStartDate >> print request.form.hiddenEndDate >> results = [] >> for result in DBInterface.getOrderDetails(orderNumber=orderNumber, >> orderGeneration=orderGeneration, locations=locations, users=users, >> errorsOnly=errorsOnly, limit=maxResults): >> results.append({ >> "username": result.user, >> "orderNumber": result.reference_3[:5], >> "orderGeneration": result.reference_3[5:7], >> "computer": result.computer, >> "errors": result.reference_9 >> }) >> return json.dumps(results) >> >> The only thing I've changed recently is the addition of the date fields, >> the visible two of which are tied via JS to JQueryUI date pickers and the >> hidden two of which are those pickers' altFields. They seem to work fine, >> though. I'm not sure why it would keep failing like this; again, there are >> no validators at all. I've killed the Flask server and restarted it, just >> to check that something odd wasn't going on there, but that didn't do >> anything. Is there anything else I could do? Any other code you'd need to >> see? >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> -- Alex Hall Automatic Distributors, IT department ahall at autodist.com _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Mon Apr 25 15:17:21 2016 From: ahall at autodist.com (Alex Hall) Date: Mon, 25 Apr 2016 15:17:21 -0400 Subject: [Flask] Form with no validators failing validation In-Reply-To: References: Message-ID: Thanks! I knew I could access errors for a given field, but I didn't realize it worked for whole forms. The problem was my IntegerField; I was leaving it blank, but it was complaining that '' is not a valid integer. That seems like a bug to me, but at least I have things working. On Mon, Apr 25, 2016 at 3:08 PM, Alejo Arias wrote: > Hi Alex, > > I don't know if you added this to your code already (it's not easy to read > it on mobile) but did you try printing searchForm.errors after the > validation? That will probably point out what the problem is. > > Regards, > Alejo > On Apr 25, 2016 21:02, "Alex Hall" wrote: > > I had it off, but was already using form.hidden_tag() anyway. I just > turned it on, but got the same result. Good thought--I wouldn't have even > considered CSRF--but sadly it didn't seem to make a difference. > > On Mon, Apr 25, 2016 at 2:54 PM, Anthony Ford > wrote: > >> I'm about to board a flight, so forgive the short message and lack of >> links, but do you have csrf enabled? If so, there's a chance you might be >> running into that. You can force disable it in your form model and see if >> that resolves it, or you can include the form.hidden_tags in your template. >> >> I may have the spelling or capitalization wrong, so check the flask-wtf >> docs for details. >> >> --Anthony >> On Apr 25, 2016 2:49 PM, "Alex Hall" wrote: >> >>> Hi list, >>> As the subject says, my form is doing something odd. Though I've defined >>> no validators for it at all, it's suddenly failing validation. I've tried >>> validate() and validate_on_submit() with no change. My form is quite simple: >>> >>> class OrderSearchForm(Form): >>> orderNumber = StringField("orderNumber") >>> #orderNumber = StringField("orderNumber", validators=[Length(-1, 7, "If >>> you enter an order number, it must be 5 or 7 characters.")]) >>> orderGeneration = IntegerField("orderGeneration") >>> startDate = StringField("startDate") >>> endDate = StringField("endDate") >>> hiddenStartDate = HiddenField("hiddenStartDate") >>> hiddenEndDate = HiddenField("hiddenEndDate") >>> maxResults = StringField("maxResults") >>> hasErrors = BooleanField("hasErrors") >>> users = SelectMultipleField("Users", choices=[(u, u) for u in >>> userNames]) >>> locations = SelectMultipleField("warehouses", choices=[(l, l) for l in >>> locations]) >>> >>> I've defined usernames and locations already. When I output the field >>> values, I see that my hidden date fields have values while my visible ones >>> don't, and that everything else is fine--empty if I didn't enter data, >>> presenting the text entered or options selected if I did anything to that >>> field. That is, the form data seems to be passing back to the function with >>> no problem, but it always fails. Here's my function: >>> >>> @app.route("/orderSearch", methods=searchMethods) >>> def orderSearch(): >>> searchForm = OrderSearchForm() >>> #now that the form is constructed, we can set the label text properties >>> of the elements >>> searchForm.orderNumber.label.text = "Order number to search for" >>> searchForm.orderGeneration.label.text = "Order generation (leave blank >>> for all generations)" >>> searchForm.startDate.label.text = "Starting date of search" >>> searchForm.endDate.label.text = "End date of search" >>> searchForm.maxResults.label.text = "Maximum results to return" >>> searchForm.locations.label.text = "choose locations to include" >>> searchForm.users.label.text = "user accounts to include" >>> searchForm.hasErrors.label.text = "Only orders with errors" >>> >>> if request.method != "POST": >>> print "Returning rendered template. Validated: %s. Method: %s." >>> %(searchForm.validate(), request.method) >>> return render_template("search.html", form=searchForm, title="Order >>> Search") >>> elif not searchForm.validate_on_submit(): >>> print "Form failed validation." >>> orderNumber = request.form.get("orderNumber", None) >>> orderGeneration = request.form.get("orderGeneration", None) >>> errorsOnly = bool(request.form.get("hasErrors", False)) >>> locations = request.form.getlist("locations", None) >>> users =request.form.getlist("users", None) >>> startDate = request.form.getlist("startDate", None) >>> endDate = request.form.getlist("endDate", None) >>> hiddenStartDate = request.form.getlist("hiddenStartDate", None) >>> hiddenEndDate = request.form.getlist("hiddenEndDate", None) >>> maxResults = request.form.getlist("maxResults", None) >>> print "Number: {number}\nGeneration: {generation}\nLocations: >>> {locations}\nUsers: {users}\nErrors Only: {errorsOnly}\nStart Date: >>> {startDate}\nEnd Date: {endDate}\nHidden Start Date: >>> {hiddenStartDate}\nHidden End Date: >>> {hiddenEndDate}".format(number=orderNumber, generation=orderGeneration, >>> locations=locations, users=users, errorsOnly=errorsOnly, >>> startDate=startDate, endDate=endDate, hiddenStartDate=hiddenStartDate, >>> hiddenEndDate=hiddenEndDate) >>> return json.dumps( >>> { "errors": [ >>> {"Number": 0, "Message": "The form failed validation."} >>> ]} >>> ) >>> else: #the form was posted, and passed validation, so return the JSON >>> print "Returning JSON." >>> orderNumber = request.form.get("orderNumber", None) >>> orderGeneration = request.form.get("orderGeneration", None) >>> errorsOnly = bool(request.form.get("hasErrors", False)) >>> locations = request.form.getlist("locations", None) >>> users =request.form.getlist("users", None) >>> maxResults = request.form.getlist("maxResults", None) >>> print "Number: {number}\nGeneration: {generation}\nLocations: >>> {locations}\nUsers: {users}\nErrors Only: >>> {errorsOnly}".format(number=orderNumber, generation=orderGeneration, >>> locations=locations, users=users, errorsOnly=errorsOnly) >>> print request.form.hiddenStartDate >>> print request.form.hiddenEndDate >>> results = [] >>> for result in DBInterface.getOrderDetails(orderNumber=orderNumber, >>> orderGeneration=orderGeneration, locations=locations, users=users, >>> errorsOnly=errorsOnly, limit=maxResults): >>> results.append({ >>> "username": result.user, >>> "orderNumber": result.reference_3[:5], >>> "orderGeneration": result.reference_3[5:7], >>> "computer": result.computer, >>> "errors": result.reference_9 >>> }) >>> return json.dumps(results) >>> >>> The only thing I've changed recently is the addition of the date fields, >>> the visible two of which are tied via JS to JQueryUI date pickers and the >>> hidden two of which are those pickers' altFields. They seem to work fine, >>> though. I'm not sure why it would keep failing like this; again, there are >>> no validators at all. I've killed the Flask server and restarted it, just >>> to check that something odd wasn't going on there, but that didn't do >>> anything. Is there anything else I could do? Any other code you'd need to >>> see? >>> >>> -- >>> Alex Hall >>> Automatic Distributors, IT department >>> ahall at autodist.com >>> >>> _______________________________________________ >>> Flask mailing list >>> Flask at python.org >>> https://mail.python.org/mailman/listinfo/flask >>> >>> > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From and.damore at gmail.com Mon Apr 25 15:52:15 2016 From: and.damore at gmail.com (Andrea D'Amore) Date: Mon, 25 Apr 2016 21:52:15 +0200 Subject: [Flask] Form with no validators failing validation In-Reply-To: References: Message-ID: On 25 April 2016 at 20:48, Alex Hall wrote: > searchForm = OrderSearchForm() > #now that the form is constructed, we can set the label text properties of > the elements > searchForm.orderNumber.label.text = "Order number to search for" [?] > searchForm.hasErrors.label.text = "Only orders with errors" Out of curiosity, why setting the labels in the view? -- Andrea From ahall at autodist.com Mon Apr 25 16:01:44 2016 From: ahall at autodist.com (Alex Hall) Date: Mon, 25 Apr 2016 16:01:44 -0400 Subject: [Flask] Form with no validators failing validation In-Reply-To: References: Message-ID: On Mon, Apr 25, 2016 at 3:52 PM, Andrea D'Amore wrote: > On 25 April 2016 at 20:48, Alex Hall wrote: > > searchForm = OrderSearchForm() > > #now that the form is constructed, we can set the label text properties > of > > the elements > > searchForm.orderNumber.label.text = "Order number to search for" > [?] > > searchForm.hasErrors.label.text = "Only orders with errors" > > Out of curiosity, why setting the labels in the view? > Because it worked. I know there must be an easier way, but I couldn't set it right in the form class as the properties didn't exist yet and so lacked the label property. I've just never bothered to look at how else to do it, but I'm sure there's a better way. > > > -- > Andrea > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From and.damore at gmail.com Tue Apr 26 03:08:10 2016 From: and.damore at gmail.com (Andrea D'Amore) Date: Tue, 26 Apr 2016 09:08:10 +0200 Subject: [Flask] Form with no validators failing validation In-Reply-To: References: Message-ID: On 25 April 2016 at 22:01, Alex Hall wrote: > Because it worked. I know there must be an easier way, I'd say in the form definition, as you are already doing with placeholders. > but I couldn't set it right in the form class as the properties didn't exist yet and so lacked the label property. Can you provide a SSCCE (short self-contained correct example [1] - this definitely needs a better name?) of this issue? [1]: http://sscce.org -- Andrea From ahall at autodist.com Tue Apr 26 08:44:05 2016 From: ahall at autodist.com (Alex Hall) Date: Tue, 26 Apr 2016 08:44:05 -0400 Subject: [Flask] Form with no validators failing validation In-Reply-To: References: Message-ID: In the form class, simply put myField.label.text = "some label text" Right away, Flask errors out: AttributeError: 'UnboundField' object has no attribute 'label' That's why I assumed I had to do it after instantiating the form. I even tried putting all my class properties in __init__, assigning them all to self (self.myField = StringField()), and then using self.myField.label.text, but I got the same error. The only difference is that the error shows on the webpage rather than in the command line. As usual, I'm probably missing something obvious. :) On Tue, Apr 26, 2016 at 3:08 AM, Andrea D'Amore wrote: > On 25 April 2016 at 22:01, Alex Hall wrote: > > Because it worked. I know there must be an easier way, > > I'd say in the form definition, as you are already doing with placeholders. > > > but I couldn't set it right in the form class as the properties didn't > exist yet and so lacked the label property. > > Can you provide a SSCCE (short self-contained correct example [1] - > this definitely needs a better name?) of this issue? > > [1]: http://sscce.org > > -- > Andrea > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Tue Apr 26 09:11:32 2016 From: ahall at autodist.com (Alex Hall) Date: Tue, 26 Apr 2016 09:11:32 -0400 Subject: [Flask] Form with no validators failing validation In-Reply-To: References: Message-ID: Final follow-up: I got it. I thought the first string passed to the constructor of the field gave it its ID, but the ID comes from the variable name (a neat trick). The string is the label text I want, explaining the multiple keywords error. You can disregard this thread, and sorry for the traffic. On Tue, Apr 26, 2016 at 9:04 AM, Alex Hall wrote: > Just a follow-up: I forgot to say that I also tried > > myField = StringField("myField", validators=[Optional()], label="my label > text goes here") > > and gotten the error: > TypeError: __init__() got multiple values for keyword argument 'label' > > As I said, I'm sure there's an easy way to do this, I just haven't found > it. > > On Tue, Apr 26, 2016 at 8:44 AM, Alex Hall wrote: > >> In the form class, simply put >> myField.label.text = "some label text" >> >> Right away, Flask errors out: >> AttributeError: 'UnboundField' object has no attribute 'label' >> >> That's why I assumed I had to do it after instantiating the form. I even >> tried putting all my class properties in __init__, assigning them all to >> self (self.myField = StringField()), and then using >> self.myField.label.text, but I got the same error. The only difference is >> that the error shows on the webpage rather than in the command line. As >> usual, I'm probably missing something obvious. :) >> >> On Tue, Apr 26, 2016 at 3:08 AM, Andrea D'Amore >> wrote: >> >>> On 25 April 2016 at 22:01, Alex Hall wrote: >>> > Because it worked. I know there must be an easier way, >>> >>> I'd say in the form definition, as you are already doing with >>> placeholders. >>> >>> > but I couldn't set it right in the form class as the properties didn't >>> exist yet and so lacked the label property. >>> >>> Can you provide a SSCCE (short self-contained correct example [1] - >>> this definitely needs a better name?) of this issue? >>> >>> [1]: http://sscce.org >>> >>> -- >>> Andrea >>> >> >> >> >> -- >> Alex Hall >> Automatic Distributors, IT department >> ahall at autodist.com >> > > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ahall at autodist.com Tue Apr 26 09:04:02 2016 From: ahall at autodist.com (Alex Hall) Date: Tue, 26 Apr 2016 09:04:02 -0400 Subject: [Flask] Form with no validators failing validation In-Reply-To: References: Message-ID: Just a follow-up: I forgot to say that I also tried myField = StringField("myField", validators=[Optional()], label="my label text goes here") and gotten the error: TypeError: __init__() got multiple values for keyword argument 'label' As I said, I'm sure there's an easy way to do this, I just haven't found it. On Tue, Apr 26, 2016 at 8:44 AM, Alex Hall wrote: > In the form class, simply put > myField.label.text = "some label text" > > Right away, Flask errors out: > AttributeError: 'UnboundField' object has no attribute 'label' > > That's why I assumed I had to do it after instantiating the form. I even > tried putting all my class properties in __init__, assigning them all to > self (self.myField = StringField()), and then using > self.myField.label.text, but I got the same error. The only difference is > that the error shows on the webpage rather than in the command line. As > usual, I'm probably missing something obvious. :) > > On Tue, Apr 26, 2016 at 3:08 AM, Andrea D'Amore > wrote: > >> On 25 April 2016 at 22:01, Alex Hall wrote: >> > Because it worked. I know there must be an easier way, >> >> I'd say in the form definition, as you are already doing with >> placeholders. >> >> > but I couldn't set it right in the form class as the properties didn't >> exist yet and so lacked the label property. >> >> Can you provide a SSCCE (short self-contained correct example [1] - >> this definitely needs a better name?) of this issue? >> >> [1]: http://sscce.org >> >> -- >> Andrea >> > > > > -- > Alex Hall > Automatic Distributors, IT department > ahall at autodist.com > -- Alex Hall Automatic Distributors, IT department ahall at autodist.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Tue Apr 26 16:41:16 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Tue, 26 Apr 2016 16:41:16 -0400 Subject: [Flask] client side cached js/css files In-Reply-To: References: Message-ID: I took a look at the flask-webpack extension, but it seemed to do a lot of things I wasn't really interested in at the moment. I just didn't want to go down that road quite yet. I ended up rolling my own solution that I would like to share in hopes it might be helpful to someone. Or... if I've done something dumb, maybe someone will point that out for me. *~ Part One ~* I added the following lines to my application factory. from checksumdir import dirhash # imports the checksumdir module that I installed via pip static_hash = dirhash('static', 'md5') # creates a string of an md5 hash of the contents of my static folder print 'static hash is', static_hash @app.template_global('static_hash') # creates a template global that I can call inside url_for def static_hash_func(): return static_hash Then I adjusted all my resources links inside my templates to add this hash value as a get parameter. {{url_for('static', filename='images/logo.png', ver=static_hash())}} *~ Part Two ~ Only needed for dev env* I added the following lines to my management script. #this block creates a list of directories inside my static folder extra_dirs = ['static/',] extra_files = [] for extra_dir in extra_dirs: for dirname, dirs, files in os.walk(extra_dir): extra_files.append(dirname) manager.add_command('run', Server(extra_files=extra_files)) # this line passes in those directories to the extra_files parm of the flask srv *~ Summary ~* The code in part one, simply generate a hash of the entire static directory and then uses that to add a "version" parameter to the requests for static files. The code in part two, simply tells the werkzeug reloader to watch for any changes in the static folder. I also set the SEND_FILE_MAX_AGE_DEFAULT in my config to 1 year. My entire site is served over HTTPS, so proxies shouldn't be an issue. -- Corey On Sun, Apr 24, 2016 at 2:02 PM, Jeff Widman wrote: > Check out flask-webpack extension... The creator has a good video and blog > post and using it will provide an introduction to tools like webpack > (browserify, grunt, gulp, etc) > On Apr 24, 2016 10:32 AM, "Corey Boyle" wrote: > >> Does anyone have recommendations for dealing with client side cached >> js/css files when pushing out new versions? I was thinking about >> embedding version numbers into the files and incrementing them >> whenever I commit new versions. Or maybe adding something like >> ?ver=123 to the end of all resource links and incrementing that. >> >> Am I even asking the right question? >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From darren.chuck at gmail.com Wed Apr 27 02:50:10 2016 From: darren.chuck at gmail.com (Darren Chuck) Date: Wed, 27 Apr 2016 14:50:10 +0800 Subject: [Flask] Problem of wfastcgi + flask + IIS 8 + python 3.5 Message-ID: Hi there, After setting web.config, we get the following error: Error occurred while reading WSGI handler: Traceback (most recent call last): File "c:\python\python35\lib\site-packages\wfastcgi.py", line 779, in main env, handler = read_wsgi_handler(response.physical_path) File "c:\python\python35\lib\site-packages\wfastcgi.py", line 621, in read_wsgi_handler handler = get_wsgi_handler(os.getenv('WSGI_HANDLER')) File "c:\python\python35\lib\site-packages\wfastcgi.py", line 594, in get_wsgi_handler handler = handler() TypeError: __call__() missing 2 required positional arguments: 'environ' and 'start_response' StdOut: StdErr: Is it because of compatibility or have we wrongly configured? The web.config file: Thanks, --Darren -------------- next part -------------- An HTML attachment was scrubbed... URL: From gabor at szabgab.com Wed Apr 27 04:39:41 2016 From: gabor at szabgab.com (Gabor Szabo) Date: Wed, 27 Apr 2016 11:39:41 +0300 Subject: [Flask] How to debug exceptions on the production server? In-Reply-To: <75af80e7-a1e3-eccb-ea94-a9eb5d41a1f7@gmail.com> References: <75af80e7-a1e3-eccb-ea94-a9eb5d41a1f7@gmail.com> Message-ID: Thanks for all the advice. I've added some logging. That seems to help for now, but I have to further explore this subject. regards Gabor -------------- next part -------------- An HTML attachment was scrubbed... URL: From aimanparvaiz at gmail.com Thu Apr 28 02:15:54 2016 From: aimanparvaiz at gmail.com (aiman parvaiz) Date: Thu, 28 Apr 2016 11:45:54 +0530 Subject: [Flask] Need advice in implementing news feed in flask Message-ID: Hi all, I am new to Python and am working on writing backend (REST API using Flask) for a Android app (Simple content posting app). I need advice in implementing a notification feed where a user can see all the activities related to their posts, for example: if some one commented on user's post it should show up on this feed. Also, there are some activities in this feed for which we need to show notification even if the user is not using the app (similar to push notification). I am new to Python and understand that a part of this can be achieved by Push notifications(GCM) but what should be the logic for showing events in feed which are not a part of push notification. I hope I was able to explain myself. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: