[Zope3-dev] Absolute URLs and Named vs. Unnamed Adapters

Bjorn Tillenius bjoti777 at student.liu.se
Wed Apr 20 12:12:04 EDT 2005


On Fri, Apr 15, 2005 at 03:26:41PM -0400, Brad Bollenbach wrote:

[snip explanation about having register the same component twice when
 adding a new absolute url view]

> I'm not intimately familiar with the internals of this code, but by
> the looks of it, behind the scenes of zapi.absoluteURL, a lookup is
> being done for an unnamed multi-adapter, and thus, naming my view
> "absolute_url" breaks that lookup. This means I need to include *both*
> ZCML snippets above for this functionality to work, i.e. I need to
> register both a named *and* an unnamed adapter for /@@absolute_url and
> zapi.absoluteURL to both work.
> 
> Would it be reasonable to improve the adapter lookup so that only one
> ZCML registration is required in this situation? Perhaps the adapter
> lookup should first try to find an adapter called absolute_url, and if
> no such adapter exists /then/ try to find an unnamed adapter providing
> IAbsoluteURL? Any other suggestions for approaches to make this Just
> Work whilst only requiring one registration in ZCML?

IMO, the problem lies in that we can't look up a view providing a
specific interface. I don't think that zapi.absoluteURL should be
changed to solve problems related to ZPT. Instead it would be better to
make the ZPT adapter look up a view providing IAbsoluteURL, and use
that to do its work. That way when defining a new IAbsoluteURL view,
we'd only have to register an unnamed view, and it'd be used both in
Python code and in ZPT.

Any objections against implementing this solution?

Regards,

Bjorn


More information about the Zope3-dev mailing list