Question

I am following the tests here: https://github.com/plone/plone.app.referenceablebehavior/blob/master/plone/app/referenceablebehavior/referenceable.txt

I added plone.app.referenceablebehavior to Plone 4.3, created a type TTW and made it referenceable:

enter image description here

Then I created an instance of the type in the site root called "My Referenceable Type Instance", and tried the following in debug mode:

>>> from plone.app.referenceablebehavior.referenceable import IReferenceable
>>> IReferenceable.providedBy(app.Plone['my-referenceable-type-instance'])
False

I would expect the result to be True. Is this a bug, or am I missing something?

[0] My buildout:

[buildout]
extends = https://raw.github.com/pythonpackages/buildout-plone/master/4.3.x-dev

[plone]
eggs +=
    plone.app.referenceablebehavior
Was it helpful?

Solution

In a debug session, you need to set the local site manager before attempting this. Try:

>>> from zope.component.hooks import setSite
>>> setSite(app.Plone)

...prior to attempting to check if IReferenceable is provided by the object. The reason that this is necessary is that Dexterity uses something called an Object Specification Descriptor that looks up interfaces dynamically from the Factory Type Information of the type, which is site-specific (you cannot retrieve site-specific configuration without first having the local site configured for lookups).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top