Linha | |
---|
1 | from zope.component import adapts |
---|
2 | from zope.interface import implements |
---|
3 | |
---|
4 | from il.sapl.interfaces import IFileSAPL |
---|
5 | |
---|
6 | from zopyx.txng3.core.interfaces import IIndexableContent |
---|
7 | from zopyx.txng3.core.content import IndexContentCollector as ICC |
---|
8 | from zopyx.txng3.core.config import DEFAULT_LANGUAGE |
---|
9 | |
---|
10 | |
---|
11 | class FileAdapter: |
---|
12 | """ Adapter para o tipo File do Zope |
---|
13 | """ |
---|
14 | |
---|
15 | adapts(IFileSAPL) |
---|
16 | implements(IIndexableContent) |
---|
17 | |
---|
18 | def __init__(self, context): |
---|
19 | self.context = context |
---|
20 | self.encoding = 'utf-8' |
---|
21 | self.language = DEFAULT_LANGUAGE |
---|
22 | |
---|
23 | def indexableContent(self, fields): |
---|
24 | icc = ICC() |
---|
25 | self.addPrincipiaSearchSource(icc) |
---|
26 | return icc |
---|
27 | |
---|
28 | def addPrincipiaSearchSource(self, icc): |
---|
29 | body = str(self.context) |
---|
30 | ct = self.context.content_type |
---|
31 | if body: |
---|
32 | icc.addBinary('PrincipiaSearchSource', body, ct, None, self.language) |
---|
Note: Veja
TracBrowser
para ajuda no uso do navegador do trac.