If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

in models/ feeds_reader.py

def group_feed_reader(group,mode='div'):
    """parse group feeds"""

    url = "http://groups.google.com/group/%s/feed/rss_v2_0_msgs.xml" % group
    from gluon.contrib import feedparser
    g = feedparser.parse(url)
    if mode == 'div':
        html = XML(DIV(UL(*[LI(A(entry['title'],_href=entry['link'],_target='_blank'))\
                            for entry in g['entries'][0:5]]),\
                       _class="boxInfo",\
                       _style="padding-bottom:5px;"))
    else:
        html = XML(UL(*[LI(A(entry['title'],_href=entry['link'],_target='_blank'))\
                            for entry in g['entries'][0:5]]))


    return html


def code_feed_reader(project,mode='div'):
    """parse google code feeds"""

    url = "http://code.google.com/feeds/p/%s/hgchanges/basic" % project
    from gluon.contrib import feedparser
    g = feedparser.parse(url)
    if mode == 'div':
        html = XML(DIV(UL(*[LI(A(entry['title'],_href=entry['link'],_target='_blank'))\
                            for entry in g['entries'][0:5]]),\
                       _class="boxInfo",\
                       _style="padding-bottom:5px;"))
    else:
        html = XML(UL(*[LI(A(entry['title'],_href=entry['link'],_target='_blank'))\
                            for entry in g['entries'][0:5]]))


    return html

In any view or controller:

To read latest entries from google group :

{{=group_feed_reader(group='web2py',mode='nodiv')}}

To read latest google code source updates:

{{=code_feed_reader(project='web2py',mode='nodiv')}}

Related slices

Comments (0)


Hosting graciously provided by:
Python Anywhere