problem portal_catalog and internally_published

Julien Bessiere julien.63 at free.fr
Thu Oct 18 11:03:29 UTC 2007


Hi,
I'm currently working on an intranet/extranet plone 3 web site.
I'm writing a view to get back plone events in iCal or sunbird.
here's the code :
----------------------------------------------------------------
from cStringIO import StringIO
from logging import info
from Products.ATContentTypes.interfaces import IATEvent
from OFS.interfaces import IFolder
from Products.Five import BrowserView
from Products.ATContentTypes.lib import calendarsupport
PRODID = "-//LECA Style//AT Event//EN"

class IcalBrowser(BrowserView):

      def ics_file(self):
          out = StringIO()
          out.write(calendarsupport.ICS_HEADER % { 'prodid' : PRODID, })

          folder = self.context

          for presult in folder.portal_catalog 
(portal_type_operator="or",
                                              portal_type=
['Event','ATEvent'],
                                              path='/'.join
(folder.getPhysicalPath()),
                                               
review_state_operator="or",
                                              review_state=
['published','external','internally_published']):
                  object = presult.getObject()
                  out.write(object.getICal())

          response = self.request.RESPONSE
          response.setHeader('Content-Type', 'text/calendar')
          response.setHeader('Content-Disposition', 'attachment;
filename="%s.ics"' % folder.getId())

          out.write(calendarsupport.ICS_FOOTER)
          return out.getvalue()
----------------------------------------------------------------------

It's working almost fine, except I only catch external events. I
can't get events with review state 'internally_published'. I've
checked in my workflow and it's the correct state.

So I thought, I could try to get the state by doing this:
----------------------------------------------------------------------
for presult in folder.portal_catalog(portal_type_operator="or",
                                              portal_type=
['Event','ATEvent'],
                                              path='/'.join
(folder.getPhysicalPath())):
              obj = presult.getObject()
              info(obj)
              info(obj.review_state)
----------------------------------------------------------------------
This way, I've got all my events.
But I've got a message : error Attribute. obj does not have an
review_state attribute.

Any idea how I could find out the exact review state of my
internally_published events ?

Tanks

Julien




More information about the Product-Developers mailing list