Hello
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

class Feed(Persistent):
   """A class that stores the feed URLs"""

   implements(IFeed)

   __name__ = __parent__ = None

   url=[]

   def getRawFeedData(self):
       return [feedparser.parse(item) for item in self.url]

class IFeed(Interface):

   def getRawFeedData():
       """retrieves raw feed data"""

   url = List (
                       title = u"URL",
                       description = u"URL for newsfeed",
                       required = True,
                       value_type=TextLine(title=u"Tool")
                       )

The content component and the interface are registred as thus:

 <class class=".components.Feed">
   <implements
       interface="zope.annotation.interfaces.IAttributeAnnotatable"
       />
   <require
       permission="zope.View"
       interface =".interfaces.IFeed"
     />
   <require
       permission="zope.ManageContent"
       set_schema=".interfaces.IFeed"
     />
   </class>


   <!-- marker interface for feed -->
   <interface
       interface=".interfaces.IFeed"
       type="zope.app.content.interfaces.IContentType"
     />

And the browser class

class FeedView(BrowserPage):
   """A view for the RSS feed aggregator object"""

   __call__ = ViewPageTemplateFile("feed_view.pt")


   def getMetadata(self):
       """Retrieves the title and description of the feed aggregator from
the persistant storage"""
       return IZopeDublinCore(self.context)


   def getFeed(self):

       feeds=self.context.getRawFeedData()

       result=[]
       for feed in feeds:
           ######## it fails here #############
           result+=[(e.updated_parsed, feed.channel, e) for e in
feed.entries ]
       result.sort(reverse=True)
       return result

Which is registered in the following way

 <!-- simple browser view of a single feed aggregator -->
 <browser:page
     for="kousai.feedreader.interfaces.IFeed"
     name="index.html"
     class="kousai.feedreader.browser.components.FeedView"
     permission="zope.View"
   />

The traceback

...

 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
   return expression(self)
  -
/Users/mikaelmoutakis/zpi/myfiles/kousai/feedreader/browser/feed_view.pt
  - Line 15, Column 2
  - Expression: <PythonExpr ( view.getFeed()[0:10])>
  - Names:
     {'args': (),
      'context': <kousai.feedreader.components.Feed object at 0x3772c70>,
      'default': <object object at 0x41560>,
      'loop': {},
      'nothing': None,
      'options': {},
      'repeat': {},
      'request': <zope.publisher.browser.BrowserRequest instance URL=
http://localhost:8080/++skin++Kousai/feed/index.html>,
      'template': <
zope.app.pagetemplate.viewpagetemplatefile.ViewPageTemplateFile object at
0x307d3f0>,
      'usage': <zope.pagetemplate.pagetemplate.TemplateUsage object at
0x37e35d0>,
      'view': <zope.app.publisher.browser.viewmeta.FeedView object at
0x37e3270>,
      'views':
<zope.app.pagetemplate.viewpagetemplatefile.ViewMapperobject at
0x37e3250>}
 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__
   return eval(self._code, vars)
  - __traceback_info__: ( view.getFeed()[0:10])
 File "<string>", line 0, in ?
 File
"/Users/mikaelmoutakis/zpi/myfiles/kousai/feedreader/browser/components.py",
line 39, in getFeed
   result+=[(e.updated_parsed, feed.channel, e) for e in feed.entries ]
ForbiddenAttribute: ('entries', {'feed': {'publisher'.....
....

Haven't I declared the getRawFeedData method by including it in the IFeed
interface?

Thanks!

/Mikael M
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to