[Zope3-checkins] CVS: Zope3/src/zope/app/browser -
absoluteurl.py:1.16
Jim Fulton
jim at zope.com
Sun Sep 21 13:30:19 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/browser
In directory cvs.zope.org:/tmp/cvs-serv11963/src/zope/app/browser
Modified Files:
absoluteurl.py
Log Message:
Changed to use ILocation rather than context wrappers.
=== Zope3/src/zope/app/browser/absoluteurl.py 1.15 => 1.16 ===
--- Zope3/src/zope/app/browser/absoluteurl.py:1.15 Wed Sep 3 14:33:55 2003
+++ Zope3/src/zope/app/browser/absoluteurl.py Sun Sep 21 13:30:19 2003
@@ -23,8 +23,8 @@
from zope.app.i18n import ZopeMessageIDFactory as _
_insufficientContext = _("There isn't enough context to get URL information. "
- "This is probably due to a bug in setting up context "
- "wrappers.")
+ "This is probably due to a bug in setting up location "
+ "information.")
class AbsoluteURL(BrowserView):
@@ -33,20 +33,18 @@
context = self.context
request = self.request
- # We do this here do maintain the rule that we must be wrapped
- container = zapi.getWrapperContainer(context)
- if container is None:
- raise TypeError, _insufficientContext
-
+
if sameProxiedObjects(context, request.getVirtualHostRoot()):
return request.getApplicationURL()
+ container = getattr(context, '__parent__', None)
+ if container is None:
+ raise TypeError, _insufficientContext
+
url = str(zapi.getView(container, 'absolute_url', request))
- dict = zapi.getInnerWrapperData(context)
- try:
- name = dict['name']
- except KeyError:
+ name = getattr(context, '__name__', None)
+ if name is None:
raise TypeError, _insufficientContext
if name:
@@ -61,7 +59,7 @@
request = self.request
# We do this here do maintain the rule that we must be wrapped
- container = zapi.getWrapperContainer(context)
+ container = getattr(context, '__parent__', None)
if container is None:
raise TypeError, _insufficientContext
@@ -72,10 +70,8 @@
base = tuple(zapi.getView(container,
'absolute_url', request).breadcrumbs())
- dict = zapi.getInnerWrapperData(context)
- try:
- name = dict['name']
- except KeyError:
+ name = getattr(context, '__name__', None)
+ if name is None:
raise TypeError, _insufficientContext
if name:
@@ -96,12 +92,10 @@
url = request.getApplicationURL()
- dict = zapi.getInnerWrapperData(context)
- if dict:
- name = dict.get('name')
- if name:
- url += '/'+name
-
+ name = getattr(context, '__name__', None)
+ if name:
+ url += '/'+name
+
return url
__call__ = __str__
@@ -116,14 +110,10 @@
base = ({'name':'', 'url': self.request.getApplicationURL()}, )
- dict = zapi.getInnerWrapperData(context)
- if dict:
- name = dict.get('name')
-
- if name:
- base += ({'name': name,
- 'url': ("%s/%s" % (base[-1]['url'], name))
- }, )
-
-
+ name = getattr(context, '__name__', None)
+ if name:
+ base += ({'name': name,
+ 'url': ("%s/%s" % (base[-1]['url'], name))
+ }, )
+
return base
More information about the Zope3-Checkins
mailing list