Hello<br>I wrote a feed aggregator using the module FeedParser. I stored the RSS feed url in a persistant content component and retrieved the feed data in the view class. But I thought that I should move the feed data into the content component class instead of retrieving it in the view class. I get a ForbiddenAttribute error when viewing the class
<br><br>class Feed(Persistent):<br> """A class that stores the feed URLs"""<br> <br> implements(IFeed)<br> <br> __name__ = __parent__ = None<br> <br> url=[]<br> <br> def getRawFeedData(self):
<br> return [feedparser.parse(item) for item in self.url]<br><br>class IFeed(Interface):<br> <br> def getRawFeedData():<br> """retrieves raw feed data"""<br> <br> url = List (
<br> title = u"URL",<br> description = u"URL for newsfeed",<br> required = True,<br> value_type=TextLine(title=u"Tool")
<br> )<br> <br>The content component and the interface are registred as thus:<br><br> <class class=".components.Feed"><br> <implements<br> interface="zope.annotation.interfaces.IAttributeAnnotatable
"<br> /><br> <require<br> permission="zope.View"<br> interface =".interfaces.IFeed"<br> /><br> <require<br> permission="zope.ManageContent"
<br> set_schema=".interfaces.IFeed"<br> /><br> </class><br> <br> <br> <!-- marker interface for feed --><br> <interface<br> interface=".interfaces.IFeed"
<br> type="zope.app.content.interfaces.IContentType"<br> /><br><br>And the browser class <br><br>class FeedView(BrowserPage):<br> """A view for the RSS feed aggregator object"""
<br> <br> __call__ = ViewPageTemplateFile("feed_view.pt")<br> <br> <br> def getMetadata(self):<br> """Retrieves the title and description of the feed aggregator from the persistant storage"""
<br> return IZopeDublinCore(self.context)<br> <br><br> def getFeed(self):<br><br> feeds=self.context.getRawFeedData()<br><br> result=[]<br> for feed in feeds:<br> ######## it fails here #############
<br> result+=[(e.updated_parsed, feed.channel, e) for e in <span style="font-weight: bold;">feed.entries</span> ]<br> result.sort(reverse=True)<br> return result<br> <br>Which is registered in the following way
<br><br> <!-- simple browser view of a single feed aggregator --><br> <browser:page<br> for="kousai.feedreader.interfaces.IFeed"<br> name="index.html"<br> class="kousai.feedreader.browser.components.FeedView
"<br> permission="zope.View"<br> /> <br><br>The traceback<br><br>...<br><br> File "/Users/admin/Zope-3.3.1/build/lib.darwin-8.9.0-Power_Macintosh-2.4/zope/tales/tales.py", line 696, in evaluate
<br> return expression(self)<br> - /Users/mikaelmoutakis/zpi/myfiles/kousai/feedreader/browser/feed_view.pt<br> - Line 15, Column 2<br> - Expression: <PythonExpr ( view.getFeed()[0:10])><br> - Names:<br> {'args': (),
<br> 'context': <kousai.feedreader.components.Feed object at 0x3772c70>,<br> 'default': <object object at 0x41560>,<br> 'loop': {},<br> 'nothing': None,<br>
'options': {},<br> 'repeat': {},<br> 'request': <zope.publisher.browser.BrowserRequest instance URL=<a href="http://localhost:8080/++skin++Kousai/feed/index.html">http://localhost:8080/++skin++Kousai/feed/index.html
</a>>,<br> 'template': <zope.app.pagetemplate.viewpagetemplatefile.ViewPageTemplateFile object at 0x307d3f0>,<br> 'usage': <zope.pagetemplate.pagetemplate.TemplateUsage object at 0x37e35d0>,
<br> 'view': <zope.app.publisher.browser.viewmeta.FeedView object at 0x37e3270>,<br> 'views': <zope.app.pagetemplate.viewpagetemplatefile.ViewMapper object at 0x37e3250>}<br> File "/Users/admin/Zope-
3.3.1/build/lib.darwin-8.9.0-Power_Macintosh-2.4/zope/tales/pythonexpr.py", line 59, in __call__<br> return eval(self._code, vars)<br> - __traceback_info__: ( view.getFeed()[0:10])<br> File "<string>", line 0, in ?
<br> File "/Users/mikaelmoutakis/zpi/myfiles/kousai/feedreader/browser/components.py", line 39, in getFeed<br> result+=[(e.updated_parsed, feed.channel, e) for e in feed.entries ]<br><span style="font-weight: bold;">
ForbiddenAttribute: ('entries'</span>, {'feed': {'publisher'.....<br>....<br><br>Haven't I declared the getRawFeedData method by including it in the IFeed interface? <br><br>Thanks!<br><br>/Mikael M
<br><br>