From lormayna at gmail.com Sat May 6 11:17:06 2017 From: lormayna at gmail.com (Lorenzo Mainardi) Date: Sat, 6 May 2017 17:17:06 +0200 Subject: [Flask] Help with Flask-WTF Message-ID: Hello, I'm trying to do something with Flask-Bootstrap and Flask-WTF. This is my app.py: from flask import Flask from flask_wtf.csrf import CsrfProtect from flask_bootstrap import Bootstrap app = Flask(__name__) Bootstrap(app) CsrfProtect(app) This is my template: {% extends "bootstrap/base.html" %} {% import "bootstrap/wtf.html" as wtf %} {% block title %} {% endblock %} {% block content %} {{ wtf.quick_form(form) }} {% include "footer.html" %} {% endblock %} This is the traceback (only last line): File "/home/lorenzo/projects/broen/lib/python2.7/site-packages/flask_bootstrap/templates/bootstrap/wtf.html", line 200, in template {{ form.hidden_tag() }} UndefinedError: 'forms.SignupForm object' has no attribute 'hidden_tag' All packages are installed via pip. Could you help me to solve it? Regards -- LORENZO MAINARDI http://blog.mainardi.me -------------- next part -------------- An HTML attachment was scrubbed... URL: From gergely at polonkai.eu Sat May 6 13:50:05 2017 From: gergely at polonkai.eu (Gergely Polonkai) Date: Sat, 06 May 2017 17:50:05 +0000 Subject: [Flask] Help with Flask-WTF In-Reply-To: References: Message-ID: I think this might be a bug in Flask-Bootstrap; the quick_form macro fails if there are no hidden fields in a form. Try adding a hidden field, like a CSRF token (you do CSRF protection, don't you?) Best, Gergely On Sat, May 6, 2017, 17:17 Lorenzo Mainardi wrote: > Hello, I'm trying to do something with Flask-Bootstrap and Flask-WTF. This > is my app.py: > > from flask import Flask > from flask_wtf.csrf import CsrfProtect > from flask_bootstrap import Bootstrap > > app = Flask(__name__) > Bootstrap(app) > CsrfProtect(app) > > This is my template: > > {% extends "bootstrap/base.html" %} > {% import "bootstrap/wtf.html" as wtf %} > > {% block title %} > > {% endblock %} > > {% block content %} > {{ wtf.quick_form(form) }} > {% include "footer.html" %} > {% endblock %} > > This is the traceback (only last line): > > File "/home/lorenzo/projects/broen/lib/python2.7/site-packages/flask_bootstrap/templates/bootstrap/wtf.html", line 200, in template > {{ form.hidden_tag() }} > UndefinedError: 'forms.SignupForm object' has no attribute 'hidden_tag' > > All packages are installed via pip. Could you help me to solve it? Regards > > -- > LORENZO MAINARDI > http://blog.mainardi.me > _______________________________________________ > 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 Sat May 6 23:32:22 2017 From: davidism at gmail.com (David Lord) Date: Sat, 6 May 2017 20:32:22 -0700 Subject: [Flask] Help with Flask-WTF In-Reply-To: References: Message-ID: You're using a WTForms Form, not a Flask-WTF FlaskForm. I guess quick_form doesn't handle that. On May 6, 2017 08:17, "Lorenzo Mainardi" wrote: > Hello, I'm trying to do something with Flask-Bootstrap and Flask-WTF. This > is my app.py: > > from flask import Flask > from flask_wtf.csrf import CsrfProtect > from flask_bootstrap import Bootstrap > > app = Flask(__name__) > Bootstrap(app) > CsrfProtect(app) > > This is my template: > > {% extends "bootstrap/base.html" %} > {% import "bootstrap/wtf.html" as wtf %} > > {% block title %} > > {% endblock %} > > {% block content %} > {{ wtf.quick_form(form) }} > {% include "footer.html" %} > {% endblock %} > > This is the traceback (only last line): > > File "/home/lorenzo/projects/broen/lib/python2.7/site-packages/flask_bootstrap/templates/bootstrap/wtf.html", line 200, in template > {{ form.hidden_tag() }} > UndefinedError: 'forms.SignupForm object' has no attribute 'hidden_tag' > > All packages are installed via pip. Could you help me to solve it? Regards > > -- > LORENZO MAINARDI > http://blog.mainardi.me > > _______________________________________________ > 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 May 9 15:30:40 2017 From: coreybrett at gmail.com (Corey Boyle) Date: Tue, 9 May 2017 15:30:40 -0400 Subject: [Flask] Password Handling Help In-Reply-To: References: Message-ID: Flask itself does not provide any authentication or authorization mechanisms. You have to add those yourself using your own code or Flask extensions. Check out these for examples. http://pythonhosted.org/Flask-Login/ http://pythonhosted.org/Flask-Principal https://pythonhosted.org/Flask-Security/ http://flask-stormpath.readthedocs.org/en/latest/ http://pythonhosted.org/Flask-User/ On Tue, Apr 25, 2017 at 4:23 PM, Osman Zakir wrote: > I?m sending this email because I want to ask where I can read up on some > info on how to allow a user of a web app I may be writing to change his/her > password. Thanks in advance for helpful answers or feedback. > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > From csantana at studioapp.com.br Thu May 11 14:50:09 2017 From: csantana at studioapp.com.br (Carlos Santana) Date: Thu, 11 May 2017 15:50:09 -0300 Subject: [Flask] Flask + boto3 + apache (mod_wsgi) Message-ID: Hi everyone. I am developing a restful api using Flask. The main goal of this API is to manage some resources on the AWS EC2 environment. Through a request to this api the server will check if some of our EC2 instances are running and for how long. The first step taken to perform this task was to write a code using only python libraries and boto3 api. The code worked like a charm. After this step I wrote a Flask endpoint to serve this request in the simplest way I could. Again, the code worked very well. The problems started to begin when this implementation was hosted on an apache server using mod_wsgi. I managed to configure the wsgi integration successfully and when I use the code to check if some of our instances were running an exception with this (truncated) traceback occurs: mod_wsgi (pid=4095): Exception occurred processing WSGI script '/var/www/siase/middleend/rest/cmd_server_wsgi.py'. Traceback (most recent call last): File "/var/www/anaconda3/lib/python3.5/site-packages/flask/app.py", line 2000, in __call__ return self.wsgi_app(environ, start_response) File "/var/www/anaconda3/lib/python3.5/site-packages/flask/app.py", line 1991, in wsgi_app response = self.make_response(self.handle_exception(e)) File "/var/www/anaconda3/lib/python3.5/site-packages/flask_cors/extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "/var/www/anaconda3/lib/python3.5/site-packages/flask/app.py", line 1567, in handle_exception (several lines) File "/var/www/anaconda3/lib/python3.5/site-packages/ botocore/vendored/requests/packages/urllib3/connectionpool.py", line 341, in _make_request self._validate_conn(conn) File "/var/www/anaconda3/lib/python3.5/site-packages/ botocore/vendored/requests/packages/urllib3/connectionpool.py", line 761, in _validate_conn conn.connect() File "/var/www/anaconda3/lib/python3.5/site-packages/ botocore/vendored/requests/packages/urllib3/connection.py", line 206, in connect resolved_cert_reqs = resolve_cert_reqs(self.cert_reqs) File "/var/www/anaconda3/lib/python3.5/site-packages/ botocore/vendored/requests/packages/urllib3/util/ssl_.py", line 157, in resolve_cert_reqs res = getattr(ssl, candidate, None) NameError: name 'ssl' is not defined This traceback only occurs when my code invokes some boto3 communication with EC2 service. In other cases, my endpoint works as expected. Here follows some details of the environment that I currently using: Apache/2.4.7 (Ubuntu) OpenSSL 1.0.1f mod_wsgi 4.5.5 Python 3.5.2 (Anaconda3 - 4.2.0) Flask 0.11.1 Boto3 1.4.4 To not overextend myself, please ask me what other information do you need regards my scenario. Thanks in advance PS: does this list accept attachments? -- Carlos Henrique Sant'Ana da Silva Analista de TI - studioApp -------------- next part -------------- An HTML attachment was scrubbed... URL: From skip.montanaro at gmail.com Fri May 12 10:58:44 2017 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Fri, 12 May 2017 09:58:44 -0500 Subject: [Flask] How to wrest complete control of log output location from Flask? Message-ID: In my Flask subclass, I override run() and set up self.logger just the way I want it: class FlaskApp(Flask): def run(self, ..., logfile): ... handler = FileHandler(logfile) handler.setFormatter(Formatter(...)) self.logger.handlers = [handler] ... super(FlaskApp, self).run(...) I guess in Flask.run it tacks on a StreamHandler instance, because all my logging goes to my file, but the traditional web server log lines still go to stdout or stderr. How do I make it stop that? I want everything to go to the file I define. Thx, Skip Montanaro From gergely at polonkai.eu Fri May 12 12:04:07 2017 From: gergely at polonkai.eu (Gergely Polonkai) Date: Fri, 12 May 2017 16:04:07 +0000 Subject: [Flask] How to wrest complete control of log output location from Flask? In-Reply-To: References: Message-ID: Take a look at Flask-Logging-Extras, which does exactly that, but without overriding Flask methods: https://pypi.python.org/pypi/Flask-Logging-Extras You may or may not like its functionality, but looking at its source code will answer your question. On Fri, May 12, 2017, 16:58 Skip Montanaro wrote: > In my Flask subclass, I override run() and set up self.logger just the > way I want it: > > class FlaskApp(Flask): > def run(self, ..., logfile): > ... > handler = FileHandler(logfile) > handler.setFormatter(Formatter(...)) > self.logger.handlers = [handler] > ... > super(FlaskApp, self).run(...) > > I guess in Flask.run it tacks on a StreamHandler instance, because all > my logging goes to my file, but the traditional web server log lines > still go to stdout or stderr. How do I make it stop that? I want > everything to go to the file I define. > > Thx, > > Skip Montanaro > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lormayna at gmail.com Sat May 13 13:45:22 2017 From: lormayna at gmail.com (Lorenzo Mainardi) Date: Sat, 13 May 2017 19:45:22 +0200 Subject: [Flask] Flask-WTF: BoolenaField not rendered Message-ID: Hello, I'm try to render a simple form with flask-wtf and quick_forms. This is my form: `class SignupForm(FlaskForm): username = StringField('Username', [validators.Length(min=4, max=25)]) accept_tos = BooleanField('I accept the TOS', [validators.DataRequired()]) prefs = BooleanField()` This is the template: {{ wtf.quick_form(form, action="/signup") }} Unfortunately the BooleanFields are not rendered. All the other fields look correct. -- LORENZO MAINARDI http://blog.mainardi.me -------------- next part -------------- An HTML attachment was scrubbed... URL: From dadygalo at gmail.com Sun May 14 02:06:24 2017 From: dadygalo at gmail.com (Dmitry Dygalo) Date: Sun, 14 May 2017 08:06:24 +0200 Subject: [Flask] Help request with extension development Message-ID: Hello everyone! I'm developing a simple Postmark (transaction emails service) integration for Flask and I'd like to ask for help :) I'm not an experienced Flask user and it is my first extension. It is here - https://github.com/Stranger6667/Flask-Postmark There is a wrapper for postmark API client, which is based on the documentation example from http://flask.pocoo.org/docs/0.12/extensiondev/ and I don't know if it is implemented in a good way or not. I'll appreciate any help, comments, tips and advices :) Thank you -- Best regards, Dmitry Dygalo -------------- next part -------------- An HTML attachment was scrubbed... URL: From scott.werner.vt at gmail.com Sun May 14 13:30:29 2017 From: scott.werner.vt at gmail.com (Scott Werner) Date: Sun, 14 May 2017 13:30:29 -0400 Subject: [Flask] How to wrest complete control of log output location from Flask? In-Reply-To: References: Message-ID: I use the following to clear and set my own log handlers in my flask app: def configure_logging(app): loggers = ['', 'flask', 'werkzeug'] level = logging.DEBUG if app.config['DEBUG'] else logging.INFO handlers = [] # Color handler color_format = '%(log_color)s%(asctime)s - %(levelname)s - %(name)s - %(message)s' color_handler = colorlog.StreamHandler() color_handler.setFormatter(colorlog.ColoredFormatter(color_format)) handlers.append(color_handler) # Configure each logger for logger in loggers: named_logger = logging.getLogger(logger) named_logger.setLevel(level) named_logger.handlers = [] # clear existing handlers for handler in handlers: named_logger.addHandler(handler) On Fri, May 12, 2017 at 12:04 PM, Gergely Polonkai wrote: > Take a look at Flask-Logging-Extras, which does exactly that, but without > overriding Flask methods: > > https://pypi.python.org/pypi/Flask-Logging-Extras > > You may or may not like its functionality, but looking at its source code > will answer your question. > > On Fri, May 12, 2017, 16:58 Skip Montanaro > wrote: > >> In my Flask subclass, I override run() and set up self.logger just the >> way I want it: >> >> class FlaskApp(Flask): >> def run(self, ..., logfile): >> ... >> handler = FileHandler(logfile) >> handler.setFormatter(Formatter(...)) >> self.logger.handlers = [handler] >> ... >> super(FlaskApp, self).run(...) >> >> I guess in Flask.run it tacks on a StreamHandler instance, because all >> my logging goes to my file, but the traditional web server log lines >> still go to stdout or stderr. How do I make it stop that? I want >> everything to go to the file I define. >> >> Thx, >> >> Skip Montanaro >> _______________________________________________ >> 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 > > -- Scott Werner scott.werner.vt at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidism at gmail.com Sun May 14 14:37:50 2017 From: davidism at gmail.com (David Lord) Date: Sun, 14 May 2017 11:37:50 -0700 Subject: [Flask] Help request with extension development In-Reply-To: References: Message-ID: I added a few issues after reviewing the code. Nothing serious though. Good job! On Sat, May 13, 2017 at 11:06 PM, Dmitry Dygalo wrote: > Hello everyone! > I'm developing a simple Postmark (transaction emails service) integration > for Flask and I'd like to ask for help :) I'm not an experienced Flask user > and it is my first extension. > It is here - https://github.com/Stranger6667/Flask-Postmark > There is a wrapper for postmark API client, which is based on the > documentation example from http://flask.pocoo.org/docs/0.12/extensiondev/ and > I don't know if it is implemented in a good way or not. I'll appreciate any > help, comments, tips and advices :) Thank you > > -- > Best regards, Dmitry Dygalo > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dadygalo at gmail.com Mon May 15 18:10:13 2017 From: dadygalo at gmail.com (Dmitry Dygalo) Date: Tue, 16 May 2017 00:10:13 +0200 Subject: [Flask] Help request with extension development Message-ID: Hello David! Thank you for the feedback! I'll update the code and add some documentation. Is it possible to add it to the extensions registry after all steps from the guide will be done? -- Best Regards, Dmitry Dygalo -------------- next part -------------- An HTML attachment was scrubbed... URL: From asa.lus at gmail.com Mon May 22 10:33:50 2017 From: asa.lus at gmail.com (=?UTF-8?Q?licence_Uni_Sp=C3=A9=5F=2D=5FAdministarttion_Ds_Sys_Appl_?=) Date: Mon, 22 May 2017 15:33:50 +0100 Subject: [Flask] flask SelectMultipleField save multiselection in database Message-ID: HELLO, I use the *SelectMultipleField *function but when I select several values in my en form I receive this error which comes from my server* MySQL[ (1241, 'Operand should contain 1 column(s)')]*. mat_actif = SelectMultipleField('Materiels :', choices = [ ('Port USB','Port USB'), ('Lecteur CD','Lecteur CD'), ('Aucun','Aucun')],) in my template i use : {{ wtf.quick_form(form, form_type='horizontal', horizontal_columns=('lg', 3, 6)) }} can you help me please. thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: From amundsen.craig at gene.com Wed May 24 09:40:47 2017 From: amundsen.craig at gene.com (Craig Amundsen) Date: Wed, 24 May 2017 06:40:47 -0700 Subject: [Flask] Form question Message-ID: Hi - I'm writing a flask app where the main part of the display contains three columns, 2 narrow ones with relatively unchanging content on either side of a wider column where most of the action occurs. I am basing my app on the example code from Grinberg's most excellent book. I've noticed that the default layout for forms make the form elements much narrower than the containing div and groups them to to the left. This is fine when I don't have my three column layout, but with it, I get very tiny form elements. My question: Is there a way to tell wtf-forms to use the entire width that is available rather than just the left hand side? Thanks, - Craig Amundsen -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Wed May 24 10:37:14 2017 From: coreybrett at gmail.com (Corey Boyle) Date: Wed, 24 May 2017 10:37:14 -0400 Subject: [Flask] Form question In-Reply-To: References: Message-ID: That would be a "styling" issue that would be addressed with CSS. Are you using Bootstrap? On May 24, 2017 9:45 AM, "Craig Amundsen" wrote: > Hi - > > I'm writing a flask app where the main part of the display contains three > columns, 2 narrow ones with relatively unchanging content on either side of > a wider column where most of the action occurs. I am basing my app on the > example code from Grinberg's most excellent book. > > I've noticed that the default layout for forms make the form elements much > narrower than the containing div and groups them to to the left. This is > fine when I don't have my three column layout, but with it, I get very tiny > form elements. > > My question: Is there a way to tell wtf-forms to use the entire width that > is available rather than just the left hand side? > > Thanks, > - Craig Amundsen > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From amundsen.craig at gene.com Wed May 24 10:42:14 2017 From: amundsen.craig at gene.com (Craig Amundsen) Date: Wed, 24 May 2017 07:42:14 -0700 Subject: [Flask] Form question In-Reply-To: References: Message-ID: Yes I am. I've found some google hits where people want to adjust the size of individual form elements, but nothing that addresses the overall width of the form. - Craig On Wed, May 24, 2017 at 7:37 AM, Corey Boyle wrote: > That would be a "styling" issue that would be addressed with CSS. Are you > using Bootstrap? > > On May 24, 2017 9:45 AM, "Craig Amundsen" wrote: > >> Hi - >> >> I'm writing a flask app where the main part of the display contains three >> columns, 2 narrow ones with relatively unchanging content on either side of >> a wider column where most of the action occurs. I am basing my app on the >> example code from Grinberg's most excellent book. >> >> I've noticed that the default layout for forms make the form elements >> much narrower than the containing div and groups them to to the left. This >> is fine when I don't have my three column layout, but with it, I get very >> tiny form elements. >> >> My question: Is there a way to tell wtf-forms to use the entire width >> that is available rather than just the left hand side? >> >> Thanks, >> - Craig Amundsen >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: