Exemple #1
0
def lookupTranslationId(obj, page, ids):
    implemented = ITranslatable.isImplementedBy(obj)
    if not implemented or implemented and not obj.isTranslation():
        pageobj = getattr(obj, page, None)
        if (pageobj is not None and
            ITranslatable.isImplementedBy(pageobj)):
            translation = pageobj.getTranslation()
            if (translation is not None and
                ids.has_key(translation.getId())):
                page = translation.getId()
    return page
Exemple #2
0
    def index_object(self, documentId, obj, treshold=None):
        """Index the object"""
        if not ITranslatable.isImplementedBy(obj):
            if IndexableObjectWrapper.isImplementedBy(obj):
                # Wrapper doesn't proxy __implements__
                wrapped = getattr(obj, '_IndexableObjectWrapper__ob', None)
                # Older CMFPlone
                if wrapped is None:
                    wrapped = getattr(obj, '_obj', None)
                if wrapped is None: 
                    return 0
                obj = wrapped
        
        try:
            language = obj.Language
            if callable(language):
                language = language()
        except AttributeError:
            return 0
        
        if ITranslatable.isImplementedBy(obj):
            cid = obj.getCanonical().UID()
        else:
            # Also index non-translatable content, otherwise
            # LinguaPlone only shows translatable content.
            # This assumes a catalog documentId will never
            # be equal to a UID.
            cid = documentId

        if documentId not in self._unindex:
            self._length.change(1)
        else:
            self._remove(self._unindex[documentId])
            
        main, sub = splitLanguage(language)
        entry = IndexEntry(documentId, main, sub, cid)
        self._insert(entry)
        self._unindex[documentId] = entry
        self._sortindex[documentId] = str(entry)
        
        return 1
Exemple #3
0
 def test_implementsTranslateable(self):
     # lingua plone is adding the ITranslatable interface to all types
     if not HAS_LINGUA_PLONE:
         return
     self.failUnless(ITranslatable.isImplementedBy(self._ATCT))
     self.failUnless(verifyObject(ITranslatable, self._ATCT))