give report and report instance a name

This commit is contained in:
Helmut Merz 2012-07-10 10:24:50 +02:00
parent 0aa539e8f8
commit e3ac0a35e9

View file

@ -25,6 +25,7 @@ from zope.component import adapts
from zope.interface import Interface, Attribute, implements from zope.interface import Interface, Attribute, implements
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from zope.security.proxy import removeSecurityProxy from zope.security.proxy import removeSecurityProxy
from zope.traversing.api import getName
from cybertools.composer.report.base import Report as BaseReport from cybertools.composer.report.base import Report as BaseReport
from cybertools.composer.report.base import LeafQueryCriteria, CompoundQueryCriteria from cybertools.composer.report.base import LeafQueryCriteria, CompoundQueryCriteria
@ -53,6 +54,8 @@ class IReport(ILoopsAdapter, IReportParams):
source='loops.expert.reportTypeSource', source='loops.expert.reportTypeSource',
required=True) required=True)
name = Attribute('The name of the report.')
class IReportInstance(IBaseReport): class IReportInstance(IBaseReport):
""" The report-type-specific object (an adapter on the report) that """ The report-type-specific object (an adapter on the report) that
@ -68,6 +71,10 @@ class Report(AdapterBase):
_contextAttributes = list(IReport) _contextAttributes = list(IReport)
@Lazy
def name(self):
return getName(self.context)
TypeInterfaceSourceList.typeInterfaces += (IReport,) TypeInterfaceSourceList.typeInterfaces += (IReport,)
@ -83,6 +90,7 @@ class ReportInstance(BaseReport):
def __init__(self, context): def __init__(self, context):
self.context = context self.context = context
self.name = context.name
def getResultsRenderer(self, name, macros): def getResultsRenderer(self, name, macros):
return macros[name] return macros[name]