[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Traversing - ModuleNamespace.py:1.2 configure.zcml:1.8

Gary Poster gary@zope.com
Thu, 19 Dec 2002 13:14:04 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Traversing
In directory cvs.zope.org:/tmp/cvs-serv5987

Modified Files:
	configure.zcml 
Added Files:
	ModuleNamespace.py 
Log Message:
cleaned-up merge of some code from Bangalore branch, in preparation for introspector merge.  ++module++ namespace lets you traverse to interfaces and classes in dotted notation (see Introspector usage, to be checked in momentarily)




=== Zope3/lib/python/Zope/App/Traversing/ModuleNamespace.py 1.1 => 1.2 ===
--- /dev/null	Thu Dec 19 13:14:04 2002
+++ Zope3/lib/python/Zope/App/Traversing/ModuleNamespace.py	Thu Dec 19 13:14:03 2002
@@ -0,0 +1,33 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+# 
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Zope.App.OFS.Services.ServiceManager.INameResolver import INameResolver
+from Zope.ComponentArchitecture import getServiceManager, getAdapter
+from Zope.ComponentArchitecture import queryDefaultViewName
+from Interface import Interface
+
+
+def module(name, parameters, pname, ob, request):
+    """Used to traverse to a module (in dot notation)"""   
+    servicemanager = getServiceManager(ob)
+    adapter = getAdapter(servicemanager, INameResolver)
+    if adapter is not None:
+        ob = adapter.resolve(name)
+    if queryDefaultViewName(ob, request) is None:
+        return Interface
+    return ob


=== Zope3/lib/python/Zope/App/Traversing/configure.zcml 1.7 => 1.8 ===
--- Zope3/lib/python/Zope/App/Traversing/configure.zcml:1.7	Fri Jul 12 19:07:28 2002
+++ Zope3/lib/python/Zope/App/Traversing/configure.zcml	Thu Dec 19 13:14:03 2002
@@ -45,5 +45,5 @@
 <traversalNamespace name="item" handler=".AttrItemNamespaces.item" />
 <traversalNamespace name="acquire" handler=".AcquireNamespace.acquire" />
 <traversalNamespace name="skin" handler=".SkinNamespace.skin" />
-
+<traversalNamespace name="module" handler=".ModuleNamespace.module" />
 </zopeConfigure>