From John.Robson at usp.br Thu Sep 8 21:13:38 2016 From: John.Robson at usp.br (John Robson) Date: Thu, 8 Sep 2016 21:13:38 -0400 Subject: [Flask] Simultaneous Matplotlib "QObject" error Message-ID: Hi all, I have some pages that plot charts using Matplotlib, they work very well, but when running them simultaneously they break, with errors like: "QObject: Cannot create children for a parent that is in a different thread." "QObject::~QObject: Timers cannot be stopped from another thread" I wonder how to safely use Matplolib with Flask (and several simultaneous users plotting stuff all the time)? Thank you, John From jaysinhp at gmail.com Fri Sep 9 13:18:32 2016 From: jaysinhp at gmail.com (Jaysinh Shukla) Date: Fri, 9 Sep 2016 22:48:32 +0530 Subject: [Flask] [X-POST] Regarding invition for Dev sprint of Pycon India Message-ID: <7b151f1f-4f2a-43a7-c726-29ccb5bb05ff@gmail.com> Respected Member, Dev Sprint is the best way to collaborate/guide other contributors physically rather than over IRC / email. We invite this community to join and hack for whole 3 days during the conference. Programmers are dreaming of contributing but they are unable to just because of lacking guidance. It will be a proud moment to mentor participants for whole three days and encourage them to be the active contributor for the project. Large contributing guidelines are always hard to digest. CFP is already started. We invite you to submit a proposal [here](https://in.pycon.org/cfp/dev-sprint-2016/proposals/). Schedule for Dev sprint [Pycon India, New Delhi](https://in.pycon.org) * Day-I: 23rd September 2016 - Full day * Day-II: 24th September 2016 - 5.00 PM to 9.00 PM * Day-III: 25th September 2016 - 5.00 PM to 9.00 PM Note: If you are reading this mail and you believe referring interested contributors will help to represent project well, feel free to drop me a mail. I will try to invite them individually. Many Thanks! From John.Robson at usp.br Fri Sep 9 17:26:13 2016 From: John.Robson at usp.br (John Robson) Date: Fri, 9 Sep 2016 17:26:13 -0400 Subject: [Flask] Simultaneous Matplotlib "QObject" error In-Reply-To: References: Message-ID: I found the main problem, I followed this and worked: http://matplotlib.org/faq/howto_faq.html#howto-webapp "matplotlib.use('Agg')" for not print, only save figures. I also fixed other problems, I was using "plt.savefig", "plt.xxx" I believe that this "plt" was harming other simultaneous plots, so I replaced every "plt." by ".fig" and now I think is OK. I just wonder how can I isolate each plot from other simultaneous plots, I'm doing this: fig = plt.figure() ax = fig.gca() > plot stuff, scatterplot, etc..., set title, lables, etc... fig = ax.get_figure() fig.set_tight_layout(True) fig.savefig(filename, format='png', dpi=100, facecolor='w', edgecolor='k', bbox_inches='tight') fig.clf() plt.close(fig) So the first "fig" instance is destroyed at the end and there is no "plt.xxx" This is a good approach to isolate all plots? Thank you, John On 09/08/16 21:13, John Robson wrote: > Hi all, > > I have some pages that plot charts using Matplotlib, they work very > well, but when running them simultaneously they break, with errors like: > > "QObject: Cannot create children for a parent that is in a different > thread." > > "QObject::~QObject: Timers cannot be stopped from another thread" > > I wonder how to safely use Matplolib with Flask (and several > simultaneous users plotting stuff all the time)? > > Thank you, > John From and.damore at gmail.com Sat Sep 10 03:59:45 2016 From: and.damore at gmail.com (Andrea D'Amore) Date: Sat, 10 Sep 2016 09:59:45 +0200 Subject: [Flask] Simultaneous Matplotlib "QObject" error In-Reply-To: References: Message-ID: On 9 September 2016 at 23:26, John Robson wrote: > I also fixed other problems, I was using "plt.savefig", "plt.xxx" I believe that this "plt" was harming other simultaneous plots, It's hard to figure what was happening without seeing the code. The pyplot interface is just a state on the object-oriented, more general, one; this way you get to quickly call the "current" figure or axes, but it's nothing more magic than this. I suggest using the object-oriented api and keeping the objects you need in your code, it makes things much clearer. > so I replaced every "plt." by ".fig" and now I think is OK. That doesn't look right, as it's written. > I just wonder how can I isolate each plot from other simultaneous plots, I'm doing this: > > fig = plt.figure() > ax = fig.gca() > > plot stuff, scatterplot, etc..., set title, lables, etc... > fig = ax.get_figure() [?] > So the first "fig" instance is destroyed at the end The first "instance" is the same as last, from what you wrote you got a figure, then its axes, then again this axes' figure that is of course the same object you started with. > fig.clf() > plt.close(fig) [?] > and there is no "plt.xxx" There clearly is the plt.close() call at the end. > This is a good approach to isolate all plots? What do you mean by "isolate all plots" there? When I had to generate many image files I felt more natural keep the Figure instance in the loop that called savefig(), I only changed the plot in the "central" axes thus keeping the common layout to all images. -- Andrea From alex-alex-90 at wp.pl Sat Sep 10 19:06:12 2016 From: alex-alex-90 at wp.pl (Alex Alex) Date: Sun, 11 Sep 2016 01:06:12 +0200 Subject: [Flask] single function handling form from base template Message-ID: <57d491e4673974.31401792@wp.pl> Hi, I have another question: I am using blueprints for different application modules but I have a single search function that handles form from base.html template that is being extended by all blueprints. How can I handle it since I'm using flash() to return search result and I need to redirect to particular page the query has been entered? I guess request.url_rule is the way to go. Any help will be greatly appreciated. Best Regards, Alex From coreybrett at gmail.com Sat Sep 10 19:26:41 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Sat, 10 Sep 2016 19:26:41 -0400 Subject: [Flask] single function handling form from base template In-Reply-To: <57d491e4673974.31401792@wp.pl> References: <57d491e4673974.31401792@wp.pl> Message-ID: You could setup a "search" view and have the form's action set to GET to the search view function. Do anything you want in the view function with the GET args. On Sep 10, 2016 7:13 PM, "Alex Alex" wrote: > Hi, > I have another question: I am using blueprints for different application > modules but I have a single search function that handles form from > base.html template that is being extended by all blueprints. How can I > handle it since I'm using flash() to return search result and I need to > redirect to particular page the query has been entered? I guess > request.url_rule is the way to go. Any help will be greatly appreciated. > Best Regards, > Alex > > > > > > > > _______________________________________________ > 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 Sep 11 10:51:10 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Sun, 11 Sep 2016 10:51:10 -0400 Subject: [Flask] Bash on Win10 In-Reply-To: References: Message-ID: Has anyone had any experience with Windows 10's new Bash feature for Flask development? If not, what about developing Flask on Windows in general? -------------- next part -------------- An HTML attachment was scrubbed... URL: From millings at mit.edu Wed Sep 7 13:46:07 2016 From: millings at mit.edu (Joshua N Millings) Date: Wed, 7 Sep 2016 17:46:07 +0000 Subject: [Flask] [please forward to appropriate list] Flask Tutorial Broken on Windows 10 Message-ID: <2C597309DDD8AA4F8CC48407C2328F59015CC6A7CA@W92EXPO28.exchange.mit.edu> With the set FLASK_APP=flaskr set FLASK_DEBUG=1 flask run cannot find flask.py.There is no change when directory extensions are used or when the debugger is switched off. With set FLASK_APP=flaskr set FLASK_DEBUG=1 python -m flask run the website is accessible from a browser, however a builtin.importerror is displayed. There is no change with the debugger being switched off or with the extensions being added to flaskr. -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex-alex-90 at wp.pl Mon Sep 12 15:10:17 2016 From: alex-alex-90 at wp.pl (Alex Alex) Date: Mon, 12 Sep 2016 21:10:17 +0200 Subject: [Flask] Search options for Flask Message-ID: <57d6fd99bd4691.10570861@wp.pl> I'm looking for a database search solution compatible with SQLAlchemy with sqlite and postgresql. At first flask-whooshalchemy seemed like a great option but it seems its development has stopped and it generates some compatybility warnings and according to this https://github.com/gyllstromk/Flask-WhooshAlchemy/issues/21 it requires SQLALCHEMY_TRACK_MODIFICATIONS to be set to True. But even after those changes it still misses some search result on text columns. So I like the idea how it supposed to work, but it is not working correctly in my case and it seems it is using deprecated options. Elasticsearch is another option but it requires additional process to be run and I would like to keep my architecture as simple as possible (and at one point I will need to run celery and redis to handle async jobs but that is future). I could get away for some cases with SQLAlchemy filter.like('%%') queries but those will not handle all the search cases. My question is what are you guys using for searching through text data? What are your recommendations? Cheers, Alex From scott.werner.vt at gmail.com Mon Sep 12 15:39:48 2016 From: scott.werner.vt at gmail.com (Scott Werner) Date: Mon, 12 Sep 2016 15:39:48 -0400 Subject: [Flask] Search options for Flask In-Reply-To: <57d6fd99bd4691.10570861@wp.pl> References: <57d6fd99bd4691.10570861@wp.pl> Message-ID: I would look into using full text search for PostgreSQL. It was pretty straight forward to implement and was good enough for my app. However, since you have the requirement for SQLite, you will need to look into the SQLite FTS5 Extension also. On Mon, Sep 12, 2016 at 3:10 PM, Alex Alex wrote: > I'm looking for a database search solution compatible with SQLAlchemy with > sqlite and postgresql. At first flask-whooshalchemy seemed like a great > option but it seems its development has stopped and it generates some > compatybility warnings and according to this > https://github.com/gyllstromk/Flask-WhooshAlchemy/issues/21 it requires > SQLALCHEMY_TRACK_MODIFICATIONS to be set to True. But even after those > changes it still misses some search result on text columns. So I like the > idea how it > supposed to work, but it is not working correctly in my case and it seems > it is using deprecated options. > > Elasticsearch is another option but it requires additional process to be > run and I would like to keep my architecture as simple as possible (and at > one point I will need to run celery and redis to handle async jobs but that > is future). > > I could get away for some cases with SQLAlchemy filter.like('%%') queries > but those will not handle all the search cases. > > My question is what are you guys using for searching through text data? > What are your recommendations? > Cheers, > Alex > > > > > > > > > _______________________________________________ > 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 coreybrett at gmail.com Mon Sep 12 15:53:14 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Mon, 12 Sep 2016 15:53:14 -0400 Subject: [Flask] Search options for Flask In-Reply-To: References: <57d6fd99bd4691.10570861@wp.pl> Message-ID: @Alex - Are you using SQLite for development only? I was doing that for awhile, but kept finding errors in my code that were not triggered by SQLite, but were by PostgreSQL. I ended up switching to PostgreSQL for my dev environment as well. On Mon, Sep 12, 2016 at 3:39 PM, Scott Werner wrote: > I would look into using full text search for PostgreSQL. It was pretty > straight forward to implement and was good enough for my app. However, since > you have the requirement for SQLite, you will need to look into the SQLite > FTS5 Extension also. > > On Mon, Sep 12, 2016 at 3:10 PM, Alex Alex wrote: >> >> I'm looking for a database search solution compatible with SQLAlchemy with >> sqlite and postgresql. At first flask-whooshalchemy seemed like a great >> option but it seems its development has stopped and it generates some >> compatybility warnings and according to this >> https://github.com/gyllstromk/Flask-WhooshAlchemy/issues/21 it requires >> SQLALCHEMY_TRACK_MODIFICATIONS to be set to True. But even after those >> changes it still misses some search result on text columns. So I like the >> idea how it >> supposed to work, but it is not working correctly in my case and it seems >> it is using deprecated options. >> >> Elasticsearch is another option but it requires additional process to be >> run and I would like to keep my architecture as simple as possible (and at >> one point I will need to run celery and redis to handle async jobs but that >> is future). >> >> I could get away for some cases with SQLAlchemy filter.like('%%') queries >> but those will not handle all the search cases. >> >> My question is what are you guys using for searching through text data? >> What are your recommendations? >> Cheers, >> Alex >> >> >> >> >> >> >> >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask > > > > > -- > Scott Werner > scott.werner.vt at gmail.com > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > From davidism at gmail.com Mon Sep 12 15:57:43 2016 From: davidism at gmail.com (David Lord) Date: Mon, 12 Sep 2016 19:57:43 +0000 Subject: [Flask] Search options for Flask In-Reply-To: References: <57d6fd99bd4691.10570861@wp.pl> Message-ID: Here's a quick full text search over multiple fields for PostgreSQL with SQLAlchemy: https://github.com/sopython/sopython-site/blob/1.6/sopy/canon/forms.py#L77. -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex-alex-90 at wp.pl Tue Sep 13 17:38:25 2016 From: alex-alex-90 at wp.pl (Alex Alex) Date: Tue, 13 Sep 2016 23:38:25 +0200 Subject: [Flask] Odp: Re: Search options for Flask Message-ID: <57d871d114fcd3.30304085@wp.pl> Guys, thank you for all your input - I'm reviewing options you've suggested. As a quick fix it turn out that I have been able to make Whoosh working with this package: https://github.com/bkabrda/flask-whooshee. What I really liked about previous approach was __searchable__ attribute. It was IMHO the most simple and clear method enabling full-text search for particular fields within ORM class. I'm not using sqlite3 only as dev server but actually the client app that works with server app uses it too in order to not to force users to install PostgreSQL. I had similar cases with MySQL - it was catching errors or choking on some request that were fine with sqlite and vice versa while in both cases using Python db api. I have one more question: I have to store text files inside database. The full-text search function is used to locate simple keywords in those text files. So far I'm just returning the list of files containing particular keyword (just as proof that current solution actually work). How would you implement providing info about particular line(s) containing the keyword. I need to return at least line number with keyword. I am thinking about loading files into memory and scanning them line by line but maybe there is a better approach. I'm sorry if this sounds like a stupid or trivial question but as I've written before I'm new to such assignment. Thanks in advance, Alex From coreybrett at gmail.com Tue Sep 13 21:18:59 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Tue, 13 Sep 2016 21:18:59 -0400 Subject: [Flask] Odp: Re: Search options for Flask In-Reply-To: <57d871d114fcd3.30304085@wp.pl> References: <57d871d114fcd3.30304085@wp.pl> Message-ID: Store each line as a DB record instead of the whole file as a record? Or a background worker/queue that inserts files into the database and indexs them in the process? On Sep 13, 2016 5:39 PM, "Alex Alex" wrote: > Guys, thank you for all your input - I'm reviewing options you've > suggested. As a quick fix it turn out that I have been able to make Whoosh > working with this package: https://github.com/bkabrda/flask-whooshee. > What I really liked about previous approach was __searchable__ attribute. > It was IMHO the most simple and clear method enabling full-text search for > particular fields within ORM class. > > I'm not using sqlite3 only as dev server but actually the client app that > works with server app uses it too in order to not to force users to install > PostgreSQL. I had similar cases with MySQL - it was catching errors or > choking on some request that were fine with sqlite and vice versa while in > both cases using Python db api. > > I have one more question: I have to store text files inside database. The > full-text search function is used to locate simple keywords in those text > files. So far I'm just returning the list of files containing particular > keyword (just as proof that current solution actually work). How would you > implement providing info about particular line(s) containing the keyword. I > need to return at least line number with keyword. I am thinking about > loading files into memory and scanning them line by line > but maybe there is a better approach. I'm sorry if this sounds like a > stupid or trivial question but as I've written before I'm new to such > assignment. > Thanks in advance, > Alex > > > > > > > > _______________________________________________ > 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 Sep 21 18:09:33 2016 From: amundsen.craig at gene.com (Craig Amundsen) Date: Wed, 21 Sep 2016 15:09:33 -0700 Subject: [Flask] Deploying on httpd and mod_wsgi Message-ID: Hello - I have written an app based on the example app in the Grinberg book. It works great running on the dev server on my laptop. I'm now trying to deploy it on a CentOS 7 machine running httpd with mod_wsgi. I'm not having much luck getting it to start. According to all the configuration pages I've read, app_name.wsgi should look like this import sys sys.path.insert(0, "/var/www/app_name") from app_name import app as application If I try running that by hand I get this error: Traceback (most recent call last): File "", line 1, in ImportError: No module named LCD The structure of the app_name directory looks like this: app_name |---> app |---> __init__.py decorators.py main/ other things you'd expect to see config.py app_name.wsgi manage.py tests/, migrations/, etc I suspect that this is because in the example app from the book, there is no __init__.py file in app_name directory. Can anyone point me in the proper direction to get this app to start up properly? Thanks, - Craig -------------- next part -------------- An HTML attachment was scrubbed... URL: From amundsen.craig at gene.com Thu Sep 22 16:29:58 2016 From: amundsen.craig at gene.com (Craig Amundsen) Date: Thu, 22 Sep 2016 13:29:58 -0700 Subject: [Flask] Deploying on httpd and mod_wsgi In-Reply-To: <57e43d10e4ad86.95656875@wp.pl> References: <57e43d10e4ad86.95656875@wp.pl> Message-ID: Hi - Yeah, I was trying to be cute and use a different python installation, but I've read a bit more and it looks like my mod_wsgi module was built against the system python, so the easiest thing now is it use a virtualenv and and tell mod_wsgi that that's what I'm doing. - Craig On Thu, Sep 22, 2016 at 1:20 PM, Alex Alex wrote: > Hi, > I'm not an expert on mod_wsgi and Apache. In fact I've used it many years > ago for the last time. > > Are you sure your imports are fine? The error says that you are missing > LCD module - probably it is installed on your laptop but not the on the > server. Without seeing your requirements.txt and flask app imports I guess > it will be hard to say something more. > > As for Apache unless you have some special requirements you may want to > check out gunicorn - it works nicely with flask applications and is python > based. That is how I run test instances on Heroku actually. > Cheers > Alex > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From amundsen.craig at gene.com Thu Sep 22 16:28:25 2016 From: amundsen.craig at gene.com (Craig Amundsen) Date: Thu, 22 Sep 2016 13:28:25 -0700 Subject: [Flask] Deploying on httpd and mod_wsgi In-Reply-To: <57e43d10e4ad86.95656875@wp.pl> References: <57e43d10e4ad86.95656875@wp.pl> Message-ID: Thanks for all the suggestions. In order to let the internet remember this for me, here's what worked. In the mod_wsgi docs there's a throwaway line about if you don't have a factory method put "from app import app as application". The example app you build in the Grinberg book does have you implement a factory method. This .wsgi file worked for me: ================================ import os import sys sys.path.insert(0, "/var/www/CraigsApplication") from app import create_app application = create_app(os.getenv('FLASK_CONFIG') or 'default') ================================ Thanks for the prompting about using a virtualenv. I'm not using one and that's my next stumbling block. I don't have root on this machine and I didn't want to use the system python, so I built my own more current python. In my .bashrc I have ensured that the path to my custom python is before /usr/bin so when I log in I get the correct python. Apache/mod_wsgi, though, are using /usr/bin/python which doesn't have any of the Flask-required libraries. Can anyone tell me how I force it to use a non-default python? Thanks, - Craig On Thu, Sep 22, 2016 at 1:20 PM, Alex Alex wrote: > Hi, > I'm not an expert on mod_wsgi and Apache. In fact I've used it many years > ago for the last time. > > Are you sure your imports are fine? The error says that you are missing > LCD module - probably it is installed on your laptop but not the on the > server. Without seeing your requirements.txt and flask app imports I guess > it will be hard to say something more. > > As for Apache unless you have some special requirements you may want to > check out gunicorn - it works nicely with flask applications and is python > based. That is how I run test instances on Heroku actually. > Cheers > Alex > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex-alex-90 at wp.pl Thu Sep 22 16:20:32 2016 From: alex-alex-90 at wp.pl (Alex Alex) Date: Thu, 22 Sep 2016 22:20:32 +0200 Subject: [Flask] Odp: Deploying on httpd and mod_wsgi Message-ID: <57e43d10e4ad86.95656875@wp.pl> Hi, I'm not an expert on mod_wsgi and Apache. In fact I've used it many years ago for the last time. Are you sure your imports are fine? The error says that you are missing LCD module - probably it is installed on your laptop but not the on the server. Without seeing your requirements.txt and flask app imports I guess it will be hard to say something more. As for Apache unless you have some special requirements you may want to check out gunicorn - it works nicely with flask applications and is python based. That is how I run test instances on Heroku actually. Cheers Alex From coreybrett at gmail.com Thu Sep 22 17:21:16 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Thu, 22 Sep 2016 17:21:16 -0400 Subject: [Flask] Deploying on httpd and mod_wsgi In-Reply-To: References: <57e43d10e4ad86.95656875@wp.pl> Message-ID: Maybe something along the lines of... import sys import os INTERP = os.path.expanduser("~/env/[appname]/bin/python") if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv) sys.path.append(os.getcwd()) from [appname] import app as application On Sep 22, 2016 4:56 PM, "Craig Amundsen" wrote: > Thanks for all the suggestions. In order to let the internet remember this > for me, here's what worked. In the mod_wsgi docs there's a throwaway line > about if you don't have a factory method put "from app import app as > application". > > The example app you build in the Grinberg book does have you implement a > factory method. This .wsgi file worked for me: > > ================================ > import os > import sys > > sys.path.insert(0, "/var/www/CraigsApplication") > > from app import create_app > application = create_app(os.getenv('FLASK_CONFIG') or 'default') > ================================ > > Thanks for the prompting about using a virtualenv. I'm not using one and > that's my next stumbling block. I don't have root on this machine and I > didn't want to use the system python, so I built my own more current > python. In my .bashrc I have ensured that the path to my custom python is > before /usr/bin so when I log in I get the correct python. Apache/mod_wsgi, > though, are using /usr/bin/python which doesn't have any of the > Flask-required libraries. > > Can anyone tell me how I force it to use a non-default python? > > Thanks, > - Craig > > On Thu, Sep 22, 2016 at 1:20 PM, Alex Alex wrote: > >> Hi, >> I'm not an expert on mod_wsgi and Apache. In fact I've used it many years >> ago for the last time. >> >> Are you sure your imports are fine? The error says that you are missing >> LCD module - probably it is installed on your laptop but not the on the >> server. Without seeing your requirements.txt and flask app imports I guess >> it will be hard to say something more. >> >> As for Apache unless you have some special requirements you may want to >> check out gunicorn - it works nicely with flask applications and is python >> based. That is how I run test instances on Heroku actually. >> Cheers >> Alex >> >> >> > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From barak.bloch at gmail.com Mon Sep 26 08:33:18 2016 From: barak.bloch at gmail.com (Barak Bloch) Date: Mon, 26 Sep 2016 15:33:18 +0300 Subject: [Flask] Flask admin - add id attr to each row in module list view page Message-ID: Hey I want to add ids to each row data in the model table in list view (id foreach ). what is the best/right way to do it? i need the id to be unique (with the primary key) for each row so a frontend guy that work with me can access data easily by a list of pk's. Thanks, Barak. -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Mon Sep 26 08:45:21 2016 From: coreybrett at gmail.com (Corey Boyle) Date: Mon, 26 Sep 2016 08:45:21 -0400 Subject: [Flask] Flask admin - add id attr to each row in module list view page In-Reply-To: References: Message-ID: Something like... {% for item in items %} {% endfor %}
{{item.firstname}} {{item.lastname}}
-------------- next part -------------- An HTML attachment was scrubbed... URL: From alex-alex-90 at wp.pl Wed Sep 28 15:19:12 2016 From: alex-alex-90 at wp.pl (Alex Alex) Date: Wed, 28 Sep 2016 21:19:12 +0200 Subject: [Flask] splitting models into blueprints Message-ID: <57ec17b075a256.11469841@wp.pl> Hi, Up to this point I've been using single models file in mine main package that contains all flask blueprints but since models tend to grow quickly and the file starts to be unreadable I'd like to split model definition between separate blueprints: for example I have a blueprint dealing with users so all user related models could be stored there. The potential problem I see are relations between different models blueprints. The simple solution I see it to use __tablename__ to enforce proper table name through SQLAlchemy and use those names across blueprints. So my question is: are there any best practices or tips regarding such design? The only tips I've found so far are about moving models into separate file not across different blueprints. Please note that my models have also number of relations (both one-to-many and many-to-many). Best Regards, Alex From robertlagrant at gmail.com Wed Sep 28 16:30:13 2016 From: robertlagrant at gmail.com (Robert Grant) Date: Wed, 28 Sep 2016 13:30:13 -0700 Subject: [Flask] splitting models into blueprints Message-ID: <-6006041425504524367@unknownmsgid> You can import a model from another file and refer to it directly. Does that do what you want? Rob Sent from my phoneFrom: Alex Alex Sent: ?28/?09/?2016 20:19 To: flask Subject: [Flask] splitting models into blueprints Hi, Up to this point I've been using single models file in mine main package that contains all flask blueprints but since models tend to grow quickly and the file starts to be unreadable I'd like to split model definition between separate blueprints: for example I have a blueprint dealing with users so all user related models could be stored there. The potential problem I see are relations between different models blueprints. The simple solution I see it to use __tablename__ to enforce proper table name through SQLAlchemy and use those names across blueprints. So my question is: are there any best practices or tips regarding such design? The only tips I've found so far are about moving models into separate file not across different blueprints. Please note that my models have also number of relations (both one-to-many and many-to-many). Best Regards, Alex _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask From alex-alex-90 at wp.pl Wed Sep 28 16:51:54 2016 From: alex-alex-90 at wp.pl (Alex Alex) Date: Wed, 28 Sep 2016 22:51:54 +0200 Subject: [Flask] Odp: RE: splitting models into blueprints Message-ID: <57ec2d6a3a2758.83873427@wp.pl> This is exactly what I am doing currently. Alex > You can import a model from another file and refer to it directly. Does > that do what you want? > > > Rob From josh.milas at gmail.com Thu Sep 29 18:50:15 2016 From: josh.milas at gmail.com (Joshua Milas) Date: Thu, 29 Sep 2016 18:50:15 -0400 Subject: [Flask] Getting routes of a blueprint Message-ID: Hello, Is there a way to get the routes defined in a blueprint? I know this ( http://flask.pocoo.org/snippets/117/) snippit exists, but requires to have the app initalized to use url_map. Is there a way to view the routes without an application? I'm developing an api with flask-restful and I would like to display the routes from within the blueprint without the app to keep it self contained. Thanks, - Joshua Milas -------------- next part -------------- An HTML attachment was scrubbed... URL: