create report sub-package for generic report configuration
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3774 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
ec60869bf9
commit
e256eb1bc5
7 changed files with 242 additions and 0 deletions
11
composer/report/README.txt
Normal file
11
composer/report/README.txt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
=================
|
||||||
|
Report Management
|
||||||
|
=================
|
||||||
|
|
||||||
|
($Id$)
|
||||||
|
|
||||||
|
>>> from zope import component
|
||||||
|
>>> from cybertools.composer.report.base import ReportManager, Report
|
||||||
|
|
||||||
|
>>> manager = ReportManager()
|
||||||
|
|
4
composer/report/__init__.py
Normal file
4
composer/report/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
"""
|
||||||
|
$Id$
|
||||||
|
"""
|
||||||
|
|
67
composer/report/base.py
Normal file
67
composer/report/base.py
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
|
||||||
|
"""
|
||||||
|
Basic classes for report management.
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
"""
|
||||||
|
|
||||||
|
from zope.interface import implements
|
||||||
|
|
||||||
|
from cybertools.composer.base import Component, Element, Compound
|
||||||
|
from cybertools.composer.base import Template
|
||||||
|
from cybertools.composer.report.interfaces import IReportManager, IReport
|
||||||
|
from cybertools.util.jeep import Jeep
|
||||||
|
from cybertools.util.randomname import generateName
|
||||||
|
|
||||||
|
|
||||||
|
class ReportManager(object):
|
||||||
|
|
||||||
|
implements(IReportManager)
|
||||||
|
|
||||||
|
reports = manager = None
|
||||||
|
reportsFactory = dict
|
||||||
|
|
||||||
|
def getManager(self):
|
||||||
|
return self.manager
|
||||||
|
|
||||||
|
def addReport(self, report):
|
||||||
|
if self.reports is None:
|
||||||
|
self.reports = self.reportsFactory()
|
||||||
|
id = report.identifier
|
||||||
|
if not id:
|
||||||
|
id = generateName(self.checkId)
|
||||||
|
report.identifier = id
|
||||||
|
self.reports[id] = report
|
||||||
|
return report
|
||||||
|
|
||||||
|
def checkId(self, id):
|
||||||
|
return id not in self.reports.keys()
|
||||||
|
|
||||||
|
|
||||||
|
class Report(Template):
|
||||||
|
|
||||||
|
implements(IReport)
|
||||||
|
|
||||||
|
name = identifier = u''
|
||||||
|
type = 'generic'
|
||||||
|
manager = None
|
||||||
|
|
||||||
|
def __init__(self, name):
|
||||||
|
self.name = name
|
8
composer/report/configure.zcml
Normal file
8
composer/report/configure.zcml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<!-- $Id$ -->
|
||||||
|
|
||||||
|
<configure
|
||||||
|
xmlns="http://namespaces.zope.org/zope"
|
||||||
|
xmlns:browser="http://namespaces.zope.org/browser"
|
||||||
|
i18n_domain="cybertools.composer">
|
||||||
|
|
||||||
|
</configure>
|
57
composer/report/instance.py
Normal file
57
composer/report/instance.py
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
|
||||||
|
"""
|
||||||
|
Report instance and related classes.
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
"""
|
||||||
|
|
||||||
|
from string import Template
|
||||||
|
from zope import component
|
||||||
|
from zope.interface import implements
|
||||||
|
from zope.publisher.browser import TestRequest
|
||||||
|
try:
|
||||||
|
from zope.traversing.browser.absoluteurl import absoluteURL
|
||||||
|
zope29 = False
|
||||||
|
except ImportError:
|
||||||
|
from zope.app.traversing.browser.absoluteurl import absoluteURL
|
||||||
|
from Acquisition import aq_parent, aq_inner
|
||||||
|
zope29 = True
|
||||||
|
|
||||||
|
from cybertools.composer.instance import Instance
|
||||||
|
from cybertools.composer.interfaces import IInstance
|
||||||
|
from cybertools.util.jeep import Jeep
|
||||||
|
|
||||||
|
_not_found = object()
|
||||||
|
|
||||||
|
|
||||||
|
class ReportInstance(Instance):
|
||||||
|
|
||||||
|
template = client = None
|
||||||
|
|
||||||
|
def __init__(self, client, template, manager):
|
||||||
|
self.client = client
|
||||||
|
self.template = template
|
||||||
|
self.manager = manager
|
||||||
|
|
||||||
|
def applyTemplate(self, **kw):
|
||||||
|
data = [] # TODO: create result set
|
||||||
|
request = data.get('request') or TestRequest()
|
||||||
|
return data
|
||||||
|
|
73
composer/report/interfaces.py
Normal file
73
composer/report/interfaces.py
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
|
||||||
|
"""
|
||||||
|
Report management.
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
"""
|
||||||
|
|
||||||
|
from zope.interface import Interface, Attribute
|
||||||
|
from zope.i18nmessageid import MessageFactory
|
||||||
|
from zope import schema
|
||||||
|
|
||||||
|
from cybertools.composer.interfaces import ITemplate, IComponent
|
||||||
|
from cybertools.composer.interfaces import IInstance
|
||||||
|
|
||||||
|
_ = MessageFactory('cybertools.composer')
|
||||||
|
|
||||||
|
|
||||||
|
class IReportManager(Interface):
|
||||||
|
""" A manager (or container) for complex messages.
|
||||||
|
"""
|
||||||
|
|
||||||
|
title = schema.TextLine(
|
||||||
|
title=_(u'Title'),
|
||||||
|
description=_(u'The title of the object.'),
|
||||||
|
required=True,)
|
||||||
|
|
||||||
|
reports = Attribute('A collection of message objects managed.')
|
||||||
|
|
||||||
|
def addReport(report):
|
||||||
|
""" Add a report.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class IReport(Interface):
|
||||||
|
""" A complex message that may be expanded using instance data.
|
||||||
|
"""
|
||||||
|
|
||||||
|
identifier = schema.ASCIILine(
|
||||||
|
title=_(u'Identifier'),
|
||||||
|
description=_(u'The (internal) identifier of the report.'),
|
||||||
|
required=True,)
|
||||||
|
name = schema.ASCIILine(
|
||||||
|
title=_(u'Name'),
|
||||||
|
description=_(u'The (visible) name of the report.'),
|
||||||
|
required=True,)
|
||||||
|
title = schema.TextLine(
|
||||||
|
title=_(u'Title'),
|
||||||
|
description=_(u'The title or label of the report.'),
|
||||||
|
required=True,)
|
||||||
|
description = schema.Text(
|
||||||
|
title=_(u'Description'),
|
||||||
|
description=_(u'A brief description of the report.'),
|
||||||
|
required=False,)
|
||||||
|
|
||||||
|
manager = Attribute('The manager of this message object')
|
||||||
|
|
22
composer/report/tests.py
Executable file
22
composer/report/tests.py
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
# $Id$
|
||||||
|
|
||||||
|
import unittest, doctest
|
||||||
|
from zope.testing.doctestunit import DocFileSuite
|
||||||
|
|
||||||
|
|
||||||
|
class Test(unittest.TestCase):
|
||||||
|
"Basic tests."
|
||||||
|
|
||||||
|
def testBasics(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def test_suite():
|
||||||
|
flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
|
||||||
|
return unittest.TestSuite((
|
||||||
|
unittest.makeSuite(Test),
|
||||||
|
DocFileSuite('README.txt', optionflags=flags),
|
||||||
|
))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(defaultTest='test_suite')
|
Loading…
Add table
Reference in a new issue