doc/book/en/devweb/views/xmlrss.rst
author Pierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 10 Jan 2012 16:33:27 +0100
changeset 8156 f47252e24354
parent 8032 bcb87336c7d2
permissions -rw-r--r--
[tableviews] use ``select_or_none`` instead of ``try: select() except:`` select_or_none is here to avoid multiplying try: except: context in the code.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2544
282261b26774 [doc] fixed some dangling internal links
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
     1
.. _XmlAndRss:
282261b26774 [doc] fixed some dangling internal links
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
     2
5312
d2dbba898a96 [doc/book] misc on views, docstrings
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
     3
XML and RSS views
d2dbba898a96 [doc/book] misc on views, docstrings
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
     4
-----------------
d2dbba898a96 [doc/book] misc on views, docstrings
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
     5
d2dbba898a96 [doc/book] misc on views, docstrings
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5266
diff changeset
     6
(:mod:`cubicweb.web.views.xmlrss`)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     7
4744
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
     8
Overview
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
     9
+++++++++
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    10
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    11
*rss*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    12
    Creates a RSS/XML view and call the view `rssitem` for each entity of
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    13
    the result set.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    14
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    15
*rssitem*
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    16
    Create a RSS/XML view for each entity based on the results of the dublin core
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    17
    methods of the entity (`dc_*`)
4744
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    18
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    19
RSS Channel Example
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    20
++++++++++++++++++++
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    21
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    22
Assuming you have several blog entries, click on the title of the
8032
bcb87336c7d2 [doc] fix most of ReST compilation errors and warnings
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5394
diff changeset
    23
search box in the left column. A larger search box should appear. Enter:
bcb87336c7d2 [doc] fix most of ReST compilation errors and warnings
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5394
diff changeset
    24
bcb87336c7d2 [doc] fix most of ReST compilation errors and warnings
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5394
diff changeset
    25
.. sourcecode:: sql
4744
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    26
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    27
   Any X ORDERBY D WHERE X is BlogEntry, X creation_date D
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    28
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    29
and you get a list of blog entries.
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    30
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    31
Click on your login at the top right corner. Chose "user preferences",
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    32
then "boxes", then "possible views box" and check "visible = yes"
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    33
before validating your changes.
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    34
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    35
Enter the same query in the search box and you will see the same list,
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    36
plus a box titled "possible views" in the left column. Click on
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    37
"entityview", then "RSS".
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    38
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    39
You just applied the "RSS" view to the RQL selection you requested.
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    40
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    41
That's it, you have a RSS channel for your blog.
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    42
8032
bcb87336c7d2 [doc] fix most of ReST compilation errors and warnings
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5394
diff changeset
    43
Try again with:
bcb87336c7d2 [doc] fix most of ReST compilation errors and warnings
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5394
diff changeset
    44
bcb87336c7d2 [doc] fix most of ReST compilation errors and warnings
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5394
diff changeset
    45
.. sourcecode:: sql
4744
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    46
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    47
    Any X ORDERBY D WHERE X is BlogEntry, X creation_date D,
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    48
    X entry_of B, B title "MyLife"
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    49
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    50
Another RSS channel, but a bit more focused.
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    51
8032
bcb87336c7d2 [doc] fix most of ReST compilation errors and warnings
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5394
diff changeset
    52
A last one for the road:
bcb87336c7d2 [doc] fix most of ReST compilation errors and warnings
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5394
diff changeset
    53
bcb87336c7d2 [doc] fix most of ReST compilation errors and warnings
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5394
diff changeset
    54
.. sourcecode:: sql
4744
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    55
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    56
    Any C ORDERBY D WHERE C is Comment, C creation_date D LIMIT 15
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    57
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    58
displayed with the RSS view, that's a channel for the last fifteen
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    59
comments posted.
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    60
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    61
[WRITE ME]
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    62
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    63
* show that the RSS view can be used to display an ordered selection
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    64
  of blog entries, thus providing a RSS channel
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    65
0772d4e29d52 [book] cleanup (deleting/moving) old stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2544
diff changeset
    66
* show that a different selection (by category) means a different channel