Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix circular import for PageInterface when using custom page interface #404

Merged
merged 7 commits into from
Sep 17, 2024

Conversation

mgax
Copy link
Member

@mgax mgax commented Sep 16, 2024

I'd like to define a custom PageInterface (using the PAGE_INTERFACE setting). Because grapple.types.pages.PageInterface is quite complex, I'd like to inherit from it, and add some additional fields.

This results in a circular import, because the definition of the Page class in the same module calls get_page_interface:

class Page(DjangoObjectType):
"""
Base Page type used if one isn't generated for the current model.
All other node types extend this.
"""
class Meta:
model = WagtailPage
interfaces = (get_page_interface(),)


This PR moves PageInterface and get_page_interface to a new module, interfaces.py.

@mgax mgax marked this pull request as ready for review September 16, 2024 11:08
@mgax
Copy link
Member Author

mgax commented Sep 16, 2024

CI is failing for the coverage job, but it looks like all recent CI runs are failing on that.

@zerolab
Copy link
Member

zerolab commented Sep 16, 2024

the actions/upload-artifact step needs include-hidden-files: true (example, reference)

@zerolab
Copy link
Member

zerolab commented Sep 16, 2024

Since we're making these changes, it may be worth moving the StreamFieldInterface in the new interfaces module

@mgax mgax requested a review from zerolab September 17, 2024 16:24
@mgax
Copy link
Member Author

mgax commented Sep 17, 2024

Since we're making these changes, it may be worth moving the StreamFieldInterface in the new interfaces module

Ah, I had meant to do that, but got carried away. Thanks!

# This conditionnal and below support both Wagtail >= 2.13 and <2.12 versions.
# The "stream_data" check can be dropped once 2.11 is not supported anymore.
# Cf: https://docs.wagtail.io/en/stable/releases/2.12.html#stream-data-on-streamfield-values-is-deprecated
elif hasattr(obj, "stream_data"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self: follow up with clean-up PR

Copy link
Member

@zerolab zerolab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zerolab zerolab merged commit db86c97 into torchbox:main Sep 17, 2024
16 checks passed
@mgax mgax deleted the fix/page-interface-circular-import branch September 17, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants