docx.protection
paper-docx 0.2.0 API reference
Document-protection awareness (paper-docx).
Word's Restrict Editing pane writes w:documentProtection into
word/settings.xml; Word then blocks or restricts editing. This package's own
mutating APIs check that setting and refuse with DocumentProtectedError
rather than silently editing a locked template — the same fail-loudly
principle applied elsewhere in this fork. The refusal follows Word's own rules,
which are per-mode AND per-operation-class (see _PROTECTION_MATRIX): a
comments-only restriction blocks body edits but still permits commenting.
Upstream python-docx APIs are untouched (strict superset).
Protection is ADVISORY, not security: the setting is plain XML anyone can
remove. The sanctioned override is one explicit, document-level
acknowledgment — acknowledge_protection(document) — after which this
package's APIs treat the document as unlocked for the life of the open
package. There is deliberately NO protection-stripping verb: the setting is
reported by protection_status and never removed.
OPERATION_CLASSES
attributeOPERATION_CLASSES= (OP_COMMENT, OP_FORM_FIELD, OP_BODY)OP_BODY
attributeOP_BODY= 'body-content'OP_COMMENT
attributeOP_COMMENT= 'comment'OP_FORM_FIELD
attributeOP_FORM_FIELD= 'form-field-value'