[Zope-Checkins] CVS: Zope2 - BaseRequest.py:1.39.8.1
shane@digicool.com
shane@digicool.com
Fri, 29 Jun 2001 13:51:11 -0400 (EDT)
Update of /cvs-repository/Zope2/lib/python/ZPublisher
In directory korak.digicool.com:/tmp/cvs-serv23594
Modified Files:
Tag: NR-branch
BaseRequest.py
Log Message:
Added support for __browser_default__.
--- Updated File BaseRequest.py in package Zope2 --
--- BaseRequest.py 2001/05/16 15:19:20 1.39
+++ BaseRequest.py 2001/06/29 17:51:11 1.39.8.1
@@ -259,6 +259,7 @@
method=req_method=upper(request_get('REQUEST_METHOD', 'GET'))
no_acquire_flag=0
+ checked_default = 0
# Set the default method
if method=='GET' or method=='POST':
@@ -312,19 +313,33 @@
# Check for method:
if path:
entry_name = path.pop()
- elif (method and hasattr(object,method)
- and entry_name != method
- and getattr(object, method) is not None):
- request._hacked_path=1
- entry_name = method
else:
- if (hasattr(object, '__call__') and
- hasattr(object.__call__,'__roles__')):
- roles=object.__call__.__roles__
- if request._hacked_path:
- i=rfind(URL,'/')
- if i > 0: response.setBase(URL[:i])
- break
+ # Finished the URL. Now publish a default view.
+ psteps = None
+ if not checked_default:
+ checked_default = 1
+ default = getattr(object, '__browser_default__', None)
+ if default is not None:
+ object, psteps = default(request)
+ if psteps:
+ request._hacked_path=1
+ entry_name = psteps[0]
+ path.extend(psteps[1:])
+ method = None # Don't hack the path again.
+ if not psteps:
+ if (method and hasattr(object,method)
+ and entry_name != method
+ and getattr(object, method) is not None):
+ request._hacked_path=1
+ entry_name = method
+ else:
+ if (hasattr(object, '__call__') and
+ hasattr(object.__call__,'__roles__')):
+ roles=object.__call__.__roles__
+ if request._hacked_path:
+ i=rfind(URL,'/')
+ if i > 0: response.setBase(URL[:i])
+ break
if not entry_name: continue
step = quote(entry_name)
_steps.append(step)