Consider a Plone browser view like this:
from Acquisition import aq_inner
from zope.component import getUtility
from zope.intid.interfaces import IIntIds
class SomeView(grok.View)
grok.name('some-view')
def render(self):
doc = aq_inner(self.context)
intids = getUtility(IIntIds)
to_id = intids.getId(doc)
[...]
There's nothing wrong with this code, yet we got a KeyError on the
getId call. After a while we figured out that this only happens when
virtual hosting is configured to hide the portal name (e.g.
http://somehost/
proxies to http://localhost:8080/Plone
) AND the URL
contains the portal name anyway (http://somehost/Plone/...
- this
happens if you use getPhysicalPath() instead of absolute_url()). In
this case the Acquisition chain contains the portal twice and aq_iter
(from five.intid.utils) wrongly detects a __parent__ loop. Removing
the protal name from the URL (by using absolute_url()) solved the
issue.