[Zope-Checkins] CVS: Zope/lib/python/OFS - Application.py:1.191.2.1 DTMLDocument.py:1.48.68.2 DTMLMethod.py:1.80.44.2 Image.py:1.145.2.2 Traversable.py:1.19.4.1
Chris McDonough
chrism@zope.com
Mon, 21 Jul 2003 12:39:12 -0400
Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv17213/lib/python/OFS
Modified Files:
Tag: Zope-2_7-branch
Application.py DTMLDocument.py DTMLMethod.py Image.py
Traversable.py
Log Message:
Merge changes from HEAD since the release of Zope 2.7a1 into the Zope-2_7-branch in preparation for release of Zope 2.7b1.
=== Zope/lib/python/OFS/Application.py 1.191 => 1.191.2.1 ===
--- Zope/lib/python/OFS/Application.py:1.191 Tue Jun 24 09:30:29 2003
+++ Zope/lib/python/OFS/Application.py Mon Jul 21 12:35:34 2003
@@ -135,11 +135,21 @@
test_url=ZopeAttributionButton
def absolute_url(self, relative=0):
- """Return an absolute url to the object. Note that the url
- will reflect the acquisition path of the object if the object
- has been acquired."""
- if relative: return ''
- return self.aq_acquire('REQUEST')['BASE1']
+ '''Return a canonical URL for this object based on its
+ physical containment path, possibly modified by virtual hosting.
+ If the optional 'relative' argument is true, only return the
+ path portion of the URL.'''
+ try:
+ # We need a REQUEST that uses physicalPathToURL to create
+ # BASE1 and BASEPATH1, so probe for it.
+ req = self.REQUEST
+ req.physicalPathToURL
+ except AttributeError:
+ return ''
+ # Take advantage of computed URL cache
+ if relative:
+ return req['BASEPATH1'][1:]
+ return req['BASE1']
def getPhysicalPath(self):
'''Returns a path that can be used to access this object again
@@ -270,17 +280,19 @@
# Ensure that a temp folder exists
if not hasattr(app, 'temp_folder'):
- from Products.TemporaryFolder.TemporaryFolder import \
- MountedTemporaryFolder
- tf = MountedTemporaryFolder('temp_folder','Temporary Folder')
- app._setObject('temp_folder', tf)
- get_transaction().note('Added temp_folder')
- get_transaction().commit()
- del tf
+ from Products.ZODBMountPoint.MountedObject import manage_addMounts
+ try:
+ manage_addMounts(app, ('/temp_folder',))
+ get_transaction().note('Added temp_folder')
+ get_transaction().commit()
+ except:
+ LOG('Zope Default Object Creation', ERROR,
+ 'Could not add a /temp_folder mount point due to an error.',
+ error=sys.exc_info())
# Ensure that there is a transient container in the temp folder
- tf = app.temp_folder
- if not hasattr(aq_base(tf), 'session_data'):
+ tf = getattr(app, 'temp_folder', None)
+ if tf is not None and not hasattr(aq_base(tf), 'session_data'):
env_has = os.environ.get
from Products.Transience.Transience import TransientObjectContainer
addnotify = env_has('ZSESSION_ADD_NOTIFY', None)
=== Zope/lib/python/OFS/DTMLDocument.py 1.48.68.1 => 1.48.68.2 ===
--- Zope/lib/python/OFS/DTMLDocument.py:1.48.68.1 Sun Jul 6 06:47:22 2003
+++ Zope/lib/python/OFS/DTMLDocument.py Mon Jul 21 12:35:34 2003
@@ -26,6 +26,7 @@
from urllib import quote
import Globals
from AccessControl import getSecurityManager
+from zExceptions.TracebackSupplement import PathTracebackSupplement
done='done'
@@ -109,6 +110,7 @@
# Return cached results.
return data
+ __traceback_supplement__ = (PathTracebackSupplement, self)
kw['document_id'] =self.getId()
kw['document_title']=self.title
if hasattr(self, 'aq_explicit'):
=== Zope/lib/python/OFS/DTMLMethod.py 1.80.44.1 => 1.80.44.2 ===
--- Zope/lib/python/OFS/DTMLMethod.py:1.80.44.1 Sun Jul 6 06:47:22 2003
+++ Zope/lib/python/OFS/DTMLMethod.py Mon Jul 21 12:35:34 2003
@@ -30,6 +30,7 @@
from AccessControl import getSecurityManager
from AccessControl.DTML import RestrictedDTML
from Cache import Cacheable
+from zExceptions.TracebackSupplement import PathTracebackSupplement
_marker = [] # Create a new marker object.
@@ -102,6 +103,7 @@
# Return cached results.
return data
+ __traceback_supplement__ = (PathTracebackSupplement, self)
kw['document_id'] =self.getId()
kw['document_title']=self.title
=== Zope/lib/python/OFS/Image.py 1.145.2.1 => 1.145.2.2 ===
--- Zope/lib/python/OFS/Image.py:1.145.2.1 Sun Jul 6 08:09:58 2003
+++ Zope/lib/python/OFS/Image.py Mon Jul 21 12:35:34 2003
@@ -375,8 +375,8 @@
self.ZCacheable_set(None)
data=self.data
- if type(data) is type(''):
- RESPONSE.setBase(None)
+ if type(data) is type(''):
+ RESPONSE.setBase(None)
return data
while data is not None:
=== Zope/lib/python/OFS/Traversable.py 1.19 => 1.19.4.1 ===
--- Zope/lib/python/OFS/Traversable.py:1.19 Thu Apr 17 13:46:57 2003
+++ Zope/lib/python/OFS/Traversable.py Mon Jul 21 12:35:34 2003
@@ -30,23 +30,19 @@
absolute_url__roles__=None # Public
def absolute_url(self, relative=0):
+ '''Return a canonical URL for this object based on its
+ physical containment path, possibly modified by virtual hosting.
+ If the optional 'relative' argument is true, only return the
+ path portion of the URL.'''
+ spp = self.getPhysicalPath()
try:
- req = self.REQUEST
+ toUrl = self.REQUEST.physicalPathToURL
except AttributeError:
- req = {}
- rpp = req.get('VirtualRootPhysicalPath', ('',))
- spp = self.getPhysicalPath()
- i = 0
- for name in rpp[:len(spp)]:
- if spp[i] == name:
- i = i + 1
- else:
- break
- path = map(quote, spp[i:])
+ return '/'.join(map(quote, spp[1:]))
if relative:
- # This is useful for physical path relative to a VirtualRoot
- return '/'.join(path)
- return '/'.join([req['SERVER_URL']] + req._script + path)
+ # Remove leading slash for backward compatibility sake.
+ return toUrl(spp, relative)[1:]
+ return toUrl(spp)
getPhysicalRoot__roles__=() # Private
getPhysicalRoot=Acquired