Skip to content

Commit e1927e5

Browse files
author
Steve Canny
committed
add Part._before_marshal()
1 parent ba56ea4 commit e1927e5

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

opc/package.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ def _after_unmarshal(self):
150150
# subclass
151151
pass
152152

153+
def _before_marshal(self):
154+
"""
155+
Entry point for pre-serialization processing, for example to finalize
156+
part naming if necessary. May be overridden by subclasses without
157+
forwarding call to super.
158+
"""
159+
# don't place any code here, just catch call if not overridden by
160+
# subclass
161+
pass
162+
153163

154164
class PartFactory(object):
155165
"""

opc/pkgwriter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ def write(pkg_file, pkg_rels, parts):
2727
*pkg_rels* and *parts* and a content types stream based on the
2828
content types of the parts.
2929
"""
30+
raise NotImplementedError()

tests/test_package.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ def it_can_add_a_relationship_to_another_part(self, part):
169169
def it_can_be_notified_after_unmarshalling_is_complete(self, part):
170170
part._after_unmarshal()
171171

172+
def it_can_be_notified_before_marshalling_is_started(self, part):
173+
part._before_marshal()
174+
172175

173176
class DescribePartFactory(object):
174177

0 commit comments

Comments
 (0)