Commit 43f95443 authored by Shane Hathaway's avatar Shane Hathaway

Changed getPhysicalPath() and unrestrictedTraverse() to match new

interface specs.
parent 1891b8ff
...@@ -85,8 +85,8 @@ ...@@ -85,8 +85,8 @@
__doc__='''Application support __doc__='''Application support
$Id: Application.py,v 1.125 2000/05/24 20:53:34 shane Exp $''' $Id: Application.py,v 1.126 2000/05/31 15:58:11 shane Exp $'''
__version__='$Revision: 1.125 $'[11:-2] __version__='$Revision: 1.126 $'[11:-2]
import Globals,Folder,os,sys,App.Product, App.ProductRegistry, misc_ import Globals,Folder,os,sys,App.Product, App.ProductRegistry, misc_
import time, traceback, os, string, Products import time, traceback, os, string, Products
...@@ -289,7 +289,7 @@ class Application(Globals.ApplicationDefaultPermissions, ...@@ -289,7 +289,7 @@ class Application(Globals.ApplicationDefaultPermissions,
be used with getPhysicalRoot(). be used with getPhysicalRoot().
''' '''
# We're at the base of the path. # We're at the base of the path.
return '' return ('',)
def getPhysicalRoot(self): return self def getPhysicalRoot(self): return self
......
...@@ -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.72 2000/05/26 15:43:07 brian Exp $''' $Id: SimpleItem.py,v 1.73 2000/05/31 15:58:11 shane Exp $'''
__version__='$Revision: 1.72 $'[11:-2] __version__='$Revision: 1.73 $'[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,7 @@ from CopySupport import CopySource ...@@ -101,7 +101,7 @@ 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 urllib import quote, unquote
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
import marshal import marshal
...@@ -348,18 +348,18 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, ...@@ -348,18 +348,18 @@ class Item(Base, Resource, CopySource, App.Management.Tabs,
return id return id
def getPhysicalPath(self): def getPhysicalPath(self):
'''Returns a path that can be used to access this object again '''Returns a path (an immutable sequence of strings)
that can be used to access this object again
later, for example in a copy/paste operation. getPhysicalRoot() later, for example in a copy/paste operation. getPhysicalRoot()
and getPhysicalPath() are designed to operate together. and getPhysicalPath() are designed to operate together.
''' '''
id=quote(self.id) path = (self.id,)
p=getattr(self,'aq_inner', None) p = getattr(self,'aq_inner', None)
if p is not None: if p is not None:
url=p.aq_parent.getPhysicalPath() path = p.aq_parent.getPhysicalPath() + path
if url: id=url+'/'+id print path
return path
return id
unrestrictedTraverse__roles__=() unrestrictedTraverse__roles__=()
def unrestrictedTraverse(self, path, default=_marker): def unrestrictedTraverse(self, path, default=_marker):
...@@ -371,12 +371,18 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, ...@@ -371,12 +371,18 @@ class Item(Base, Resource, CopySource, App.Management.Tabs,
N=None N=None
M=_marker M=_marker
if type(path) is StringType: path=split(path,'/') if type(path) is StringType:
path = map(unquote, split(path,'/'))
else: path=list(path) else: path=list(path)
REQUEST={'path': path} REQUEST={'path': path}
path.reverse() path.reverse()
pop=path.pop pop=path.pop
# If the path starts with an empty string, go to the root first.
if len(path) > 0 and not path[-1]:
object = self.getPhysicalRoot()
pop()
try: try:
while path: while path:
...@@ -437,18 +443,19 @@ class Item_w__name__(Item): ...@@ -437,18 +443,19 @@ class Item_w__name__(Item):
return id return id
def getPhysicalPath(self): def getPhysicalPath(self):
'''Returns a path that can be used to access this object again '''Returns a path (an immutable sequence of strings)
that can be used to access this object again
later, for example in a copy/paste operation. getPhysicalRoot() later, for example in a copy/paste operation. getPhysicalRoot()
and getPhysicalPath() are designed to operate together. and getPhysicalPath() are designed to operate together.
''' '''
id=quote(self.__name__) path = (self.__name__,)
p=getattr(self,'aq_inner', None) p = getattr(self,'aq_inner', None)
if p is not None: if p is not None:
url=p.aq_parent.getPhysicalPath() path = p.aq_parent.getPhysicalPath() + path
if url: id=url+'/'+id
return id return path
def format_exception(etype,value,tb,limit=None): def format_exception(etype,value,tb,limit=None):
import traceback import traceback
......
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