reports – Report Generation Components Module¶
Components for report generation.
-
class
waeup.kofa.reports.AsyncReportJob(site, generator_name, args=[], kw={})[source]¶ Bases:
zc.async.job.JobAn IJob that creates reports.
AsyncReportJob instances are regular AsyncJob instances with a different constructor API. Instead of a callable to execute, you must pass a site, some generator_name, and additional args and keywords to create a report.
The real work is done when an instance of this class is put into a queue. See
waeup.kofa.asyncto learn more about asynchronous jobs.The generator_name must be the name under which an IReportGenerator utility was registered with the ZCA.
The site must be a valid site or
None.The result of an AsyncReportJob is an IReport object.
-
__doc__= 'An IJob that creates reports.\n\n `AsyncReportJob` instances are regular `AsyncJob` instances with a\n different constructor API. Instead of a callable to execute, you\n must pass a `site`, some `generator_name`, and additional args and\n keywords to create a report.\n\n The real work is done when an instance of this class is put into a\n queue. See :mod:`waeup.kofa.async` to learn more about\n asynchronous jobs.\n\n The `generator_name` must be the name under which an IReportGenerator\n utility was registered with the ZCA.\n\n The `site` must be a valid site or ``None``.\n\n The result of an `AsyncReportJob` is an IReport object.\n '¶
-
__implemented__= <implementedBy waeup.kofa.reports.AsyncReportJob>¶
-
__module__= 'waeup.kofa.reports'¶
-
__provides__¶ Special descriptor for class __provides__
The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.
For example:
>>> from zope.interface import Interface >>> class IFooFactory(Interface): ... pass >>> class IFoo(Interface): ... pass >>> class C(object): ... implements(IFoo) ... classProvides(IFooFactory) >>> [i.getName() for i in C.__provides__] ['IFooFactory']
>>> [i.getName() for i in C().__provides__] ['IFoo']
-
failed¶ A report job is marked failed iff it is finished and the result does not provide IReport.
While a job is unfinished, the failed status is
None.Failed jobs normally provide a traceback to examine reasons.
-
finished¶ A job is marked finished if it is completed.
Please note: a finished report job does not neccessarily provide an IReport result. See meth:failed.
-
-
class
waeup.kofa.reports.HandleReports(id, title='', description='')[source]¶ Bases:
grokcore.security.components.PermissionThe HandleReports permission allows to add any kind of report and to view and remove own reports, i.e. reports which were created by the logged-in user.
-
__doc__= 'The HandleReports permission allows to add any kind of report\n and to view and remove own reports, i.e. reports which were created by\n the logged-in user.\n '¶
-
__module__= 'waeup.kofa.reports'¶
-
-
interface
waeup.kofa.reports.IReport[source]¶ A report.
-
args¶ The args passed to constructor
-
creation_dt¶ Datetime when a report was created. The datetime should reflect the point of time when the data was fetched, not when any output was created.
-
kwargs¶ The keywords passed to constructor
-
create_pdf(job_id)¶ Generate a PDF copy.
-
-
interface
waeup.kofa.reports.IReportGenerator[source]¶ Extends:
waeup.kofa.interfaces.IKofaObjectA report generator.
-
generate(site, args=[], kw={})¶ Generate a report.
args and kw are the parameters needed to create a specific report (if any).
-
title¶ Human readable description of report type.
-
-
interface
waeup.kofa.reports.IReportJob[source]¶ Extends:
zc.async.interfaces.IJob-
failed¶ True iff the job finished and didn’t provide a report.
-
finished¶ True if the job finished.`
-
__init__(site, generator_name)¶ Create a report job via generator.
-
-
interface
waeup.kofa.reports.IReportJobContainer[source]¶ A component that contains (maybe virtually) report jobs.
-
get_running_report_jobs(user_id=None)¶ Get report jobs for user with user_id as list of tuples.
Each tuples holds
<job_id>, <generator_name>, <user_id>in that order. The<generator_name>is the utility name of the used report generator.If user_id is
None, all running report jobs are returned.
-
report_entry_from_job_id(job_id)¶ Get entry tuple for job_id.
Returns
Noneif no such entry can be found.
-
start_report_job(report_generator_name, user_id, args=[], kw={})¶ Start asynchronous report job.
- report_generator_name
- is the name of a report generator utility to be used.
- user_id
- is the ID of the user that triggers the report generation.
- args and kw
- args and keywords passed to the generators generate() method.
The job_id is stored along with exporter name and user id in a persistent list.
Returns the job ID of the job started.
-
delete_report_entry(entry)¶ Delete the report job denoted by entry.
Removes entry from the local running_report_jobs list and also removes the regarding job via the local job manager.
entry is a tuple
(<job id>, <generator name>, <user id>)as created bystart_report_job()or returned byget_running_report_jobs().
-
get_report_jobs_status(user_id=None)¶ Get running/completed report jobs for user_id as list of tuples.
Each tuple holds
<raw status>, <status translated>, <generator title>in that order, where<status translated>and<generator title>are translated strings representing the status of the job and the human readable title of the report generator used.
-
-
interface
waeup.kofa.reports.IReportsContainer[source]¶ Extends:
grok.interfaces.IContainer,waeup.kofa.reports.IReportJobContainer,waeup.kofa.interfaces.IKofaObjectA grok container that holds report jobs.
-
class
waeup.kofa.reports.ManageReports(id, title='', description='')[source]¶ Bases:
grokcore.security.components.PermissionThe ManageReports permission allows to view, add and remove also the reports of other users. It requires the permission to handle reports.
-
__doc__= 'The ManageReports permission allows to view, add and remove also\n the reports of other users. It requires the permission to handle reports.\n '¶
-
__module__= 'waeup.kofa.reports'¶
-
-
class
waeup.kofa.reports.Report(args=[], kwargs={})[source]¶ Bases:
objectA base for reports.
-
__dict__= dict_proxy({'__providedBy__': <_interface_coptimizations.ObjectSpecificationDescriptor object at 0x7f402dea22c0>, '__module__': 'waeup.kofa.reports', 'creation_dt': None, '__provides__': <zope.interface.declarations.ClassProvides object at 0x7f4026b68150>, '__dict__': <attribute '__dict__' of 'Report' objects>, 'create_pdf': <function create_pdf at 0x7f40267df8c0>, '__implemented__': <implementedBy waeup.kofa.reports.Report>, '__weakref__': <attribute '__weakref__' of 'Report' objects>, '__doc__': 'A base for reports.\n ', '__init__': <function __init__ at 0x7f40267df1b8>})¶
-
__doc__= 'A base for reports.\n '¶
-
__implemented__= <implementedBy waeup.kofa.reports.Report>¶
-
__module__= 'waeup.kofa.reports'¶
-
__providedBy__¶ Special descriptor for class __provides__
The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.
For example:
>>> from zope.interface import Interface >>> class IFooFactory(Interface): ... pass >>> class IFoo(Interface): ... pass >>> class C(object): ... implements(IFoo) ... classProvides(IFooFactory) >>> [i.getName() for i in C.__provides__] ['IFooFactory']
>>> [i.getName() for i in C().__provides__] ['IFoo']
-
__provides__¶ Special descriptor for class __provides__
The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.
For example:
>>> from zope.interface import Interface >>> class IFooFactory(Interface): ... pass >>> class IFoo(Interface): ... pass >>> class C(object): ... implements(IFoo) ... classProvides(IFooFactory) >>> [i.getName() for i in C.__provides__] ['IFooFactory']
>>> [i.getName() for i in C().__provides__] ['IFoo']
-
__weakref__¶ list of weak references to the object (if defined)
-
creation_dt= None¶
-
-
class
waeup.kofa.reports.ReportGenerator[source]¶ Bases:
objectA base for report generators.
-
__dict__= dict_proxy({'__providedBy__': <_interface_coptimizations.ObjectSpecificationDescriptor object at 0x7f402dea22c0>, '__module__': 'waeup.kofa.reports', 'title': u'Unnamed Report', '__provides__': <zope.interface.declarations.ClassProvides object at 0x7f4026b68910>, '__doc__': 'A base for report generators.\n ', '__dict__': <attribute '__dict__' of 'ReportGenerator' objects>, '__implemented__': <implementedBy waeup.kofa.reports.ReportGenerator>, '__weakref__': <attribute '__weakref__' of 'ReportGenerator' objects>, 'generate': <function generate at 0x7f40267df488>})¶
-
__doc__= 'A base for report generators.\n '¶
-
__implemented__= <implementedBy waeup.kofa.reports.ReportGenerator>¶
-
__module__= 'waeup.kofa.reports'¶
-
__providedBy__¶ Special descriptor for class __provides__
The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.
For example:
>>> from zope.interface import Interface >>> class IFooFactory(Interface): ... pass >>> class IFoo(Interface): ... pass >>> class C(object): ... implements(IFoo) ... classProvides(IFooFactory) >>> [i.getName() for i in C.__provides__] ['IFooFactory']
>>> [i.getName() for i in C().__provides__] ['IFoo']
-
__provides__¶ Special descriptor for class __provides__
The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.
For example:
>>> from zope.interface import Interface >>> class IFooFactory(Interface): ... pass >>> class IFoo(Interface): ... pass >>> class C(object): ... implements(IFoo) ... classProvides(IFooFactory) >>> [i.getName() for i in C.__provides__] ['IFooFactory']
>>> [i.getName() for i in C().__provides__] ['IFoo']
-
__weakref__¶ list of weak references to the object (if defined)
-
title= u'Unnamed Report'¶
-
-
class
waeup.kofa.reports.ReportJobContainer[source]¶ Bases:
objectA mix-in that provides functionality for asynchronous report jobs.
-
__dict__= dict_proxy({'__providedBy__': <_interface_coptimizations.ObjectSpecificationDescriptor object at 0x7f402dea22c0>, '__module__': 'waeup.kofa.reports', 'get_running_report_jobs': <function get_running_report_jobs at 0x7f4026b692a8>, 'running_report_jobs': [], 'report_entry_from_job_id': <function report_entry_from_job_id at 0x7f4026b69410>, 'start_report_job': <function start_report_job at 0x7f4026b69230>, 'delete_report_entry': <function delete_report_entry at 0x7f4026b69398>, '__provides__': <zope.interface.declarations.ClassProvides object at 0x7f40277f6210>, 'get_report_jobs_status': <function get_report_jobs_status at 0x7f4026b69320>, '__dict__': <attribute '__dict__' of 'ReportJobContainer' objects>, '__implemented__': <implementedBy waeup.kofa.reports.ReportJobContainer>, '__weakref__': <attribute '__weakref__' of 'ReportJobContainer' objects>, '__doc__': 'A mix-in that provides functionality for asynchronous report jobs.\n '})¶
-
__doc__= 'A mix-in that provides functionality for asynchronous report jobs.\n '¶
-
__implemented__= <implementedBy waeup.kofa.reports.ReportJobContainer>¶
-
__module__= 'waeup.kofa.reports'¶
-
__providedBy__¶ Special descriptor for class __provides__
The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.
For example:
>>> from zope.interface import Interface >>> class IFooFactory(Interface): ... pass >>> class IFoo(Interface): ... pass >>> class C(object): ... implements(IFoo) ... classProvides(IFooFactory) >>> [i.getName() for i in C.__provides__] ['IFooFactory']
>>> [i.getName() for i in C().__provides__] ['IFoo']
-
__provides__¶ Special descriptor for class __provides__
The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.
For example:
>>> from zope.interface import Interface >>> class IFooFactory(Interface): ... pass >>> class IFoo(Interface): ... pass >>> class C(object): ... implements(IFoo) ... classProvides(IFooFactory) >>> [i.getName() for i in C.__provides__] ['IFooFactory']
>>> [i.getName() for i in C().__provides__] ['IFoo']
-
__weakref__¶ list of weak references to the object (if defined)
-
delete_report_entry(entry)[source]¶ Delete the report job denoted by entry.
Removes entry from the local running_report_jobs list and also removes the regarding job via the local job manager.
entry is a tuple
(<job id>, <generator name>, <user id>)as created bystart_report_job()or returned byget_running_report_jobs().
-
get_report_jobs_status(user_id=None)[source]¶ Get running/completed report jobs for user_id as list of tuples.
Each tuple holds
<raw status>, <status translated>, <generator title>in that order, where<status translated>and<generator title>are translated strings representing the status of the job and the human readable title of the report generator used.
-
get_running_report_jobs(user_id=None)[source]¶ Get report jobs for user with user_id as list of tuples.
Each tuples holds
<job_id>, <generator_name>, <user_id>in that order. The<generator_name>is the utility name of the used report generator.If user_id is
None, all running report jobs are returned.
-
report_entry_from_job_id(job_id)[source]¶ Get entry tuple for job_id.
Returns
Noneif no such entry can be found.
-
running_report_jobs= []¶
-
start_report_job(generator_name, user_id, args=[], kw={})[source]¶ Start asynchronous export job.
- generator_name
- is the name of a report generator utility to be used.
- user_id
- is the ID of the user that triggers the report generation.
- args and kw
- args and keywords passed to the generators generate() method.
The job_id is stored along with exporter name and user id in a persistent list.
Returns the job ID of the job started, None if the job could not be started.
-
-
class
waeup.kofa.reports.ReportsContainer[source]¶ Bases:
grokcore.content.components.Container,waeup.kofa.reports.ReportJobContainerA container for reports.
-
__doc__= 'A container for reports.\n '¶
-
__implemented__= <implementedBy waeup.kofa.reports.ReportsContainer>¶
-
__module__= 'waeup.kofa.reports'¶
-
__provides__¶ Special descriptor for class __provides__
The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.
For example:
>>> from zope.interface import Interface >>> class IFooFactory(Interface): ... pass >>> class IFoo(Interface): ... pass >>> class C(object): ... implements(IFoo) ... classProvides(IFooFactory) >>> [i.getName() for i in C.__provides__] ['IFooFactory']
>>> [i.getName() for i in C().__provides__] ['IFoo']
-
-
class
waeup.kofa.reports.ReportsContainerPlugin[source]¶ Bases:
grokcore.component.components.GlobalUtilityA plugin that updates sites to contain a reports container.
-
__doc__= 'A plugin that updates sites to contain a reports container.\n '¶
-
__implemented__= <implementedBy waeup.kofa.reports.ReportsContainerPlugin>¶
-
__module__= 'waeup.kofa.reports'¶
-
__provides__¶ Special descriptor for class __provides__
The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.
For example:
>>> from zope.interface import Interface >>> class IFooFactory(Interface): ... pass >>> class IFoo(Interface): ... pass >>> class C(object): ... implements(IFoo) ... classProvides(IFooFactory) >>> [i.getName() for i in C.__provides__] ['IFooFactory']
>>> [i.getName() for i in C().__provides__] ['IFoo']
-
deprecated_attributes= []¶
-
-
class
waeup.kofa.reports.ReportsManager(id, title, description='')[source]¶ Bases:
grok.components.RoleThe Reports Manager has the permission to view, add and remove all reports.
-
__doc__= 'The Reports Manager has the permission to view, add and remove\n **all** reports.\n '¶
-
__module__= 'waeup.kofa.reports'¶
-
-
class
waeup.kofa.reports.ReportsOfficer(id, title, description='')[source]¶ Bases:
grok.components.RoleThe Reports Officer has the permission to view, add and remove own reports.
-
__doc__= 'The Reports Officer has the permission to view, add and remove\n **own** reports.\n '¶
-
__module__= 'waeup.kofa.reports'¶
-
-
waeup.kofa.reports.get_generators()[source]¶ Get available report generators.
Returns an iterator of tuples
<NAME, GENERATOR>withNAMEbeing the name under which the respective generator was registered.
-
waeup.kofa.reports.report_job(site, generator_name, args=[], kw={})[source]¶ Get a generator and perform report creation.
- site
- is the site for which the report should be created.
- generator_name
- the global utility name under which the desired generator is registered.
- args and kw
- Arguments and keywords to be passed to the generate() method of the desired generator. While args should be a list, kw should be a dictionary.