Solved: [Zope3-dev] persistent data in (not local) utilitiy

Markus Leist ml_zope3_dev at ikom-online.de
Mon Jan 30 16:53:18 EST 2006


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()

does.

Bye, Markus

Am Freitag 27 Januar 2006 10:20 schrieb Markus Leist:
> Hi all,
>
> *local* utilities (configured in zcml, right?) are accessible in a
> IProcessStartingEvent-Subscriber:
> (debug-point in my Subscriber  ->)
> (Pdb) from zope.app.error.interfaces import IErrorReportingUtility
> (Pdb) myu1=zapi.getUtility(IErrorReportingUtility)
> (Pdb) p myu1.getProperties()
> {'ignored_exceptions': ('Unauthorized',), 'keep_entries': 20,
> 'copy_to_zlog': 0} In this case data is not persistent.
>
> _my_ utility was born in IProcessStartingEvent
> (_after_ commit in IDatabaseOpenedEvent) by ensureUtility(...)
>
> In this subscriber i don't see any utility which is not local.
>
> (On IRC-Channel it was asked for permissions to get utility, where
> i have to start debugging?)
>
> Is there any chance to get an utility not defined in ZCML in this way
> (at start of Zope)? Or to easy store attribute-data in a local utility?
>
> I have to count all starts of the Zope-Instance (and have to do
> "something more").
>
> Bye, Markus


More information about the Zope3-dev mailing list