AbsoluteURL inconsistent between adapter and view
Bug #747086 reported by
Wolfgang Schnerring
This bug affects 3 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
zope.traversing |
Invalid
|
Undecided
|
Unassigned |
Bug Description
AbsoluteURL can be accessed in two ways, as an adapter from (context, request) to IAbsoluteURL, and as a view, i.e. an adapter from (context, request) to Interface, with the name 'absolute_url'.
zope.traversing's default implementation implements this duality by registering the same class twice -- and not by delegating one access path to the other. This means that if you want to override AbsoluteURL, you have to override both access paths, too, which feels conceptually broken to me, and creates superfluous busywork.
To post a comment you must log in.
+1
It would save many many lines of zcml.
I'd prefer to make the view delegate to the IAbsoluteURL adapter. In my projects I always override the default view with this class to do it:
class AbsoluteURLView (object) :
"""An absoluteURL view that delegates to the IAbsoluteURL multi-adapter"""
def __init__(self, context, request):
self.context = context
self.request = request
@property ((self. context, self.request), IAbsoluteURL)
def _url(self):
return getMultiAdapter
def __unicode__(self): __unicode_ _()
return self._url.
def __str__(self):
return self._url.__str__()
def __call__(self):
return self._url()