Changeset 9949


Ignore:
Timestamp:
14 Feb 2013, 16:32:40 (12 years ago)
Author:
uli
Message:

Use specialized methods to get a PDF creator; better usable in customized packages when different pdf forms are needed for different circumstances.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/pdf.py

    r9948 r9949  
    9696        return data
    9797
     98    def _getPDFCreator(self):
     99        return getUtility(IPDFCreator)
     100
    98101    def __call__(self, view=None, note=None):
    99102        """Return a PDF representation of the context applicant.
     
    109112        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
    110113        separators = getUtility(IApplicantsUtils).SEPARATORS_DICT
    111         creator = getUtility(IPDFCreator)
     114        creator = self._getPDFCreator()
    112115
    113116        # append history
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r9925 r9949  
    100100        """
    101101
     102    def getPDFCreator(context):
     103        """Get some IPDFCreator instance suitable for use with `context`.
     104        """
     105
    102106    def renderPDF(view, subject='', filename='slip.pdf',):
    103107        """Render pdf slips for various pages.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r9948 r9949  
    252252        # Draw each signature field one under another (vertically)
    253253        for num, signature in enumerate(signatures):
    254             line = (num - 1) * 2
     254            line = len(data)
    255255            sig_style.extend((
    256256                ('TOPPADDING', (0, line), (-1, line), 32),
     
    537537            return
    538538        style = getSampleStyleSheet()
    539         creator = getUtility(IPDFCreator)
     539        creator = self.getPDFCreator(student)
    540540        data = []
    541541        doc_title = view.label
     
    585585        return pdf_stream
    586586
     587    def getPDFCreator(self, context):
     588        """Get a pdf creator suitable for `context`.
     589
     590        The default implementation always returns the default creator.
     591        """
     592        return getUtility(IPDFCreator)
     593
    587594    def renderPDF(self, view, filename='slip.pdf', student=None,
    588595                  studentview=None,
     
    595602        # XXX: tell what the different parameters mean
    596603        style = getSampleStyleSheet()
    597         creator = getUtility(IPDFCreator)
     604        creator = self.getPDFCreator(student)
    598605        data = []
    599606        doc_title = view.label
Note: See TracChangeset for help on using the changeset viewer.