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

Move INameFromTitle interface to plone.base #271

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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