kill ExtResourcesBoxTemplate tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 17 Feb 2009 16:40:26 +0100
branchtls-sprint
changeset 663 482d39578366
parent 662 6f867ab70e3d
child 664 04154a2b238d
kill ExtResourcesBoxTemplate
web/box.py
web/views/boxes.py
--- a/web/box.py	Tue Feb 17 14:48:10 2009 +0100
+++ b/web/box.py	Tue Feb 17 16:40:26 2009 +0100
@@ -139,14 +139,6 @@
         return (self.rql, {'x': self.req.user.eid}, 'x')
     
 
-class ExtResourcesBoxTemplate(BoxTemplate):
-    """base class for boxes displaying external resources such as the RSS logo.
-    It should list necessary resources with the .need_resources attribute.
-    """
-    __registerer__ = extresources_registerer
-    need_resources = ()
-
-
 class EntityBoxTemplate(BoxTemplate):
     """base class for boxes related to a single entity"""
     __registerer__ = accepts_registerer
--- a/web/views/boxes.py	Tue Feb 17 14:48:10 2009 +0100
+++ b/web/views/boxes.py	Tue Feb 17 16:40:26 2009 +0100
@@ -19,7 +19,7 @@
 
 from cubicweb.selectors import any_rset, appobject_selectable, match_user_groups
 from cubicweb.web.htmlwidgets import BoxWidget, BoxMenu, BoxHtml, RawBoxItem
-from cubicweb.web.box import BoxTemplate, ExtResourcesBoxTemplate
+from cubicweb.web.box import BoxTemplate
 
 _ = unicode
 
@@ -136,7 +136,6 @@
     visible = True # enabled by default
     title = _('search')
     order = 0
-    need_resources = 'SEARCH_GO'
     formdef = u"""<form action="%s">
 <table id="tsearch"><tr><td>
 <input id="norql" type="text" accesskey="q" tabindex="%s" title="search text" value="%s" name="rql" />
@@ -186,19 +185,22 @@
             box.render(self.w)
 
         
-class RSSIconBox(ExtResourcesBoxTemplate):
+class RSSIconBox(BoxTemplate):
     """just display the RSS icon on uniform result set"""
-    __selectors__ = ExtResourcesBoxTemplate.__selectors__ + (appobject_selectable('components', 'rss_feed_url'),)
+    id = 'rss'
+    __selectors__ = BoxTemplate.__selectors__ + (appobject_selectable('components', 'rss_feed_url'),)
     
-    id = 'rss'
     order = 999
-    need_resources = 'RSS_LOGO',
     visible = False
     
     def call(self, **kwargs):
+        try:
+            rss = self.req.external_resource('RSS_LOGO')
+        except KeyError:
+            self.error('missing RSS_LOGO external resource')
+            return
         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" alt="rss"/></a>\n' % (html_escape(url), rss))