user2665694
user2665694

Reputation:

Canoncial way to retrieve the IntID of an content object based on Dexterity

The five.intid documentation states the following pattern for retrieving the IntID for an object:

from five.intid import site
intids = site.get_intids(app.plone)
intid_obj = intids.getId(app.plone.restrictedTraverse('path/to/object')

Is this the canoncical way also in Plone or is there some helper/utility method available wrapping the code above?

Upvotes: 0

Views: 295

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1123450

I always use:

from zope.component import getUtility
from zope.intid.interfaces import IIntIds

intid = getUtility(IIntIds).getId(object)

as the intid utility is registered with the local component manager.

Upvotes: 2

Related Questions