[Zope3-checkins] CVS: Zope3/src/zope/app/browser - absoluteurl.py:1.5.12.1 introspector.py:1.3.12.1 managementviewselector.py:1.2.28.1 menu.py:1.2.28.1 menus.zcml:1.6.12.1 onlinehelp.py:1.3.12.1 traversal.zcml:1.4.16.1 undo.py:1.3.26.1 objectname.py:NONE
Grégoire Weber
zope@i-con.ch
Sun, 22 Jun 2003 10:24:07 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser
In directory cvs.zope.org:/tmp/cvs-serv24874/src/zope/app/browser
Modified Files:
Tag: cw-mail-branch
absoluteurl.py introspector.py managementviewselector.py
menu.py menus.zcml onlinehelp.py traversal.zcml undo.py
Removed Files:
Tag: cw-mail-branch
objectname.py
Log Message:
Synced up with HEAD
=== Zope3/src/zope/app/browser/absoluteurl.py 1.5 => 1.5.12.1 ===
--- Zope3/src/zope/app/browser/absoluteurl.py:1.5 Mon Apr 28 09:14:19 2003
+++ Zope3/src/zope/app/browser/absoluteurl.py Sun Jun 22 10:22:35 2003
@@ -16,95 +16,130 @@
Revision information:
$Id$
"""
+
+from zope.app import zapi
from zope.publisher.browser import BrowserView
-from zope.proxy.context import getWrapperContainer, getInnerWrapperData
-from zope.proxy.introspection import removeAllProxies
-from zope.component import getView
+from zope.proxy import sameProxiedObjects
+
+_insufficientContext = ("There isn't enough context to get URL information. "
+ "This is probably due to a bug in setting up context "
+ "wrappers.")
-class AbsoluteURLBase(BrowserView):
+
+class AbsoluteURL(BrowserView):
def __str__(self):
context = self.context
- vh_root = removeAllProxies(self.request.getVirtualHostRoot())
- if removeAllProxies(context) is vh_root:
- return self.request.getApplicationURL()
- container = getWrapperContainer(context)
- container_url = str(getView(container, 'absolute_url',
- self.request))
- dict = getInnerWrapperData(context)
- name = dict and dict.get('name') or None
- if name == '.':
- name = dict.get('side_effect_name', name)
- if name.startswith('++vh++'):
- return container_url
- return "%s/%s" % (container_url, name)
+ 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()
+
+ url = str(zapi.getView(container, 'absolute_url', request))
+
+ dict = zapi.getInnerWrapperData(context)
+ try:
+ name = dict['name']
+ except KeyError:
+ raise TypeError, _insufficientContext
+
+ if name:
+ url += '/'+name
+
+ side_effect_names = dict.get('side_effect_names')
+ if side_effect_names:
+ url += _side_effects_url(side_effect_names)
+
+ return url
+
+ __call__ = __str__
def breadcrumbs(self):
context = self.context
- vh_root = removeAllProxies(self.request.getVirtualHostRoot())
- if removeAllProxies(context) is vh_root:
+ 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 ({'name':'', 'url': self.request.getApplicationURL()}, )
- dict = getInnerWrapperData(context)
- name = dict and dict.get('name') or None
- container = getWrapperContainer(context)
- base = getView(container, 'absolute_url', self.request).breadcrumbs()
-
- if name == '.':
- # The name is meaningless. There is a side-efect name
- # that we need to preserve in the urls (only)
- name = dict.get('side_effect_name', name)
- if name.startswith('++vh++'):
- return base
-
- # replace the last step in base with a step with the same
- # name and an augmented url
- base = base[:-1] + (
- {'name': base[-1]['name'],
- 'url': ("%s/%s" % (base[-1]['url'], name))}, )
- return base
- base += ({'name': name, 'url': ("%s/%s" % (base[-1]['url'], name))}, )
- return base
+ base = zapi.getView(container, 'absolute_url', request).breadcrumbs()
+ dict = zapi.getInnerWrapperData(context)
+ try:
+ name = dict['name']
+ except KeyError:
+ raise TypeError, _insufficientContext
+
+ if name:
+ base += ({'name': name,
+ 'url': ("%s/%s" % (base[-1]['url'], name))
+ }, )
+
+ side_effect_names = dict.get('side_effect_names')
+ if side_effect_names:
+ base[-1]['url'] += _side_effects_url(side_effect_names)
-class AbsoluteURL(AbsoluteURLBase):
+ return base
- def __str__(self):
- dict = getInnerWrapperData(self.context)
- name = dict and dict.get('name') or None
- container = getWrapperContainer(self.context)
- if name is None or container is None:
- raise TypeError, 'Not enough context information to get a URL'
- return super(AbsoluteURL, self).__str__()
+def _side_effects_url(side_effect_names):
+ return "/"+"/".join([name
+ for name in side_effect_names
+ if not name.startswith("++vh++")])
- __call__ = __str__
+class SiteAbsoluteURL(BrowserView):
- def breadcrumbs(self):
+ def __str__(self):
context = self.context
- dict = getInnerWrapperData(context)
- name = dict and dict.get('name') or None
- container = getWrapperContainer(context)
- if name is None or container is None:
- raise TypeError, 'Not enough context information to get a URL'
+ request = self.request
- return super(AbsoluteURL, self).breadcrumbs()
+ if sameProxiedObjects(context, request.getVirtualHostRoot()):
+ return request.getApplicationURL()
+ url = request.getApplicationURL()
-class SiteAbsoluteURL(AbsoluteURLBase):
-
- def __str__(self):
- dict = getInnerWrapperData(self.context)
- name = dict and dict.get('name') or None
- if name:
- return super(SiteAbsoluteURL, self).__str__()
- return self.request.getApplicationURL()
+ dict = zapi.getInnerWrapperData(context)
+ if dict:
+ name = dict.get('name')
+ if name:
+ url += '/'+name
+ side_effect_names = dict.get('side_effect_names')
+ if side_effect_names:
+ url += _side_effects_url(side_effect_names)
+
+ return url
__call__ = __str__
def breadcrumbs(self):
context = self.context
- dict = getInnerWrapperData(context)
- name = dict and dict.get('name') or None
- if name:
- return super(SiteAbsoluteURL, self).breadcrumbs()
- return ({'name':'', 'url': self.request.getApplicationURL()}, )
+ request = self.request
+
+ if sameProxiedObjects(context, request.getVirtualHostRoot()):
+ return ({'name':'', 'url': self.request.getApplicationURL()}, )
+
+ 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))
+ }, )
+
+ side_effect_names = dict.get('side_effect_names')
+ if side_effect_names:
+ base[-1]['url'] += _side_effects_url(side_effect_names)
+
+ return base
=== Zope3/src/zope/app/browser/introspector.py 1.3 => 1.3.12.1 ===
--- Zope3/src/zope/app/browser/introspector.py:1.3 Wed Apr 30 19:37:48 2003
+++ Zope3/src/zope/app/browser/introspector.py Sun Jun 22 10:22:35 2003
@@ -39,7 +39,7 @@
# # XXX IConfigureFor appears to have disappeared at some point
# adapter = queryAdapter(service, IConfigureFor)
# if (adapter is not None
- # and adapter.hasConfigurationFor(self.context)):
+ # and adapter.hasRegistrationFor(self.context)):
# search_result = service.getRegisteredMatching(
# self.context, None, [], self.context)
# directive_path = []
=== Zope3/src/zope/app/browser/managementviewselector.py 1.2 => 1.2.28.1 ===
--- Zope3/src/zope/app/browser/managementviewselector.py:1.2 Wed Dec 25 09:12:26 2002
+++ Zope3/src/zope/app/browser/managementviewselector.py Sun Jun 22 10:22:35 2003
@@ -17,6 +17,7 @@
__metaclass__ = type
+from zope.interface import implements
from zope.component import getService
from zope.publisher.browser import BrowserView
from zope.publisher.interfaces.browser import IBrowserPublisher
@@ -25,7 +26,7 @@
"""View that selects the first available management view
"""
- __implements__ = BrowserView.__implements__, IBrowserPublisher
+ implements(IBrowserPublisher)
def browserDefault(self, request):
return self, ()
=== Zope3/src/zope/app/browser/menu.py 1.2 => 1.2.28.1 ===
--- Zope3/src/zope/app/browser/menu.py:1.2 Wed Dec 25 09:12:26 2002
+++ Zope3/src/zope/app/browser/menu.py Sun Jun 22 10:22:35 2003
@@ -15,6 +15,7 @@
$Id$
"""
+from zope.interface import implements
from zope.publisher.browser import BrowserView
from zope.app.interfaces.browser.menu import IMenuAccessView
from zope.component import getService
@@ -22,7 +23,7 @@
class MenuAccessView(BrowserView):
__doc__ = IMenuAccessView.__doc__
- __implements__ = BrowserView.__implements__, IMenuAccessView
+ implements(IMenuAccessView)
def __getitem__(self, menu_id):
context = self.context
=== Zope3/src/zope/app/browser/menus.zcml 1.6 => 1.6.12.1 ===
--- Zope3/src/zope/app/browser/menus.zcml:1.6 Mon Apr 28 17:35:28 2003
+++ Zope3/src/zope/app/browser/menus.zcml Sun Jun 22 10:22:35 2003
@@ -40,7 +40,7 @@
usage="addingdialog"
/>
- <menu id="add_configuration"
+ <menu id="add_registration"
title="Menu of addable configuration objects"
usage="addingdialog"
/>
=== Zope3/src/zope/app/browser/onlinehelp.py 1.3 => 1.3.12.1 ===
--- Zope3/src/zope/app/browser/onlinehelp.py:1.3 Wed Apr 30 19:37:48 2003
+++ Zope3/src/zope/app/browser/onlinehelp.py Sun Jun 22 10:22:35 2003
@@ -15,14 +15,14 @@
$Id$
"""
-from zope.interface.implements import flattenInterfaces
+from zope.interface import providedBy
from zope.component import getService, getView
from zope.publisher.browser import BrowserView
from zope.app.traversing import getRoot
-from zope.proxy.context import ContextWrapper
-from zope.app.traversing import getParents, objectName
-from zope.proxy.introspection import removeAllProxies
+from zope.app.context import ContextWrapper
+from zope.app.traversing import getParents, getName
+from zope.proxy import removeAllProxies
class OnlineHelpTopicView(BrowserView):
@@ -57,13 +57,13 @@
view = self.context
obj = view.context
help = getService(obj, 'OnlineHelp')
- ifaces = flattenInterfaces(removeAllProxies(obj.__implements__))
+ ifaces = providedBy(obj).flattened()
topics = []
for klass in view.__class__.__bases__ + (view.__class__, None):
for iface in ifaces:
for topic in help.getTopicsForInterfaceAndView(iface, klass):
parents = getParents(topic)
- path = map(objectName, parents[:-1]+[topic])
+ path = map(getName, parents[:-1]+[topic])
url = getView(obj, 'absolute_url', self.request)()
url += '/++help++/'+'/'.join(path)
topics.append(FindResult(url, topic))
=== Zope3/src/zope/app/browser/traversal.zcml 1.4 => 1.4.16.1 ===
--- Zope3/src/zope/app/browser/traversal.zcml:1.4 Tue Mar 25 12:26:06 2003
+++ Zope3/src/zope/app/browser/traversal.zcml Sun Jun 22 10:22:35 2003
@@ -1,5 +1,5 @@
<zopeConfigure xmlns='http://namespaces.zope.org/zope'
- xmlns:browser='http://namespaces.zope.org/browser'>
+ xmlns:browser='http://namespaces.zope.org/browser'>
<browser:page
name="_traverse"
@@ -61,22 +61,6 @@
class=".absoluteurl.SiteAbsoluteURL"
permission="zope.Public"
allowed_interface="zope.app.interfaces.browser.absoluteurl.IAbsoluteURL"
- />
-
-<browser:page
- for="*"
- name="object_name"
- class=".objectname.ObjectNameView"
- permission="zope.Public"
- allowed_interface="zope.app.interfaces.traversing.IObjectName"
- />
-
-<browser:page
- for="zope.app.interfaces.content.folder.IRootFolder"
- name="object_name"
- class=".objectname.SiteObjectNameView"
- permission="zope.Public"
- allowed_interface="zope.app.interfaces.traversing.IObjectName"
/>
</zopeConfigure>
=== Zope3/src/zope/app/browser/undo.py 1.3 => 1.3.26.1 ===
--- Zope3/src/zope/app/browser/undo.py:1.3 Mon Jan 20 14:58:57 2003
+++ Zope3/src/zope/app/browser/undo.py Sun Jun 22 10:22:35 2003
@@ -16,6 +16,7 @@
Revision information:
$Id$
"""
+from zope.interface import implements
from zope.component import getUtility
from zope.publisher.browser import BrowserView
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
@@ -26,7 +27,7 @@
"""Implement the basic undo management api for a single ZODB database.
"""
- __implements__ = IUndoManager
+ implements(IUndoManager)
def __init__(self, db):
self.__db = db
=== Removed File Zope3/src/zope/app/browser/objectname.py ===