Ignore:
Timestamp:
7 Jan 2015, 08:49:38 (10 years ago)
Author:
Henrik Bettermann
Message:

Add exporter and batch processor for REST documents.

Fix DocumentProcessorBase?.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/batching.py

    r12267 r12410  
    3737from waeup.ikoba.interfaces import IIkobaUtils
    3838from waeup.ikoba.interfaces import MessageFactory as _
    39 from waeup.ikoba.documents.interfaces import IPDFDocument, IHTMLDocument
     39from waeup.ikoba.documents.interfaces import (
     40    IPDFDocument, IHTMLDocument, IRESTDocument)
    4041from waeup.ikoba.utils.batching import BatchProcessor
    4142
     
    5455
    5556    location_fields = ['document_id',]
     57    additional_fields = ['class_name',]
     58
    5659    factory_name = None
    5760
    58     additional_fields = ['class_name']
    59     additional_headers = ['class_name']
     61    mode = None
    6062
    61     mode = None
     63    @property
     64    def available_fields(self):
     65        return sorted(list(set(
     66                    self.additional_fields +
     67                    getFields(self.iface).keys())))
    6268
    6369    def parentsExist(self, row, site):
     
    118124            if class_name != self.factory_name.strip('waeup.'):
    119125                errs.append(('class_name','wrong processor'))
    120         document_id = row.get('document_id', None)
    121126        return errs, inv_errs, conv_dict
     127
    122128
    123129class PDFDocumentProcessor(DocumentProcessorBase):
     
    132138    factory_name = 'waeup.PDFDocument'
    133139
    134 class HTMLDocumentProcessor(PDFDocumentProcessor):
     140
     141class HTMLDocumentProcessor(DocumentProcessorBase):
    135142    """A batch processor for IHTMLDocument objects.
    136143    """
     
    142149
    143150    factory_name = 'waeup.HTMLDocument'
     151
     152
     153class RESTDocumentProcessor(DocumentProcessorBase):
     154    """A batch processor for IRESTDocument objects.
     155    """
     156    util_name = 'restdocumentprocessor'
     157    grok.name(util_name)
     158
     159    name = _('Public REST Document Processor')
     160    iface = IRESTDocument
     161
     162    factory_name = 'waeup.RESTDocument'
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/export.py

    r12365 r12410  
    2424from waeup.ikoba.utils.batching import ExporterBase
    2525from waeup.ikoba.utils.helpers import iface_names
    26 from waeup.ikoba.documents.interfaces import IPDFDocument, IHTMLDocument
     26from waeup.ikoba.documents.interfaces import (
     27    IPDFDocument, IHTMLDocument, IRESTDocument)
    2728
    2829
     
    99100    class_name = 'HTMLDocument'
    100101    title = _(u'Public HTML Documents')
     102
     103
     104class RESTDocumentExporter(DocumentExporterBase):
     105    """Exporter for documents.
     106    """
     107    grok.name('restdocuments')
     108    iface = IRESTDocument
     109    class_name = 'RESTDocument'
     110    title = _(u'Public REST Documents')
  • main/waeup.ikoba/trunk/src/waeup/ikoba/utils/utils.py

    r12378 r12410  
    131131        'pdfdocuments',
    132132        'htmldocuments',
     133        'restdocuments',
    133134        'users',
    134135        'products',
     
    144145        'pdfdocumentprocessor',
    145146        'htmldocumentprocessor',
     147        'restdocumentprocessor',
    146148        'userprocessor')
    147149
Note: See TracChangeset for help on using the changeset viewer.