[Zope3-checkins] CVS: Zope3/src/zope/app/traversing - adapters.py:1.20 interfaces.py:1.2 namespace.py:1.28

Jim Fulton jim at zope.com
Sat Apr 17 13:16:05 EDT 2004


Update of /cvs-repository/Zope3/src/zope/app/traversing
In directory cvs.zope.org:/tmp/cvs-serv18496/src/zope/app/traversing

Modified Files:
	adapters.py interfaces.py namespace.py 
Log Message:
Removed the last vestiges of name parameters. Even though we stopped
supporting parameters in names (name;foo=bar) years ago, we still had
support in the apis. Sheesh.


=== Zope3/src/zope/app/traversing/adapters.py 1.19 => 1.20 ===
--- Zope3/src/zope/app/traversing/adapters.py:1.19	Sat Mar 13 16:03:23 2004
+++ Zope3/src/zope/app/traversing/adapters.py	Sat Apr 17 13:15:34 2004
@@ -23,7 +23,7 @@
 
 from zope.app.traversing.namespace import namespaceLookup
 from zope.app.traversing.namespace import UnexpectedParameters
-from zope.app.traversing.namespace import parameterizedNameParse
+from zope.app.traversing.namespace import nsParse
 
 from zope.interface import implements
 
@@ -40,9 +40,7 @@
     def __init__(self, subject):
         self._subject = subject
 
-    def traverse(self, name, parameters, pname, furtherPath):
-        if parameters:
-            raise UnexpectedParameters(parameters)
+    def traverse(self, name, furtherPath):
         subject = self._subject
         r = getattr(subject, name, _marker)
         if r is not _marker:
@@ -156,9 +154,9 @@
         return obj
 
     if name and name[:1] in '@+':
-        ns, nm, parms = parameterizedNameParse(name)
+        ns, nm = nsParse(name)
         if ns:
-            return namespaceLookup(name, ns, nm, parms, obj, request)
+            return namespaceLookup(ns, nm, obj, request)
     else:
         parms = ()
         nm = name
@@ -173,7 +171,7 @@
             raise NotFoundError('No traversable adapter found', obj)
 
     try:
-        next_item = traversable.traverse(nm, parms, name, further_path)
+        next_item = traversable.traverse(nm, further_path)
         obj = next_item
     except NotFoundError:
         if default != _marker:


=== Zope3/src/zope/app/traversing/interfaces.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/traversing/interfaces.py:1.1	Sat Mar 13 16:03:23 2004
+++ Zope3/src/zope/app/traversing/interfaces.py	Sat Apr 17 13:15:34 2004
@@ -23,7 +23,7 @@
 
 class INamespaceHandler(Interface):
 
-    def __call__(name, parameters, pname, object, request):
+    def __call__(name, object, request):
         """Access a name in a namespace
 
         The name lookup usually depends on an object and/or a
@@ -61,15 +61,11 @@
 class ITraversable(Interface):
     """To traverse an object, this interface must be provided"""
 
-    def traverse(name, parameters, pname, furtherPath):
+    def traverse(name, furtherPath):
         """Get the next item on the path
 
         Should return the item corresponding to 'name' or raise
         NotFoundError where appropriate.
-
-        The parameters provided, are passed as a sequence of
-        name, value items.  The 'pname' argument has the original name
-        before parameters were removed.
 
         furtherPath is a list of names still to be traversed. This method is
         allowed to change the contents of furtherPath.


=== Zope3/src/zope/app/traversing/namespace.py 1.27 => 1.28 ===
--- Zope3/src/zope/app/traversing/namespace.py:1.27	Sat Mar 13 16:03:23 2004
+++ Zope3/src/zope/app/traversing/namespace.py	Sat Apr 17 13:15:34 2004
@@ -36,12 +36,12 @@
 def provideNamespaceHandler(ns, handler):
     _namespace_handlers[ns] = handler
 
