Skip to content

Commit

Permalink
Load plone.app.discussion code conditionally.
Browse files Browse the repository at this point in the history
This package is optional since Plone 6.1.
  • Loading branch information
mauritsvanrees committed Jan 7, 2025
1 parent cc5bbed commit 84319e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changelog
3.2.0 (unreleased)
------------------

- Load ``plone.app.discussion`` code conditionally.
This package is optional since Plone 6.1. [maurits]

- existingcontent tile:
Introduce new "main" macro lookup to enable full layout control within
registered "content_views" templates.
Expand Down
9 changes: 8 additions & 1 deletion src/plone/app/standardtiles/existingcontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from plone import api
from plone.app.blocks import utils
from plone.app.blocks.tiles import renderTiles
from plone.app.discussion.interfaces import IConversation
from plone.app.standardtiles import PloneMessageFactory as _
from plone.autoform import directives as form
from plone.base.utils import safe_text
Expand Down Expand Up @@ -38,6 +37,12 @@
RelatedItemsFieldWidget as ExistingContentBrowserWidget,
)

try:
from plone.app.discussion.interfaces import IConversation
except ImportError:
# plone.app.discussion is optional since Plone 6.1.
IConversation = None


def uuidToObject(uuid):
"""Given a UUID, attempt to return a content object. Will return
Expand Down Expand Up @@ -267,6 +272,8 @@ def image_tag(self):

@property
def comments_count(self):
if IConversation is None:
return 0
context = self.content_context
try:
conversation = IConversation(context)
Expand Down
1 change: 1 addition & 0 deletions src/plone/app/standardtiles/layout.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
class=".discussion.DiscussionTile"
permission="zope.Public"
add_permission="zope2.View"
zcml:condition="installed plone.app.discussion"
/>

</configure>

0 comments on commit 84319e0

Please sign in to comment.