librelist archives

« back to archive

Questions regarding a flask project with rss and backend

Questions regarding a flask project with rss and backend

From:
Carsten Brueggenolte
Date:
2013-03-21 @ 17:06
Hello everyone,

I thought about it for a week now since google said that they will
shutdown reader. Now as a good starting project, I thought I take the
flask introduction project, small blogging, and modify it to display a
couple of feeds that I subscribe to.

I want to use feedparser for that and already looked at the documentation.

/intro - question:

What would be a good way to grab and store the feeds? Basically all I
need is the title, the URL and the date.

Which type of database would you suggest and which database framework?

But the most important question I have is: how do I get the app to
retrieve new feeds without me refreshing the page or calling a refresh
method? Is there a way to implement a background process?

I don't know if this is too much as a starter but I think it's a nice
project to learn a lot of different technologies.

Thanks for any help and all tips

Best regards
Carsten.

----------
Von einem mobilen Gerät gesendet

Re: [flask] Questions regarding a flask project with rss and backend

From:
Shawn Milochik
Date:
2013-03-21 @ 17:36
On Thu, Mar 21, 2013 at 1:06 PM, Carsten Brueggenolte
<cbrueggenolte@gmail.com> wrote:

> What would be a good way to grab and store the feeds? Basically all I
> need is the title, the URL and the date.
>

Use the 'requests' library to get the info from the feed servers.

> Which type of database would you suggest and which database framework?

Postgres in production, sqlite3 in development. Store the actual feed data
in Redis so you can enjoy the built-in expiration.

>
> But the most important question I have is: how do I get the app to
> retrieve new feeds without me refreshing the page or calling a refresh
> method? Is there a way to implement a background process?

Cron is an option. So is Celery.

Re: [flask] Questions regarding a flask project with rss and backend

From:
Carsten Brüggenolte
Date:
2013-03-21 @ 18:29
thanks  

will have a look at this librarys   


-- Carsten


Am Donnerstag, 21. März 2013 um 18:36 schrieb Shawn Milochik:

> On Thu, Mar 21, 2013 at 1:06 PM, Carsten Brueggenolte
> <cbrueggenolte@gmail.com (mailto:cbrueggenolte@gmail.com)> wrote:
>  
> > What would be a good way to grab and store the feeds? Basically all I
> > need is the title, the URL and the date.
> >  
>  
>  
> Use the 'requests' library to get the info from the feed servers.
>  
> > Which type of database would you suggest and which database framework?
>  
> Postgres in production, sqlite3 in development. Store the actual feed data
> in Redis so you can enjoy the built-in expiration.
>  
> >  
> > But the most important question I have is: how do I get the app to
> > retrieve new feeds without me refreshing the page or calling a refresh
> > method? Is there a way to implement a background process?
> >  
>  
>  
> Cron is an option. So is Celery.  

Re: [flask] Questions regarding a flask project with rss and backend

From:
Matthew Hoopes
Date:
2013-03-21 @ 19:06
An alternative to celery is http://python-rq.org/

Much easier to work with, IMO...


On Thu, Mar 21, 2013 at 1:36 PM, Shawn Milochik <shawn@milochik.com> wrote:

> On Thu, Mar 21, 2013 at 1:06 PM, Carsten Brueggenolte
> <cbrueggenolte@gmail.com> wrote:
>
> > What would be a good way to grab and store the feeds? Basically all I
> > need is the title, the URL and the date.
> >
>
> Use the 'requests' library to get the info from the feed servers.
>
> > Which type of database would you suggest and which database framework?
>
> Postgres in production, sqlite3 in development. Store the actual feed data
> in Redis so you can enjoy the built-in expiration.
>
> >
> > But the most important question I have is: how do I get the app to
> > retrieve new feeds without me refreshing the page or calling a refresh
> > method? Is there a way to implement a background process?
>
> Cron is an option. So is Celery.
>

Re: [flask] Questions regarding a flask project with rss and backend

From:
Shawn Milochik
Date:
2013-03-21 @ 19:10
On Thu, Mar 21, 2013 at 3:06 PM, Matthew Hoopes
<matthew.hoopes@gmail.com> wrote:
> An alternative to celery is http://python-rq.org/
>
> Much easier to work with, IMO...
>

I agree and love rq, but it just provides async processing, not scheduled jobs.

If the original goal was to update the RSS data periodically on the
server (and not upon page load), then the Celery "periodic_task"
feature (or cron) would work. But rq would not.

Re: [flask] Questions regarding a flask project with rss and backend

From:
Carsten Brueggenolte
Date:
2013-03-21 @ 20:55
Hi everyone,

Thank you very much for pointing me to these tools.
I am very new to python and i will need some time to study all this.
But keeps me busy. Thanks



----------
Von einem mobilen Gerät gesendet

Am 21.03.2013 um 20:12 schrieb Shawn Milochik <shawn@milochik.com>:

> On Thu, Mar 21, 2013 at 3:06 PM, Matthew Hoopes
> <matthew.hoopes@gmail.com> wrote:
>> An alternative to celery is http://python-rq.org/
>>
>> Much easier to work with, IMO...
>
> I agree and love rq, but it just provides async processing, not scheduled jobs.
>
> If the original goal was to update the RSS data periodically on the
> server (and not upon page load), then the Celery "periodic_task"
> feature (or cron) would work. But rq would not.

Re: Questions regarding a flask project with rss and backend

From:
Pete Forman
Date:
2013-03-22 @ 09:47
Shawn Milochik <shawn@milochik.com> writes:

> On Thu, Mar 21, 2013 at 3:06 PM, Matthew Hoopes
> <matthew.hoopes@gmail.com> wrote:
>> An alternative to celery is http://python-rq.org/
>>
>> Much easier to work with, IMO...
>>
>
> I agree and love rq, but it just provides async processing, not
> scheduled jobs.
>
> If the original goal was to update the RSS data periodically on the
> server (and not upon page load), then the Celery "periodic_task"
> feature (or cron) would work. But rq would not.
>

APScheduler is lighter weight than Celery but should be suitable for the
OP's needs.

-- 
Pete Forman

Re: [flask] Re: Questions regarding a flask project with rss and backend

From:
Shawn Milochik
Date:
2013-03-24 @ 15:44
On Fri, Mar 22, 2013 at 5:47 AM, Pete Forman <petef4+usenet@gmail.com> wrote:
> APScheduler is lighter weight than Celery but should be suitable for the
> OP's needs.

Thanks for the tip. It looks like a combination of this and rq would
work well for replacing Celery.

Decorating all methods in Flask-Admin

From:
Tark
Date:
2013-03-23 @ 17:32
Hello {{ username }}!

I have method named nocache

def nocache(f):
    def new_func(*args, **kwargs):
        resp = make_response(f(*args, **kwargs))
        resp.cache_control.no_cache = True
        return resp
    return update_wrapper(new_func, f)

and I want decorate all methods in my class, something like

@nocache
class Shops(AccessibleView): # /admin/shops
    @expose('/')
    def index(self):
        return self.render('admin/shops/list.html', shops=db.shops.find())

    @expose('/add', methods=['GET', 'POST'])
    def item_add(self):
        if request.method == 'POST':
            pass

        return self.render('admin/shops/item.html', task='add')
# -----------

Now I have following error: RuntimeError: working outside of application 
context.
What I need to do? Decorate each method individually? That's... 
uncomfortable.

Thanks! 

Re: [flask] Decorating all methods in Flask-Admin

From:
Serge S. Koval
Date:
2013-03-23 @ 17:42
You're trying to wrap generic class with the decorator. Instead, you
should wrap individual views.

If you really want to wrap all views at once, you can do it in
constructor by iterating over self._urls:
https://github.com/mrjoes/flask-admin/blob/master/flask_admin/base.py#L211

Serge.

On Sat, Mar 23, 2013 at 7:32 PM, Tark <tark.hidden@gmail.com> wrote:
> Hello {{ username }}!
>
> I have method named nocache
>
> def nocache(f):
>     def new_func(*args, **kwargs):
>         resp = make_response(f(*args, **kwargs))
>         resp.cache_control.no_cache = True
>         return resp
>     return update_wrapper(new_func, f)
>
> and I want decorate all methods in my class, something like
>
> @nocache
> class Shops(AccessibleView): # /admin/shops
>     @expose('/')
>     def index(self):
>         return self.render('admin/shops/list.html', shops=db.shops.find())
>
>     @expose('/add', methods=['GET', 'POST'])
>     def item_add(self):
>         if request.method == 'POST':
>             pass
>
>         return self.render('admin/shops/item.html', task='add')
> # -----------
>
> Now I have following error: RuntimeError: working outside of application
> context.
> What I need to do? Decorate each method individually? That's...
> uncomfortable.
>
> Thanks!
>