summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Poster <gary@zope.com>2002-12-19 18:14:03 +0000
committerGary Poster <gary@zope.com>2002-12-19 18:14:03 +0000
commitd3024cf185f3e1c07d8fde8d571820451db2ee5b (patch)
treea0fa68c480abbb140c8db6dd71609d08b7cdc8e9
parentc8939fe6983b3a80f3813a6fa5bdaca2f7f04f6b (diff)
downloadzope-traversing-d3024cf185f3e1c07d8fde8d571820451db2ee5b.tar.gz
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)
-rwxr-xr-xModuleNamespace.py33
-rw-r--r--configure.zcml2
2 files changed, 34 insertions, 1 deletions
diff --git a/ModuleNamespace.py b/ModuleNamespace.py
new file mode 100755
index 0000000..69e45c0
--- /dev/null
+++ b/ModuleNamespace.py
@@ -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: ModuleNamespace.py,v 1.2 2002/12/19 18:14:03 poster Exp $
+"""
+
+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
diff --git a/configure.zcml b/configure.zcml
index 1ce0980..3521e0b 100644
--- a/configure.zcml
+++ b/configure.zcml
@@ -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>