-def namespaceLookup(name, ns, qname, parameters, object, request=None):
+def namespaceLookup(ns, qname, object, request=None):
     """Lookup a value from a namespace
 
     name -- the original name
     ns -- The namespace
-    qname -- The name without any parameters
+    qname -- The name without the namespace
 
     The resulting object is returned in the context of the original.
     This means that the caller should *not* wrap the result.
@@ -51,23 +51,42 @@
     if handler is None:
         raise NotFoundError(name)
 
-    new = handler(qname, parameters, name, object, request)
+    new = handler(qname, object, request)
 
     return new
 
 
 namespace_pattern = re.compile('[+][+]([a-zA-Z0-9_]+)[+][+]')
 
-def parameterizedNameParse(name):
-    """Parse a name with parameters, including namespace parameters.
+def nsParse(name):
+    """Parse a namespace-qualified name into a namespace name and a name
 
-    Return:
+    Returns the namespace name and a name.
 
-    - namespace, or None if there isn't one.
+    A namespace-qualified name is usually of the form ++ns++name, as in:
 
-    - unparameterized name.
+    >>> nsParse('++acquire++foo')
+    ('acquire', 'foo')
+
+    The part inside the +s must be an identifier, so:
+
+    >>> nsParse('++hello world++foo')
+    ('', '++hello world++foo')
+    >>> nsParse('+++acquire+++foo')
+    ('', '+++acquire+++foo')
+    
+
+    But it may also be a @@foo, which implies the view namespace:
+    
+    >>> nsParse('@@foo')
+    ('view', 'foo')
+
+    >>> nsParse('@@@foo')
+    ('view', '@foo')
+
+    >>> nsParse('@foo')
+    ('', '@foo')
 
-    - sequence of parameters, as name-value pairs.
     """
 
     ns = ''
@@ -80,7 +99,7 @@
             prefix, ns = match.group(0, 1)
             name = name[len(prefix):]
 
-    return ns, name, ()
+    return ns, name
 
 def getResourceInContext(ob, name, request):
     resource = queryResourceInContext(ob, name, request)
@@ -106,10 +125,7 @@
 
 # ---- namespace processors below ----
 
-def acquire(name, parameters, pname, ob, request):
-    if parameters:
-        raise UnexpectedParameters(parameters)
-
+def acquire(name, ob, request):
     i = 0
     origOb = ob
     while i < 200:
@@ -120,7 +136,7 @@
             try:
                 # XXX what do we do if the path gets bigger?
                 path = []
-                next = traversable.traverse(name, parameters, pname, path)
+                next = traversable.traverse(name, path)
                 if path:
                     continue
             except NotFoundError:
@@ -130,24 +146,20 @@
 
         ob = getattr(ob, '__parent__', None)
         if ob is None:
-            raise NotFoundError(origOb, pname)
+            raise NotFoundError(origOb, name)
 
-    raise ExcessiveWrapping(origOb, pname)
+    raise ExcessiveWrapping(origOb, name)
 
-def attr(name, parameters, pname, ob, request):
-    if parameters:
-        raise UnexpectedParameters(parameters)
+def attr(name, ob, request):
     return getattr(ob, name)
 
-def item(name, parameters, pname, ob, request):
-    if parameters:
-        raise UnexpectedParameters(parameters)
+def item(name, ob, request):
     return ob[name]
 
 from zope.app.applicationcontrol.applicationcontrol \
     import applicationController
 from zope.app.traversing.interfaces import IContainmentRoot
-def etc(name, parameters, pname, ob, request):
+def etc(name, ob, request):
     # XXX
 
     # This is here now to allow us to get service managers from a
@@ -160,30 +172,25 @@
     # not all get methods may satisfy this assumption. It might be
     # best to introduce some sort of etc registry.
 
-    if parameters:
-        raise UnexpectedParameters(parameters)
-
     if (name in ('process', 'ApplicationController')
         and IContainmentRoot.providedBy(ob)):
         return applicationController
 
     if name not in ('site', 'Services'):
-        raise NotFoundError(ob, pname, request)
+        raise NotFoundError(ob, name, request)
 
     method_name = "getSiteManager"
     method = getattr(ob, method_name, None)
     if method is None:
-        raise NotFoundError(ob, pname, request)
+        raise NotFoundError(ob, name, request)
 
     return method()
 
-def help(name, parameters, pname, ob, request):
+def help(name, ob, request):
     """Used to traverse to an online help topic."""
     return zapi.getService(ob, 'OnlineHelp')
 
-def view(name, parameters, pname, ob, request):
-    if parameters:
-        raise UnexpectedParameters(parameters)
+def view(name, ob, request):
     if not request:
         raise NoRequest(pname)
     view = zapi.queryView(ob, name, request)
@@ -192,23 +199,17 @@
 
     return view
 
-def resource(name, parameters, pname, ob, request):
-    if parameters:
-        raise UnexpectedParameters(parameters)
+def resource(name, ob, request):
     if not request:
         raise NoRequest(pname)
 
     resource = queryResourceInContext(ob, name, request)
     if resource is None:
-        raise NotFoundError(ob, pname)
+        raise NotFoundError(ob, name)
 
     return resource
 
-def skin(name, parameters, pname, ob, request):
-
-    if parameters:
-        raise UnexpectedParameters(parameters)
-
+def skin(name, ob, request):
     if not request:
         raise NoRequest(pname)
 
@@ -217,7 +218,7 @@
 
     return ob
 
-def vh(name, parameters, pname, ob, request):
+def vh(name, ob, request):
 
     traversal_stack = request.getTraversalStack()
     app_names = []




More information about the Zope3-Checkins mailing list