diff options
author | Marius Gedminas <marius@gedmin.as> | 2002-12-12 11:32:35 +0000 |
---|---|---|
committer | Marius Gedminas <marius@gedmin.as> | 2002-12-12 11:32:35 +0000 |
commit | 1e9d9895c22f50e4a6494d50767357b4e59d9064 (patch) | |
tree | 757407a132549b4f698fc04aa920b0f94b0e4d92 | |
parent | e06375a075209c756518d2bb3d4c12801cd3a985 (diff) | |
download | zope-traversing-1e9d9895c22f50e4a6494d50767357b4e59d9064.tar.gz |
Merge named-component-configuration-branch
-rw-r--r-- | __init__.py | 14 | ||||
-rw-r--r-- | tests/testConvenienceFunctions.py | 9 |
2 files changed, 16 insertions, 7 deletions
diff --git a/__init__.py b/__init__.py index 1496128..016788c 100644 --- a/__init__.py +++ b/__init__.py @@ -127,12 +127,13 @@ def locationAsTuple(location): """ if not location: raise ValueError, "location must be non-empty: %s" % repr(location) - if isinstance(location, tuple): - t = tuple(map(unicode, location)) - elif isinstance(location, StringTypes): + if isinstance(location, StringTypes): if location == u'/': # matches '/' or u'/' return (u'',) t = tuple(location.split(u'/')) + elif location.__class__ == tuple: + # isinstance doesn't work when tuple is security-wrapped + t = tuple(map(unicode, location)) else: raise ValueError, \ "location %s must be a string or a tuple of strings." % (location,) @@ -153,12 +154,13 @@ def locationAsUnicode(location): """ if not location: raise ValueError, "location must be non-empty." - if isinstance(location, tuple): + if isinstance(location, StringTypes): + u = unicode(location) + elif location.__class__ == tuple: + # isinstance doesn't work when tuple is security-wrapped u = u'/'.join(location) if not u: # special case for u'' return u'/' - elif isinstance(location, StringTypes): - u = unicode(location) else: raise ValueError, \ "location %s must be a string or a tuple of strings." % (location,) diff --git a/tests/testConvenienceFunctions.py b/tests/testConvenienceFunctions.py index af0e694..7f17b1c 100644 --- a/tests/testConvenienceFunctions.py +++ b/tests/testConvenienceFunctions.py @@ -13,7 +13,7 @@ ############################################################################## """ -$Id: testConvenienceFunctions.py,v 1.10 2002/12/05 14:29:22 stevea Exp $ +$Id: testConvenienceFunctions.py,v 1.11 2002/12/12 11:32:35 mgedmin Exp $ """ from unittest import TestCase, TestSuite, main, makeSuite from Zope.App.OFS.Services.ServiceManager.tests.PlacefulSetup \ @@ -32,6 +32,8 @@ from Zope.App.Traversing.IContainmentRoot import IContainmentRoot from Zope.App.Traversing.PhysicalLocationAdapters \ import WrapperPhysicallyLocatable, RootPhysicallyLocatable +from Zope.Security.Proxy import Proxy +from Zope.Security.Checker import selectChecker from Zope.Exceptions import NotFoundError @@ -39,6 +41,10 @@ class C: def __init__(self, name): self.name = name +def _proxied(*args): + return Proxy(args, selectChecker(args)) + + class Test(PlacefulSetup, TestCase): def setUp(self): @@ -237,6 +243,7 @@ class Test(PlacefulSetup, TestCase): ( u'/xx/yy/zz', (u'',u'xx',u'yy',u'zz'), ('','xx','yy','zz'), '/xx/yy/zz', + _proxied('','xx','yy','zz'), ), ( u'xx', (u'xx',), ('xx',), |