[Zope3-Users] IIntIds in test environment

Kai Diefenbach usenet at diefenba.ch
Wed Jun 4 11:19:11 EDT 2008


Hi, 

to register a IntIds utility by startup I'm using following subscriber:

<snip>

def bootStrapSubscriber(event):
    """Subscriber to the IDataBaseOpenedEvent

    Create local utilities if not yet present
    """
    db, connection, root, root_folder = getInformationFromEvent(event)

    ensureUtility(root_folder, IIntIds, '', IntIds, copy_to_zlog=False)
    transaction.commit()
    connection.close()

</snip>

and register this with 

<snip>

  <subscriber
      for="zope.app.appsetup.IDatabaseOpenedEvent"
      handler=".bootstrap.bootStrapSubscriber" />

</snip>

This is working when zope is running.

I wonder why it isn't within tests. the code above is executed but the
IntIds utility is not available.

With:

<snip>

    >>> from zope.app.intid.interfaces import IIntIds
    >>> from zope.component import getUtility
    >>> intids = getUtility(IIntIds)

</snip>

I get: 

File
"/Users/Kai/Zope/instances/iqpp.qab/src/iqppqab/actions/adapters/actions
.txt", line 28, in actions.txt
Failed example:
    intids = getUtility(IIntIds)
Exception raised:
    Traceback (most recent call last):
      File
"/Users/Kai/Zope/instances/iqpp.qab/eggs/tmpDJ2x_9/zope.testing-3.5.1-py
2.4.egg/zope/testing/doctest.py", line 1356, in __run
        
      File "<doctest actions.txt[10]>", line 1, in ?
        intids = getUtility(IIntIds)
      File
"/Users/Kai/Zope/instances/iqpp.qab/eggs/zope.component-3.4.0-py2.4.egg/
zope/component/_api.py", line 207, in getUtility
        raise ComponentLookupError(interface, name)
    ComponentLookupError: (<InterfaceClass
zope.app.intid.interfaces.IIntIds>, '')

I guess I don't understand the whole SiteManager thing. Is there a
working example of how to setup a test environment with IntIds.

Thanks
Kai

-- 
iqplusplus - http://iqpp.de
EasyShop - http://easyshop-for-plone.googlecode.com/



More information about the Zope3-users mailing list