[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication - PublicationTraverse.py:1.1.2.19 Traversers.py:1.1.2.19 ZopePublication.py:1.1.2.40 zopepublication.zcml:1.1.2.6
Jim Fulton
jim@zope.com
Fri, 7 Jun 2002 10:41:51 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication
In directory cvs.zope.org:/tmp/cvs-serv12187/lib/python/Zope/App/ZopePublication
Modified Files:
Tag: Zope-3x-branch
PublicationTraverse.py Traversers.py ZopePublication.py
zopepublication.zcml
Log Message:
Merging in Zope3InWonderland-branch, which implemented the following
proposals (see
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/OldProposals):
- RenameAllowToRequire
- GroupClassRelatedDirectivesInClassDirective
- ViewInterfaceAndSimplification
- ConsistentUseOfSpacesAsDelimitersInZCMLAttributes
- TwoArgumentViewConstructors
- ImplementsInZCML
- SimpleViewCreationInZCML
- RemoveGetView
- ReplaceProtectWithAllow
- ViewMethodsAsViews
- MergeProtectionAndComponentDefinitions
There were also various security fixes resulting of better integration
of security with components.
=== Zope3/lib/python/Zope/App/ZopePublication/PublicationTraverse.py 1.1.2.18 => 1.1.2.19 ===
"""
-from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
-from Zope.ComponentArchitecture import getRequestView, getService
+from Zope.ComponentArchitecture import queryView, getService
from Zope.Publisher.Exceptions import NotFound
from types import StringTypes
from Zope.Proxy.ContextWrapper import ContextWrapper, getWrapperContext
@@ -28,6 +27,7 @@
from Zope.Proxy.ProxyIntrospection import removeAllProxies
from Zope.App.Traversing.Namespaces import namespaceLookup
from Zope.App.Traversing.ParameterParsing import parameterizedNameParse
+from Zope.Publisher.IPublishTraverse import IPublishTraverse
class DuplicateNamespaces(Exception):
"""More than one namespace was specified in a request"""
@@ -41,7 +41,7 @@
nm = name # the name to look up the object with
- if name.find(';') >= 0:
+ if ':' in name or ';' in name:
# Process URI segment parameters.
ns, nm, parms = parameterizedNameParse(name)
@@ -74,10 +74,10 @@
if nm == '.':
return ob
- if request.getViewType().isImplementedBy(removeAllProxies(ob)):
+ if IPublishTraverse.isImplementedBy(removeAllProxies(ob)):
ob2 = ob.publishTraverse(request, nm)
else:
- adapter = getRequestView(ob, '_traverse', request, self # marker
+ adapter = queryView(ob, '_traverse', request, self # marker
)
if adapter is not self:
=== Zope3/lib/python/Zope/App/ZopePublication/Traversers.py 1.1.2.18 => 1.1.2.19 ===
from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
from Zope.ComponentArchitecture \
- import getRequestView, getRequestDefaultViewName
+ import getView, getDefaultViewName
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
class SimpleComponentTraverser:
@@ -22,37 +22,38 @@
"""
__implements__ = IBrowserPublisher
- def __init__(self, target):
+ def __init__(self, target, request):
self.target = target
def browserDefault(self, request):
ob = self.target
- view_name = getRequestDefaultViewName(ob, request)
+ view_name = getDefaultViewName(ob, request)
return ob, (view_name,)
def publishTraverse(self, request, name):
ob = self.target
try:
- return getRequestView(ob, name, request)
+ return getView(ob, name, request)
except ComponentLookupError:
raise NotFound(ob, name)
-class HTMLContentTraverser(SimpleComponentTraverser):
- """Browser traverser for HTML content.
+class FileContentTraverser(SimpleComponentTraverser):
+ """Browser traverser for file content.
+
+ The default view for file content has effective URLs that don't end in
+ /. In particular, if the content inclused HTML, relative links in
+ the HTML are relative to the container the content is in.
- HTML content is content that authors expect to be used like simple
- HTML pages. In particular, for the default view, URLs should be
- relative to the container containing the content.
"""
def browserDefault(self, request):
ob = self.target
- view_name = getRequestDefaultViewName(ob, request)
+ view_name = getDefaultViewName(ob, request)
view = self.publishTraverse(request, view_name)
if hasattr(view, 'browserDefault'):
view, path = view.browserDefault(request)
@@ -69,7 +70,7 @@
__implements__ = IBrowserPublisher
- def __init__(self, target):
+ def __init__(self, target, request):
self.target = target
def browserDefault(self, request):
@@ -77,16 +78,16 @@
if hasattr(ob, '__implements__'):
- view_name = getRequestDefaultViewName(ob, request)
+ view_name = getDefaultViewName(ob, request)
- return ob, (("%s;view" % view_name),)
+ return ob, (("view::%s" % view_name),)
return ob, ()
def publishTraverse(self, request, name):
ob = self.target
- if name.endswith(';view'):
- return getRequestView( ob, name[:-5], request)
+ if name.startswith('view::'):
+ return getView(ob, name[6:], request)
if name.startswith('_'):
raise Unauthorized("Name %s begins with an underscore" % `name`)
=== Zope3/lib/python/Zope/App/ZopePublication/ZopePublication.py 1.1.2.39 => 1.1.2.40 ===
from zLOG import LOG, ERROR, INFO
-from Zope.ComponentArchitecture import getRequestView
from Zope.Publisher.DefaultPublication import DefaultPublication
from Zope.Publisher.mapply import mapply
from Zope.Publisher.Exceptions import Retry
@@ -75,17 +74,17 @@
def getApplication(self, request):
- # If the first name is 'ApplicationControl;etc', then we should
+ # If the first name is 'etc::ApplicationControl', then we should
# get it rather than look in the database!
stack = request.getTraversalStack()
if stack:
name = stack[-1]
- if name.startswith('ApplicationController;'):
- parms = name.split(';')
- if 'etc' in parms or 'ns=etc' in parms:
- stack.pop() # consume the name
- request.setTraversalStack(stack) # Reset the stack
- return self.traverseName(request, None, name)
+ if (name.startswith('etc::ApplicationController') and
+ (name == 'etc::ApplicationController' or
+ name.startswith('etc::ApplicationController;'))):
+ stack.pop() # consume the name
+ request.setTraversalStack(stack) # Reset the stack
+ return self.traverseName(request, None, name)
# Open the database.
version = request.get(self.version_cookie, '')
=== Zope3/lib/python/Zope/App/ZopePublication/zopepublication.zcml 1.1.2.5 => 1.1.2.6 ===
<browser:view name="_traverse"
- for="Zope.App.OFS.Content.IHTMLContent."
- factory="Zope.App.ZopePublication.Traversers.HTMLContentTraverser" />
+ for="Zope.App.OFS.Content.IFileContent."
+ factory="Zope.App.ZopePublication.Traversers.FileContentTraverser" />
<xmlrpc:view name="_traverse"
for="Interface.Interface"