If you start up the zope site via bin/instance debug
it's not clear what plone
site should be used, since there can be more than one.
So you first need to define what plone site plone.api
should use. This is done by pointing the site manager to your plone site.
./bin/instance debug
Starting debugger (the name "app" is bound to the top-level Zope object)
...
...
>>>
>>> api.portal.get() # Will not work
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/path/to/egg/plone.api.egg/plone/api/portal.py", line 82, in get
'Unable to get the portal object. More info on '
CannotGetPortalError: Unable to get the portal object. More info on http://docs.plone.org/develop/plone.api/docs/api/exceptions.html#plone.api.exc.CannotGetPortalError
>>> plone = app.get('my-plone-site')
>>> plone
<PloneSite at /my-plone-site>
>>> from zope.component.hooks import setSite
>>> setSite(plone)
>>> from plone import api
>>> api.portal.get()
<PloneSite at /my-plone-site>
That's it.