author | Nicolas Chauvat <nicolas.chauvat@logilab.fr> |
Thu, 20 May 2010 10:40:55 +0200 | |
branch | stable |
changeset 5548 | d29d1a1ce15d |
parent 5424 | 8ecbcbff9777 |
child 5556 | 9ab2b4c74baf |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
1547 | 18 |
"""Specific views for SIOC interfaces |
19 |
||
20 |
""" |
|
21 |
__docformat__ = "restructuredtext en" |
|
22 |
||
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
23 |
from logilab.mtconverter import xml_escape |
1547 | 24 |
|
25 |
from cubicweb.view import EntityView |
|
26 |
from cubicweb.selectors import implements |
|
27 |
from cubicweb.interfaces import ISiocItem, ISiocContainer |
|
28 |
||
29 |
class SIOCView(EntityView): |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
30 |
__regid__ = 'sioc' |
1547 | 31 |
__select__ = EntityView.__select__ & implements(ISiocItem, ISiocContainer) |
32 |
title = _('sioc') |
|
33 |
templatable = False |
|
34 |
content_type = 'text/xml' |
|
35 |
||
36 |
def call(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
37 |
self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self._cw.encoding) |
1547 | 38 |
self.w(u'''<rdf:RDF |
39 |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
|
40 |
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" |
|
41 |
xmlns:owl="http://www.w3.org/2002/07/owl#" |
|
42 |
xmlns:foaf="http://xmlns.com/foaf/0.1/" |
|
43 |
xmlns:sioc="http://rdfs.org/sioc/ns#" |
|
44 |
xmlns:sioctype="http://rdfs.org/sioc/types#" |
|
45 |
xmlns:dcterms="http://purl.org/dc/terms/">\n''') |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
46 |
for i in xrange(self.cw_rset.rowcount): |
1547 | 47 |
self.cell_call(i, 0) |
48 |
self.w(u'</rdf:RDF>\n') |
|
49 |
||
50 |
def cell_call(self, row, col): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
51 |
self.wview('sioc_element', self.cw_rset, row=row, col=col) |
1547 | 52 |
|
53 |
class SIOCContainerView(EntityView): |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
54 |
__regid__ = 'sioc_element' |
1547 | 55 |
__select__ = EntityView.__select__ & implements(ISiocContainer) |
56 |
templatable = False |
|
57 |
content_type = 'text/xml' |
|
58 |
||
59 |
def cell_call(self, row, col): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
60 |
entity = self.cw_rset.complete_entity(row, col) |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
61 |
sioct = xml_escape(entity.isioc_type()) |
1656 | 62 |
self.w(u'<sioc:%s rdf:about="%s">\n' |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
63 |
% (sioct, xml_escape(entity.absolute_url()))) |
1656 | 64 |
self.w(u'<dcterms:title>%s</dcterms:title>' |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
65 |
% xml_escape(entity.dc_title())) |
1656 | 66 |
self.w(u'<dcterms:created>%s</dcterms:created>' |
67 |
% entity.creation_date) |
|
68 |
self.w(u'<dcterms:modified>%s</dcterms:modified>' |
|
69 |
% entity.modification_date) |
|
1547 | 70 |
self.w(u'<!-- FIXME : here be items -->')#entity.isioc_items() |
1656 | 71 |
self.w(u'</sioc:%s>\n' % sioct) |
1547 | 72 |
|
73 |
||
74 |
class SIOCItemView(EntityView): |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
75 |
__regid__ = 'sioc_element' |
1547 | 76 |
__select__ = EntityView.__select__ & implements(ISiocItem) |
77 |
templatable = False |
|
78 |
content_type = 'text/xml' |
|
79 |
||
80 |
def cell_call(self, row, col): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
81 |
entity = self.cw_rset.complete_entity(row, col) |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
82 |
sioct = xml_escape(entity.isioc_type()) |
1656 | 83 |
self.w(u'<sioc:%s rdf:about="%s">\n' |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
84 |
% (sioct, xml_escape(entity.absolute_url()))) |
1656 | 85 |
self.w(u'<dcterms:title>%s</dcterms:title>' |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
86 |
% xml_escape(entity.dc_title())) |
1656 | 87 |
self.w(u'<dcterms:created>%s</dcterms:created>' |
88 |
% entity.creation_date) |
|
89 |
self.w(u'<dcterms:modified>%s</dcterms:modified>' |
|
90 |
% entity.modification_date) |
|
1547 | 91 |
if entity.content: |
1656 | 92 |
self.w(u'<sioc:content>%s</sioc:content>''' |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
93 |
% xml_escape(entity.isioc_content())) |
1547 | 94 |
if entity.related('entry_of'): |
1656 | 95 |
self.w(u'<sioc:has_container rdf:resource="%s"/>\n' |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
96 |
% xml_escape(entity.isioc_container().absolute_url())) |
1547 | 97 |
if entity.creator: |
98 |
self.w(u'<sioc:has_creator>\n') |
|
1656 | 99 |
self.w(u'<sioc:User rdf:about="%s">\n' |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
100 |
% xml_escape(entity.creator.absolute_url())) |
1547 | 101 |
self.w(entity.creator.view('foaf')) |
102 |
self.w(u'</sioc:User>\n') |
|
103 |
self.w(u'</sioc:has_creator>\n') |
|
104 |
self.w(u'<!-- FIXME : here be topics -->')#entity.isioc_topics() |
|
105 |
self.w(u'<!-- FIXME : here be replies -->')#entity.isioc_replies() |
|
1656 | 106 |
self.w(u' </sioc:%s>\n' % sioct) |
1547 | 107 |