[silva.export.html][Emiliano D'Alterio] Added method to export h...
[email protected] Mon, 07 Oct 2013 14:54:03 +0200
| Newsgroups | gmane.comp.web.zope.silva.cvs |
|---|---|
| Message-ID | <[email protected]> |
author: Emiliano D'Alterio
date: Mon Oct 07 14:53:44 2013 +0200
revision: 13:e3d8f9a2005c in silva.export.html
branch:
details: https://hg.infrae.com/silva.export.html?cmd=changeset;node=e3d8f9a2005c
modified: src/silva/export/html/html.py
added:
removed:
log: Added method to export html to a folder in order to support export
to PDF feature.
diffstat:
src/silva/export/html/html.py | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diffs (34 lines):
diff -r a49424c7ca17 -r e3d8f9a2005c src/silva/export/html/html.py
--- a/src/silva/export/html/html.py Wed Mar 06 15:29:49 2013 +0100
+++ b/src/silva/export/html/html.py Mon Oct 07 14:53:44 2013 +0200
@@ -3,7 +3,7 @@
# See also LICENSE.txt
from cStringIO import StringIO
-from zipfile import ZipFile, ZIP_DEFLATED
+from zipfile import ZipFile, ZIP_DEFLATED, ZIP_STORED
import logging
import os
@@ -122,7 +122,7 @@
for name, skin in getUtilitiesFor(IBrowserSkinType):
if skin.extends(IHTMLExportSkin):
terms.append(SimpleTerm(
- value=skin, token=skin.__identifier__, title=name))
+ value=skin, token=skin.__identifier__, title=name))
return SimpleVocabulary(terms)
@@ -150,3 +150,12 @@
Exporter(HTMLExportSettings(self.context, html_skin), archive).export()
archive.close()
return output.getvalue()
+
+ def export_to_folder(self, folder, html_skin, **options):
+ ## We use zero compression setting, it should be faster.
+ archive = ZipFile(StringIO(), "w", ZIP_STORED)
+ Exporter(HTMLExportSettings(self.context, html_skin), archive).export()
+ ## We extract all the archive content to the folder specified.
+ archive.extractall(folder)
+ archive.close()
+ return folder