author | Florent <florent@secondweb.fr> |
Tue, 19 May 2009 17:05:54 +0200 | |
branch | stable |
changeset 1873 | e96f50e52099 |
parent 1653 | 8b82227719f0 |
child 1977 | 606923dff11b |
permissions | -rw-r--r-- |
0 | 1 |
"""xbel views |
2 |
||
3 |
:organization: Logilab |
|
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
731
diff
changeset
|
4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
0 | 5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 |
""" |
|
7 |
__docformat__ = "restructuredtext en" |
|
8 |
_ = unicode |
|
9 |
||
10 |
from logilab.mtconverter import html_escape |
|
11 |
||
731
ac4a94e50b60
some more s/__selectors__/__select__ but still more to come
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
728
diff
changeset
|
12 |
from cubicweb.selectors import implements |
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
731
diff
changeset
|
13 |
from cubicweb.view import EntityView |
1653 | 14 |
from cubicweb.web.views.xmlrss import XMLView |
0 | 15 |
|
16 |
||
1653 | 17 |
class XbelView(XMLView): |
0 | 18 |
id = 'xbel' |
19 |
title = _('xbel') |
|
20 |
templatable = False |
|
1653 | 21 |
content_type = 'text/xml' #application/xbel+xml |
22 |
||
0 | 23 |
def cell_call(self, row, col): |
24 |
self.wview('xbelitem', self.rset, row=row, col=col) |
|
1653 | 25 |
|
0 | 26 |
def call(self): |
27 |
"""display a list of entities by calling their <item_vid> view""" |
|
28 |
title = self.page_title() |
|
29 |
url = self.build_url(rql=self.req.form.get('rql', '')) |
|
30 |
self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self.req.encoding) |
|
31 |
self.w(u'<!DOCTYPE xbel PUBLIC "+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML" "http://www.python.org/topics/xml/dtds/xbel-1.0.dtd">') |
|
32 |
self.w(u'<xbel version="1.0">') |
|
33 |
self.w(u'<title>%s</title>' % self.req._('bookmarks')) |
|
34 |
for i in xrange(self.rset.rowcount): |
|
35 |
self.cell_call(i, 0) |
|
36 |
self.w(u"</xbel>") |
|
1653 | 37 |
|
0 | 38 |
|
39 |
class XbelItemView(EntityView): |
|
40 |
id = 'xbelitem' |
|
41 |
||
42 |
def cell_call(self, row, col): |
|
43 |
entity = self.complete_entity(row, col) |
|
44 |
self.w(u'<bookmark href="%s">' % html_escape(self.url(entity))) |
|
45 |
self.w(u' <title>%s</title>' % html_escape(entity.dc_title())) |
|
46 |
self.w(u'</bookmark>') |
|
47 |
||
48 |
def url(self, entity): |
|
49 |
return entity.absolute_url() |
|
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
731
diff
changeset
|
50 |
|
1653 | 51 |
|
0 | 52 |
class XbelItemBookmarkView(XbelItemView): |
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
53 |
__select__ = implements('Bookmark') |
0 | 54 |
|
55 |
def url(self, entity): |
|
56 |
return entity.actual_url() |
|
1653 | 57 |