[Grok-dev] getUtility(ICatalog) fails with ComponentLookupError

Uli Fouquet uli at gnufix.de
Tue Nov 15 12:57:43 UTC 2011


Hi there,

Somehow Alex postings to the list seem to get lost on their way to my
mailbox. Is there something I can do (no, the mails didn't go to the
spam folder)? I only noticed he posted by seeing the replies and looking
into the web-archive.

Am Dienstag, den 15.11.2011, 10:59 +0100 schrieb Sylvain Viollon:
> Hello,
> 
> Op 14 nov 2011, om 22:57 heeft Àlex Magaz Graça het volgende geschreven:
> 
> > Hi! I finally got it right. The problem was in the following snipped:
> > 
> >> [...]
> >> class Helpdesk(grok.Application, grok.Container):
> >>    def __init__(self):
> >>        super(Helpdesk, self).__init__()
> >>        self.ticketCatalog = TicketCatalog()
> >> 
> > 
> > Adding the TicketCatalog object to the Helpdesk container like below 
> > solved the problem:
> > 
> > def __init__(self):
> >         super(Helpdesk, self).__init__()
> >         self.ticketCatalog = TicketCatalog()
> 
>    This set the catalog as an attribute of your folder class. No events happens.
> Nothing happens, except the catalog is pickled in the database.
> 
> >         self["ticketCatalog"] = self.ticketCatalog
> > 
> 
>    This set the catalog as an element in your folder item. Added events are triggered,
> that probably initialize the catalog itself.

Yep, that might be true and this difference is important to remember:
adding items to a container triggers IObjectAddedEvent while setting
attributes of a container does not (at least not automatically).

I nevertheless do not understand, why the catalog is not created
automatically.

Normally, your catalog should be created automatically when you create a
HelpDesk instance and store it into ZODB (as a container item). But that
requires the ComponentArchitecture to be in place and a ZODB to store
the instance in.

Best regards,

-- 
Uli

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20111115/ffd53754/attachment.bin 


More information about the Grok-dev mailing list