Skip to content

Commit

Permalink
Add comments RE 'default_value_class' and update the BaseStreamBlock …
Browse files Browse the repository at this point in the history
…class instead of just StreamBlock (it's a sensible default for both)
  • Loading branch information
ababic committed Apr 9, 2024
1 parent 5b1c9d8 commit 77a115c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions wagtail/blocks/stream_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def as_json_data(self):


class BaseStreamBlock(Block):
# This is set to `StreamValue` a little further down. The idea is that
# developers can override this on custom subclasses to change the default
# `value_class` for all instances
default_value_class = None

def __init__(self, local_blocks=None, search_index=True, **kwargs):
Expand Down Expand Up @@ -769,6 +772,11 @@ def __reduce__(self):
)


# Now that StreamValue is defined, make it the default `value_class`
# for all `BaseStreamBlock` subclasses
BaseStreamBlock.default_value_class = StreamValue


class StreamBlockAdapter(Adapter):
js_constructor = "wagtail.blocks.StreamBlock"

Expand Down Expand Up @@ -813,7 +821,4 @@ def media(self):
]
)


StreamBlock.default_value_class = StreamValue

register(StreamBlockAdapter(), StreamBlock)

0 comments on commit 77a115c

Please sign in to comment.