[Grok-dev] Question about initialing grok.GlobalUtility with data from application containers

rmoskal rmoskal at mostmedia.com
Mon Sep 15 09:36:08 EDT 2008


You are right Martin, I can just call the application object, and traverse my
content objects.  duh.

Thanks,

Rob

Martijn Faassen-2 wrote:
> 
> rmoskal wrote:
>> The only way I can think to get this done is to actually pass the
>> articles/placements context  to the method where I test the validity of a
>> placement.  I can set a flag to indicate if the GlobalUtility has been
>> intialized, and load up the existing data exactly once.  This seems
>> unsatisfying.  Can anyone suggest a more elegant way?
>> 
>> It seems like a common use case.
> 
> I'm still trying to understand the use case. Could you perhaps give an 
> example of a business rule you want to enforce?
> 
> I'm just going to list random ideas that come to mind in the hopes that 
> one works as an answer to you question:
> 
> * you can do grok.getSite() within the global utility code to get the 
> site object; you might be able to traverse to your content that way, 
> say: grok.getSite()['placements'] to get to your placements container.
> 
> * you could catalog your content objects and do a query in the global 
> utility.
> 
> * you could instead of a global utility perhaps get away with doing this 
> in an IObjectAddedEvent handler.
> 
> * it is, I believe, also possible to register a placements containerr as 
> a local utility directly, though this will need to be done through the 
> API - I don't think Grok will help much here. You could then define the 
> business rules on the placements container and just look it up using 
> component.getUtility()
> 
> Regards,
> 
> Martijn
> 
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev
> 
> 

-- 
View this message in context: http://www.nabble.com/Question-about-initialing-grok.GlobalUtility-with-data-from-application-containers-tp19485498p19493107.html
Sent from the Grok mailing list archive at Nabble.com.



More information about the Grok-dev mailing list