Search code examples
pythonplonedexterity

Resolving an IntId


I am passing an IntId of Dexterity content through a form into a browser view. How can I resolve the IntId back into the original object in Plone?


Solution

  • Use the IIntIds utility:

    from zope.component import getUtility
    from zope.intid.interfaces import IIntIds
    
    intidutil = getUtility(IIntIds)
    object = intidutil.getObject(id)
    

    Alternatively, you could use the .queryObject() method, it takes a default keyword parameter (defaults to None), returned if the id is not found.