diff --git a/docgen/README.txt b/docgen/README.txt new file mode 100644 index 0000000..b9d009f --- /dev/null +++ b/docgen/README.txt @@ -0,0 +1,10 @@ +================================================================ +docgen - Document Generation from Result Sets and XML Structures +================================================================ + + >>> from zope import component + >>> from zope.publisher.browser import TestRequest + + >>> from cybertools.docgen.base import WordDocument + >>> doc = WordDocument(None, TestRequest) + diff --git a/docgen/__init__.py b/docgen/__init__.py new file mode 100644 index 0000000..5bb534f --- /dev/null +++ b/docgen/__init__.py @@ -0,0 +1 @@ +# package diff --git a/docgen/base.py b/docgen/base.py new file mode 100644 index 0000000..cc961e4 --- /dev/null +++ b/docgen/base.py @@ -0,0 +1,55 @@ +# +# Copyright (c) 2012 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 +# + +""" +View definitions for generation of documents. +""" + +from zope.app.pagetemplate import ViewPageTemplateFile +from zope.cachedescriptors.property import Lazy +from zope.publisher.browser import BrowserPage + +word_template = ViewPageTemplateFile('word_page.pt') + + +class Base(BrowserPage): + + def __call__(self): + return self.index() + + +class WordDocument(Base): + + index = word_template + + def setHeader(self, data, filename='document'): + fn = '%s.doc' % filename + response = self.request.response + response.setHeader('Cache-Control', '') + response.setHeader('Pragma', '') + response.setHeader('Content-Type', 'application/msword;charset=utf-8') + response.setHeader('Content-Length', len(data)) + response.setHeader('Content-Disposition', 'filename="%s"' % fn) + + mswordXml = """ + + Print + 90 + + + """ diff --git a/docgen/tests.py b/docgen/tests.py new file mode 100755 index 0000000..48cd742 --- /dev/null +++ b/docgen/tests.py @@ -0,0 +1,26 @@ +""" +unit tests, doc tests +""" + +import unittest, doctest +from zope.testing.doctestunit import DocFileSuite +from zope.interface.verify import verifyClass +from zope.interface import implements + + +class Test(unittest.TestCase): + "Basic tests for the docgen package." + + def testInterfaces(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') diff --git a/docgen/word_macros.pt b/docgen/word_macros.pt new file mode 100644 index 0000000..99c8fc0 --- /dev/null +++ b/docgen/word_macros.pt @@ -0,0 +1,70 @@ + + + + +
+ +
+

Title

+
+

+
+ + + + +
+ Start date: +

startDate

+
+ +

Index

+
+

1. Introduction

+
+ +

For ... + .

+ +
+
+ +
+

Annex 1: ...

+
+
+ +
+
+

+ Footnote Text...

+ +
+
+
+
+

$refNumber

+
+
+
Page + PAGE +
+
+
+
+ + + + diff --git a/docgen/word_page.pt b/docgen/word_page.pt new file mode 100644 index 0000000..649c9dc --- /dev/null +++ b/docgen/word_page.pt @@ -0,0 +1,23 @@ + + + + Document + + + + + + + + +
Body Text
+ + +