Am Montag, den 30.01.2006, 22:53 +0100 schrieb Markus Leist:
> Ok, getUtility() doesn't work, but:
> 
> def bootStrapSubscriberDatabase(event):
> [...]
>     db, connection, root, root_folder = getInformationFromEvent(event)
>     if ( ensureUtility(root_folder, IIkAdminUtility, 'IkAdminUtility', 
> IkAdminUtility, '') ) :
>         logger.info("Ensure unnamed IkAdminUtility")
>     sm = root_folder.getSiteManager()
>     utils = [reg for reg in sm.utilities.registrations()
>                  if reg.provided.isOrExtends(IIkAdminUtility)]
>     # [0] is a dirty quick hack
>     instIkAdminUtility = utils[0].component
>     instIkAdminUtility.nbrStarts += 1
>     [...]
>     transaction.get().commit()
>     connection.close()

Hi,

zapi.getUtility('IIkAdminUtility', name='IkAdminUtility', 
                context=root_folder)
should return the utility.

If you really want an unnamed utility you sould install it using:
zope.app.appsetup.bootstrap.ensureUtility(root_folder, IIkAdminUtility, 
                                          '', IkAdminUtility)

The utility_type is used as name for the utility so you have to give it
as a parameter to zapi.getUtility

HTH
mac


_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to