Commit c4f758de authored by Shane Hathaway's avatar Shane Hathaway

Moved the absolute_url() method to Traversable.

parent df3dbe39
...@@ -89,8 +89,8 @@ Aqueduct database adapters, etc. ...@@ -89,8 +89,8 @@ Aqueduct database adapters, etc.
This module can also be used as a simple template for implementing new This module can also be used as a simple template for implementing new
item types. item types.
$Id: SimpleItem.py,v 1.77 2000/06/12 19:36:37 shane Exp $''' $Id: SimpleItem.py,v 1.78 2000/06/12 19:49:48 shane Exp $'''
__version__='$Revision: 1.77 $'[11:-2] __version__='$Revision: 1.78 $'[11:-2]
import regex, sys, Globals, App.Management, Acquisition, App.Undo import regex, sys, Globals, App.Management, Acquisition, App.Undo
import AccessControl.Role, AccessControl.Owned, App.Common import AccessControl.Role, AccessControl.Owned, App.Common
...@@ -101,7 +101,6 @@ from CopySupport import CopySource ...@@ -101,7 +101,6 @@ from CopySupport import CopySource
from string import join, lower, find, split from string import join, lower, find, split
from types import InstanceType, StringType from types import InstanceType, StringType
from ComputedAttribute import ComputedAttribute from ComputedAttribute import ComputedAttribute
from urllib import quote
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from Traversable import Traversable from Traversable import Traversable
...@@ -334,21 +333,6 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -334,21 +333,6 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
def __len__(self): def __len__(self):
return 1 return 1
def absolute_url(self, relative=0):
req = self.REQUEST
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:])
if relative: # Deprecated - use getPhysicalPath
return join(path, '/')
return join([req['SERVER_URL']] + req._script + path, '/')
Globals.default__class_init__(Item) Globals.default__class_init__(Item)
...@@ -370,22 +354,6 @@ class Item_w__name__(Item): ...@@ -370,22 +354,6 @@ class Item_w__name__(Item):
def _setId(self, id): def _setId(self, id):
self.__name__=id self.__name__=id
def absolute_url(self, relative=0):
req = self.REQUEST
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:])
if relative:
# This is useful for physical path relative to a VirtualRoot
return join(path, '/')
return join([req['SERVER_URL']] + req._script + path, '/')
def getPhysicalPath(self): def getPhysicalPath(self):
'''Returns a path (an immutable sequence of strings) '''Returns a path (an immutable sequence of strings)
that can be used to access this object again that can be used to access this object again
......
...@@ -84,19 +84,36 @@ ...@@ -84,19 +84,36 @@
############################################################################## ##############################################################################
'''This module implements a mix-in for traversable objects. '''This module implements a mix-in for traversable objects.
$Id: Traversable.py,v 1.1 2000/06/12 19:36:37 shane Exp $''' $Id: Traversable.py,v 1.2 2000/06/12 19:49:48 shane Exp $'''
__version__='$Revision: 1.1 $'[11:-2] __version__='$Revision: 1.2 $'[11:-2]
import Acquisition import Acquisition
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from string import split from string import split, join
from urllib import quote
_marker=[] _marker=[]
StringType=type('') StringType=type('')
class Traversable: class Traversable:
def absolute_url(self, relative=0):
req = self.REQUEST
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:])
if relative:
# This is useful for physical path relative to a VirtualRoot
return join(path, '/')
return join([req['SERVER_URL']] + req._script + path, '/')
getPhysicalRoot=Acquisition.Acquired getPhysicalRoot=Acquisition.Acquired
getPhysicalRoot__roles__=() getPhysicalRoot__roles__=()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment