Tres Seaver wrote:
Hash: SHA1

Johan Carlsson wrote:

No lock on the Zope3-users list I turn here.

How do I get a page template resource object define in a named layer
from Python code?

Look at what the handler for the <browser:resource> directive does:

Thanks Tres,
Already done that. It registers the resource as an adapter on the global site manger. Problem is I can't get the adapter, but gets an error. The registration is somewhat strange in it self (adapts from layer interface to Interface interface???).

I cut and paste my post from the Zope3-users list:

Ok, so far I figured out the following:

1. Resources gets registered as adapters in the Global Site Manager.
2. The adapter is registerd to adapt from the current layer interface (defaults to IDefaultBrowserLayer) to the Interface interface (strange, why is that so I wounder?) 3. The layer interface I can look up byt calling: zapi.getUtility(ILayer, 'my_layer')

Ok, fine. So from my View class I try the following:

        layer = zapi.getUtility(ILayer, 'my_test')
        adapter=gsm.queryAdapter(layer, Interface, 'test_me.html')

But this doesn't work, I get the following error:

Error type: exceptions.KeyError
Error object: <weakref at 02545900; to 'Surrogate' at 0210CAF0>

File "C:\Python24\Lib\site-packages\zope\publisher\", line 138, in publish

File "C:\Python24\Lib\site-packages\zope\app\publication\", line 164, in callObject

File "C:\Python24\Lib\site-packages\zope\publisher\", line 113, in mapply

File "C:\Python24\Lib\site-packages\zope\publisher\", line 119, in debug_call

File "C:\Zope\Zope31\lib\python\wfc\browser\", line 44, in __call__
    adapter=gsm.queryAdapter(layer, Interface, 'test_me.html')

File "C:\Python24\Lib\site-packages\zope\component\", line 70, in queryAdapter
    """Set all module' __file__ attribute to an absolute path"""

File "C:\Zope\Zope31\lib\python\zope\interface\", line 414, in queryAdapter
    return self.adapter_hook(interface, object, name, default)

File "C:\Zope\Zope31\lib\python\zope\interface\", line 404, in adapter_hook
    factory = self.lookup1(providedBy(object), interface, name)

File "C:\Zope\Zope31\lib\python\zope\interface\", line 392, in lookup1
    return self.lookup((required,), provided, name, default)

File "C:\Zope\Zope31\lib\python\zope\interface\", line 327, in lookup
    byname = s.get(provided)

File "C:\Zope\Zope31\lib\python\zope\interface\", line 227, in get

File "C:\Zope\Zope31\lib\python\zope\interface\", line 146, in clean

File "C:\Zope\Zope31\lib\python\zope\interface\", line 248, in unsubscribe
    del self.dependents[dependent]

File "C:\Python24\lib\", line 216, in __delitem__

Can somebody sched a light on this problem?


Johan Carlsson          Tel: + 46 8 31 24 94
Colliberty              Mob: + 46 70 558 25 24
Torsgatan 72            Email: [EMAIL PROTECTED]

Zope3-dev mailing list

Reply via email to