--- a/common/selectors.py Fri Nov 21 17:37:27 2008 +0100
+++ b/common/selectors.py Tue Nov 25 17:41:16 2008 +0100
@@ -389,6 +389,16 @@
return 0
return 1
+def appobject_selectable(registry, oid):
+ @lltrace
+ def selector(cls, req, rset, *args, **kwargs):
+ try:
+ cls.vreg.select_object(registry, oid, req, rset, *args, **kwargs)
+ return 1
+ except NoSelectableObject:
+ return 0
+ return selector
+
# compound selectors ##########################################################
--- a/entities/__init__.py Fri Nov 21 17:37:27 2008 +0100
+++ b/entities/__init__.py Tue Nov 25 17:41:16 2008 +0100
@@ -202,6 +202,7 @@
def rss_feed_url(self):
return self.absolute_url(vid='rss')
+
# abstractions making the whole things (well, some at least) working ######
@classmethod
--- a/web/views/basecomponents.py Fri Nov 21 17:37:27 2008 +0100
+++ b/web/views/basecomponents.py Tue Nov 25 17:41:16 2008 +0100
@@ -14,14 +14,14 @@
from cubicweb import Unauthorized
from cubicweb.common.uilib import html_escape, toggle_action
-from cubicweb.common.selectors import yes_selector
+from cubicweb.common.selectors import yes_selector, nfentity_selector, onelinerset_selector
from cubicweb.schema import display_name
from cubicweb.common.selectors import (chainfirst, multitype_selector,
req_form_params_selector)
from cubicweb.web.htmlwidgets import MenuWidget, PopupBoxMenu, BoxSeparator, BoxLink
-from cubicweb.web.component import (SingletonVComponent, EntityVComponent,
- RelatedObjectsVComponent)
+from cubicweb.web.component import (VComponent, SingletonVComponent, EntityVComponent,
+ RelatedObjectsVComponent)
_ = unicode
--- a/web/views/basetemplates.py Fri Nov 21 17:37:27 2008 +0100
+++ b/web/views/basetemplates.py Tue Nov 25 17:41:16 2008 +0100
@@ -11,7 +11,7 @@
from cubicweb import NoSelectableObject, ObjectNotFound
from cubicweb.common.view import Template, MainTemplate, NOINDEX, NOFOLLOW
-from cubicweb.common.selectors import nfentity_selector
+from cubicweb.common.selectors import nfentity_selector, onelinerset_selector
from cubicweb.common.utils import make_uid
from cubicweb.web.views.baseviews import vid_from_rset
@@ -331,9 +331,9 @@
self.req.add_js(jscript, localfile=False)
def alternates(self):
- # nfentity_selector is used by the rss icon box as well
- if nfentity_selector(self, self.req, self.rset):
- url = self.build_url(rql=self.limited_rql(), vid='rss')
+ urlgetter = self.vreg.select_component('rss_feed_url', self.req, self.rset)
+ if urlgetter is not None:
+ url = urlgetter.feed_url()
self.whead(u'<link rel="alternate" type="application/rss+xml" title="RSS feed" href="%s"/>\n'
% html_escape(url))
--- a/web/views/boxes.py Fri Nov 21 17:37:27 2008 +0100
+++ b/web/views/boxes.py Tue Nov 25 17:41:16 2008 +0100
@@ -17,7 +17,7 @@
from logilab.mtconverter import html_escape
-from cubicweb.common.selectors import rset_selector, nfentity_selector, onelinerset_selector
+from cubicweb.common.selectors import (rset_selector, appobject_selectable)
from cubicweb.web.htmlwidgets import BoxWidget, BoxMenu, BoxHtml, RawBoxItem
from cubicweb.web.box import BoxTemplate, ExtResourcesBoxTemplate
@@ -165,7 +165,6 @@
"""display a box containing links to all possible views"""
id = 'possible_views_box'
-
title = _('possible views')
order = 10
require_groups = ('users', 'managers')
@@ -186,7 +185,7 @@
class RSSIconBox(ExtResourcesBoxTemplate):
"""just display the RSS icon on uniform result set"""
- __selectors__ = ExtResourcesBoxTemplate.__selectors__ + (nfentity_selector,)
+ __selectors__ = ExtResourcesBoxTemplate.__selectors__ + (appobject_selectable('components', 'rss_feed_url'),)
id = 'rss'
order = 999
@@ -194,9 +193,10 @@
visible = False
def call(self, **kwargs):
- url = html_escape(self.build_url(rql=self.limited_rql(), vid='rss'))
+ urlgetter = self.vreg.select_component('rss_feed_url', self.req, self.rset)
+ url = urlgetter.feed_url()
rss = self.req.external_resource('RSS_LOGO')
- self.w(u'<a href="%s"><img src="%s" border="0" /></a>\n' % (url, rss))
+ self.w(u'<a href="%s"><img src="%s" border="0" /></a>\n' % (html_escape(url), rss))
class EntityRSSIconBox(RSSIconBox):
"""just display the RSS icon on uniform result set for a single entity"""