[Zope3-dev] Creating a resource: Presentation service not available

Peter Mayne PeterMayne at ap.spherion.com
Tue Oct 5 21:26:17 EDT 2004


I've written a resource that provides a dynamic image capability, useful 
for presenting charts and so on. The catch is that I'm not sure 
where/when to register it.

The registration code I use is:

     factory = MyResourceFactory(...)
     gps = sm.getService(Presentation)
     gps.provideAdapter(IBrowserRequest, factory, name='my.png', 
layer='default')

If I run this code at the end of one of my class files, I get:

   File 
"/tmp/ZopeX3-3.0.0c2/build/lib.linux-i686-2.3/zope/component/service.py", 
line 109, in getService
    raise ComponentLookupError: 'Presentation'

presumably because the Presentation service isn't defined yet.

If I run this code as a side-effect of doing something else manually 
after Z3 has started, then everything works fine, but this isn't really 
acceptable.

How can I get my resource registration code to run after the 
Presentation service is available, and before Z3 has finished starting?

I'm not sure there are any guarantees as to what order things start up 
in, so I haven't tried implementing a custom ZCML directive, for 
instance: it may work today, but not in c3.

Thanks.

PJDM
-- 
Peter Mayne
Spherion Technology Solutions
Canberra, ACT, Australia
"You're given the form, but you have to write the sonnet yourself.
What you say is completely up to you." - Mrs. Whatsit



More information about the Zope3-dev mailing list