Skip to content

Commit

Permalink
Merge pull request #271 from plone/use-interface-from-plone-base
Browse files Browse the repository at this point in the history
Move `INameFromTitle` interface to `plone.base`
  • Loading branch information
mauritsvanrees authored Nov 2, 2023
2 parents 1e8d0c3 + ccc85f6 commit d487863
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
5 changes: 5 additions & 0 deletions news/3858.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Mark ``INameFromTitle`` deprecated, in this distribution, as it has been moved to ``plone.base``.
It will be removed in Plone 7.0.
We do not show a deprecation warning, because doing so would break content types with this interface name in the behaviors list.
Recommended is to use ``plone.namefromtitle`` as behavior name, then it works in all supported Plone versions.
[gforcada]
30 changes: 22 additions & 8 deletions plone/app/content/interfaces.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
from zope import schema
from plone.base.interfaces import INameFromTitle as FutureINameFromTitle
from zope.interface import Attribute
from zope.interface import Interface


class INameFromTitle(Interface):
"""An object that supports gettings it name from its title."""
class INameFromTitle(FutureINameFromTitle):
"""An object that supports getting its name (id) from its title.
title = schema.TextLine(
title="Title",
description="A title, which will be converted to a name",
required=True,
)
This interface has been moved to plone.base.interfaces.
This alias will be removed in Plone 7.0.
We tried deprecating it like this:
zope.deferredimport.deprecated(
INameFromTitle="plone.base.interfaces:INameFromTitle",
)
Unfortunately this does not completely work: if your site has a content
type with behavior `plone.app.content.interfaces.INameFromTitle` this would
no longer work because the behavior is not found.
If you use `plone.namefromtitle` then it works.
So as long as we want to support the old spelling, we must keep the
interface here, and also use this interface as the `provides` in the
definition of the behavior in `plone.app.dexterity`.
See https://github.com/plone/plone.app.dexterity/pull/379
"""


class IReindexOnModify(Interface):
Expand Down
2 changes: 1 addition & 1 deletion plone/app/content/namechooser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from Acquisition import aq_base
from Acquisition import aq_inner
from plone.app.content.interfaces import INameFromTitle
from plone.base.interfaces import INameFromTitle
from plone.base.utils import check_id
from plone.i18n.normalizer import FILENAME_REGEX
from plone.i18n.normalizer.interfaces import IURLNormalizer
Expand Down
2 changes: 1 addition & 1 deletion plone/app/content/namechooser.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Title-based name chooser
An object can also gain a name based on its title. To do so, the object
must implement or be adaptable to INameFromTitle.

>>> from plone.app.content.interfaces import INameFromTitle
>>> from plone.base.interfaces import INameFromTitle

>>> @implementer(INameFromTitle)
... @adapter(IMyType)
Expand Down

0 comments on commit d487863

Please sign in to comment.