Ignore:
Timestamp:
21 Dec 2012, 13:09:05 (12 years ago)
Author:
Henrik Bettermann
Message:

Extend IExportJob so that AsyncExportJobs? unveil their status like AsyncReportJobs? do. Use this property attribute to hide buttons.

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

Legend:

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

    r9814 r9816  
    11851185        pass
    11861186
     1187    finished = schema.Bool(
     1188        title = u'`True` if the job finished.`',
     1189        default = False,
     1190        )
     1191
     1192    failed = schema.Bool(
     1193        title = u"`True` iff the job finished and didn't provide a file.",
     1194        default = None,
     1195        )
     1196
    11871197class IExportJobContainer(IKofaObject):
    11881198    """A component that contains (maybe virtually) export jobs.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r9815 r9816  
    26712671            # XXX: Descr. should be improved
    26722672            descr = '%r, %r' % (job.args[1:], job.kwargs)
    2673 
    2674             # XXX: status should be replaced by 'ready', 'running' or 'FAILED'
    2675             # like in w.k.browser.reports ...
    2676             status = job.status
    2677             # ... and buttons should be displayed accordingly
    2678             show_download_button = True
    2679             show_discard_button = True
    2680             show_refresh_button = True
    2681 
    2682 
     2673            status = job.finished and 'ready' or 'running'
     2674            status = job.failed and 'FAILED' or status
     2675            show_download_button = job.finished and not job.failed
     2676            show_discard_button = job.finished
     2677            show_refresh_button = not job.finished
    26832678            start_time = getattr(job, 'begin_after', None)
    26842679            if start_time:
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/batching.py

    r9797 r9816  
    2828import tempfile
    2929import time
     30import zc.async.interfaces
    3031from cStringIO import StringIO
    3132from persistent.list import PersistentList
     
    571572            export_job, site, exporter_name, *args, **kwargs)
    572573
     574    @property
     575    def finished(self):
     576        """A job is marked `finished` if it is completed.
     577
     578        Please note: a finished report job does not neccessarily
     579        provide an IReport result. See meth:`failed`.
     580        """
     581        return self.status == zc.async.interfaces.COMPLETED
     582
     583    @property
     584    def failed(self):
     585        """A report job is marked failed iff it is finished and the
     586        result is None.
     587
     588        While a job is unfinished, the `failed` status is ``None``.
     589
     590        Failed jobs normally provide a `traceback` to examine reasons.
     591        """
     592        if not self.finished:
     593            return None
     594        if getattr(self, 'result', None) is None:
     595            return True
     596        return False
     597
    573598class ExportJobContainer(object):
    574599    """A mix-in that provides functionality for asynchronous export jobs.
Note: See TracChangeset for help on using the changeset viewer.