Comment 2 for bug 101440

Revision history for this message
sacco (timothy-heap) wrote :

O.K.

Here's the fulltext() method I'm using at present (i.e. this is where I'm
starting from):

    def _stringify(self, obj):
        if not isinstance(obj, basestring):
            try:
                obj = str(obj)
            except UnicodeEncodeError:
                obj = unicode(obj)
        return obj

    security.declareProtected(SilvaPermissions.AccessContentsInformation,
                              'fulltext')
    def fulltext(self):
        """Return the full text content of this object."""
        if self.version_status() == 'unapproved':
            return ''
        fulltext = [self.get_title()]
        text = self._flattenxml(self.content_xml())
        if isinstance(text, (list, tuple, )):
            fulltext.extend(map(self._stringify, filter(None, text)))
        else:
            text = self._stringify(text)
            if text:
                fulltext.append(text)
        return fulltext