[Zope-Checkins]
SVN: Products.Five/branches/regebro-traversal_refactor/
Five runs error free, and I need to go home.
Lennart Regebro
regebro at gmail.com
Thu Apr 27 16:39:36 EDT 2006
Log message for revision 67670:
Five runs error free, and I need to go home.
Changed:
U Products.Five/branches/regebro-traversal_refactor/browser/TrustedExpression.py
U Products.Five/branches/regebro-traversal_refactor/tests/testing/simplecontent.py
-=-
Modified: Products.Five/branches/regebro-traversal_refactor/browser/TrustedExpression.py
===================================================================
--- Products.Five/branches/regebro-traversal_refactor/browser/TrustedExpression.py 2006-04-27 20:38:38 UTC (rev 67669)
+++ Products.Five/branches/regebro-traversal_refactor/browser/TrustedExpression.py 2006-04-27 20:39:35 UTC (rev 67670)
@@ -29,6 +29,19 @@
ModuleImporter = SecureModuleImporter
+from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.interface import implements, Interface
+from zope.app.publication.browser import setDefaultSkin
+from zope.app.traversing.namespace import nsParse
+from zope.app.traversing.namespace import namespaceLookup
+from zope.component import queryMultiAdapter
+
+class FakeRequest(dict):
+ implements(IBrowserRequest)
+
+ def getURL(self):
+ return "http://codespeak.net/z3/five"
+
def trustedTraverse(ob, path, ignored,):
if not path: return self
@@ -40,7 +53,11 @@
if isinstance(path, str): path = path.split('/')
else: path=list(path)
- REQUEST={'TraversalRequestNameStack': path}
+ REQUEST = get(ob, 'REQUEST', None)
+ if REQUEST is None:
+ REQUEST=FakeRequest()
+ setDefaultSkin(REQUEST)
+ REQUEST['TraversalRequestNameStack'] = path
path.reverse()
pop=path.pop
@@ -64,6 +81,17 @@
object=o
continue
+ if name and name[:1] in '@+':
+ # Process URI segment parameters.
+ ns, nm = nsParse(name)
+ if ns:
+ try:
+ o = namespaceLookup(ns, nm, object, REQUEST).__of__(object)
+ except TraversalError:
+ raise KeyError(name)
+ object = o
+ continue
+
t=get(object, '__bobo_traverse__', M)
if t is not M: o=t(REQUEST, name)
else:
@@ -71,7 +99,11 @@
if o is M:
try: o = object[name]
except (AttributeError, TypeError): # better exception
- raise AttributeError(name)
+ o = queryMultiAdapter((object, REQUEST), Interface, name)
+ if o is not None:
+ o = o.__of__(object)
+ else:
+ raise AttributeError(name)
object = o
return object
Modified: Products.Five/branches/regebro-traversal_refactor/tests/testing/simplecontent.py
===================================================================
--- Products.Five/branches/regebro-traversal_refactor/tests/testing/simplecontent.py 2006-04-27 20:38:38 UTC (rev 67669)
+++ Products.Five/branches/regebro-traversal_refactor/tests/testing/simplecontent.py 2006-04-27 20:39:35 UTC (rev 67670)
@@ -20,7 +20,6 @@
from AccessControl import ClassSecurityInfo
from zope.interface import Interface, implements
-from Products.Five.traversable import Traversable
class ISimpleContent(Interface):
pass
@@ -31,7 +30,7 @@
class IIndexSimpleContent(ISimpleContent):
pass
-class SimpleContent(Traversable, SimpleItem):
+class SimpleContent(SimpleItem):
implements(ISimpleContent)
meta_type = 'Five SimpleContent'
More information about the Zope-Checkins
mailing list