Changeset 12267


Ignore:
Timestamp:
20 Dec 2014, 15:59:04 (10 years ago)
Author:
Henrik Bettermann
Message:

Use a baseclass for document batch processors.

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

Legend:

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

    r12260 r12267  
    4141
    4242
    43 class PDFDocumentProcessor(BatchProcessor):
    44     """A batch processor for IPDFDocument objects.
     43class DocumentProcessorBase(BatchProcessor):
     44    """A base for batch processors for IDocument objects.
    4545    """
    4646    grok.implements(IBatchProcessor)
    4747    grok.provides(IBatchProcessor)
    4848    grok.context(Interface)
    49     util_name = 'pdfdocumentprocessor'
    50     grok.name(util_name)
     49    grok.baseclass()
    5150
    52     name = _('Public PDF Document Processor')
    53     iface = IPDFDocument
     51    util_name = None
     52    name = None
     53    iface = None
    5454
    5555    location_fields = ['document_id',]
    56     factory_name = 'waeup.PDFDocument'
     56    factory_name = None
    5757
    5858    additional_fields = ['class_name']
     
    9898        """Update obj to the values given in row.
    9999        """
    100         items_changed = super(PDFDocumentProcessor, self).updateEntry(
     100        items_changed = super(DocumentProcessorBase, self).updateEntry(
    101101            obj, row, site, filename)
    102102        # Log actions...
     
    111111        """
    112112        errs, inv_errs, conv_dict = super(
    113             PDFDocumentProcessor, self).checkConversion(row, mode=mode)
     113            DocumentProcessorBase, self).checkConversion(row, mode=mode)
    114114        # We need to check if the class_name corresponds with the
    115115        # processor chosen. This is to avoid accidentally wrong imports.
     
    121121        return errs, inv_errs, conv_dict
    122122
     123class PDFDocumentProcessor(DocumentProcessorBase):
     124    """A batch processor for IPDFDocument objects.
     125    """
     126    util_name = 'pdfdocumentprocessor'
     127    grok.name(util_name)
     128
     129    name = _('Public PDF Document Processor')
     130    iface = IPDFDocument
     131
     132    factory_name = 'waeup.PDFDocument'
    123133
    124134class HTMLDocumentProcessor(PDFDocumentProcessor):
  • main/waeup.ikoba/trunk/src/waeup/ikoba/utils/tests/test_batching.py

    r12178 r12267  
    188188            ['name', 'dinoports', 'owner', 'taxpayer'],
    189189            mode='create', user='Bob', logger=self.logger)
    190         num_succ, num_fail, finished_path, failed_path = result
     190        num, num_fail, finished_path, failed_path = result
    191191        self.resultpath = [finished_path, failed_path]
    192         assert num_succ == 4
     192        assert num == 4
    193193        assert num_fail == 0
    194194        assert finished_path.endswith('/newcomers.finished.csv')
     
    201201            ['name', 'dinoports', 'owner', 'taxpayer'],
    202202            mode='create', user='Bob', logger=self.logger)
    203         num_succ, num_fail, finished_path, failed_path = result
     203        num, num_fail, finished_path, failed_path = result
    204204        self.resultpath = [finished_path, failed_path]
    205205        assert len(self.stoneville) == 4
     
    215215            ['name', 'dinoports', 'owner', 'taxpayer'],
    216216            mode='create', user='Bob', logger=self.logger)
    217         num_succ, num_fail, finished_path, failed_path = result
     217        num, num_fail, finished_path, failed_path = result
    218218        self.resultpath = [finished_path, failed_path]
    219219        assert isinstance(self.stoneville['Barneys Home'].dinoports, int)
     
    231231            ['name', 'dinoports', 'owner', 'taxpayer'],
    232232            mode='create', user='Bob', logger=self.logger)
    233         num_succ, num_fail, finished_path, failed_path = result
     233        num, num_fail, finished_path, failed_path = result
    234234        self.resultpath = [finished_path, failed_path]
    235235        log_contents = open(self.logfile, 'rb').read()
Note: See TracChangeset for help on using the changeset viewer.