zms-publishing / ZMS

Running on Python 3.8+
12 stars 6 forks source link

Word/DOCX-Eport: Applying python-docx #287

Open drfho opened 4 months ago

drfho commented 4 months ago

Traditionally ZMS uses the XML-represenation of it's content for (XSL-based) transforming it into 3rd-party formats like Word-XML. Instead using XSL (and its efforts with debugging) a direct, pythonic objekt transformation by the python-docx-library may be more practical especially with complex content-models . python-docx is a Python library for creating and updating Microsoft Word (.docx) files: https://python-docx.readthedocs.io/

drfho commented 4 months ago

The evaluation notebook of https://github.com/zms-publishing/ZMS/commit/1e726cda04f3e7235b5605e0e0718349139158dc in https://github.com/zms-publishing/ZMS/pull/288 contains some code- snippets to create a word file interacting directly with ZODB.

image

The notebook code is quite minimalistic to get objects attribute values by the rest_api public functions. @zmsdev: But template based content aggregration will result in "AttributeError: REQUEST" due to ZMSObject.isVisible(self, REQUEST) and its call of self.isActive(REQUEST), Line 502:

https://github.com/zms-publishing/ZMS/blob/f12ccd8f8c0a19a2499079e7d72e811fed8b826d/Products/zms/zmsobject.py#L496-L504

The function ObjAttrs.isActive() calls self.getType() and this will break, Line 551;

https://github.com/zms-publishing/ZMS/blob/f12ccd8f8c0a19a2499079e7d72e811fed8b826d/Products/zms/_objattrs.py#L656-L708