Repository navigation
Conversation
|
Thanks for putting this together. I’m open to switching to Docform. Could you address two compatibility issues we found with 1.0.2?
Could you publish a release with those fixes and the [large-template rendering fix from Docform #210](cvas22/docform#210), then update this PR to pin that release? That would give us a build to validate against our reporting suite and larger templates. |
|
@chrismaddalena thanks for the report, could you confirm if the two issues preexists in the old library (python-docx)? |
|
Thx for testing. Both are fixed in docform 1.1.0, now on PyPI: header, footer and body images get unique drawing IDs, and tables without a |
Use docform[subdoc] from PyPI in place of the GhostManager python-docx-template fork, and import DocxTemplate/RichText from docform. Add docform. to the render sandbox's blocked module prefixes. The forked python-docx is left as-is.
Issue
#1013 (per discussion, opening to a PR for this in the thread).
Description of the Change
Swaps the report writer off the GhostManager fork of
python-docx-templateand onto docform, a maintained fork of the same project published on PyPI. Full disclosure, I maintain docform.The reportwriter only touches the public API (
DocxTemplate,RichText,new_subdoc), so this is an import swap plus the requirements pin:docform[subdoc]==1.1.0instead of the git pin, andfrom docform import ...in the three reportwriter modules. I left your forkedpython-docxalone; docform'spython-docxrequirement is unpinned, so your fork still satisfies it and nothing gets double-installed. I also added"docform."toReportSandboxedEnvironment._blocked_object_module_prefixesso the render sandbox keeps blocking the templating library's internals now that they live under a different module.Alternate Designs
Keep carrying the fork. The reason to switch is to stop maintaining a private fork and pick up fixes from a maintained one. docform already made the post-render body swap linear, which looks like what a lot of your fork's perf commits are about, and upstream PR #626 (OOXML font/style order) is in it too.
Possible Drawbacks
docform tracks upstream
python-docx-template, so any Ghostwriter-specific behavior in your fork that never went upstream could differ. I diffed yourv0.21.0against upstream: the 37 commits ahead are almost all performance work, plus a couple of header/footer Jinja-detection tweaks. The full reporting suite passes against docform, but if you have templates with unusual Jinja in headers or footers those are the spot worth an eyeball.Verification Process
Built the CI django image with the docform pin (installs cleanly alongside your
python-docxfork), brought up postgres and redis, and ranmanage.py test ghostwriter.reporting --exclude-tag=GitHubagainst docform 1.0.2. 667 tests pass, no failures. The existing reporting tests exercise the DOCX/PPTX export, rich text, templating and footnote paths, which is where docform does the rendering.Release Notes
Switched the report writer from the docxtpl fork to docform.