Ignore:
Timestamp:
27 Jan 2015, 08:31:34 (10 years ago)
Author:
Henrik Bettermann
Message:

Export datasets of selected items specified by a list of identifiers. Will be used in students and applicants modules.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.py

    r12513 r12516  
    497497        raise NotImplementedError
    498498
     499    def get_selected(self, site, selected):
     500        """Get datasets to export for selected items
     501        specified by a list of identifiers.
     502
     503        Returns an iterable.
     504        """
     505        raise NotImplementedError
     506
    499507    def export(self, iterable, filepath=None):
    500508        """Export `iterable` as CSV file.
     
    521529        """
    522530        data = self.get_filtered(site, **kw)
     531        return self.export(data, filepath=filepath)
     532
     533    def export_selected(self, site, filepath=None, **kw):
     534        """Export those items specified by a list of identifiers
     535        called `selected`.
     536
     537        If `filepath` is ``None``, a raw string with CSV data should
     538        be returned.
     539        """
     540        selected = kw.get('selected', [])
     541        data = self.get_selected(site, selected)
    523542        return self.export(data, filepath=filepath)
    524543
     
    551570    if kw == {}:
    552571        exporter.export_all(site, filepath=output_path)
     572    elif kw.has_key('selected'):
     573        exporter.export_selected(site, filepath=output_path, **kw)
    553574    else:
    554575        exporter.export_filtered(site, filepath=output_path, **kw)
Note: See TracChangeset for help on using the changeset viewer.