[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Traversing - SkinNamespace.py:1.1 meta.zcml:1.1 AcquireNamespace.py:1.3 AttrItemNamespaces.py:1.3 EtcNamespace.py:1.4 Namespaces.py:1.4 PhysicalLocationAdapters.py:1.2 PresentationNamespaces.py:1.4 configure.zcml:1.5
Jim Fulton
jim@zope.com
Fri, 12 Jul 2002 15:29:03 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/Traversing
In directory cvs.zope.org:/tmp/cvs-serv21500/lib/python/Zope/App/Traversing
Modified Files:
AcquireNamespace.py AttrItemNamespaces.py EtcNamespace.py
Namespaces.py PhysicalLocationAdapters.py
PresentationNamespaces.py configure.zcml
Added Files:
SkinNamespace.py meta.zcml
Log Message:
Finally added a configuration directive for registering traversal
namespace handlers:
<traversalNamespace name="etc" handler=".EtcNamespace.etc" />
Added a "skin" namespace so you can play with Sidbei's new UI work
by adding ++skin++ZopeTop to the front of your URLs:
http://localhost:8080/++skin++ZopeTop
Added some needed __init__ modules to some of the new ZopeTop packages
and fixed up ZopeTop configure.zcml.
=== Added File Zope3/lib/python/Zope/App/Traversing/SkinNamespace.py ===
##############################################################################
#
# 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: SkinNamespace.py,v 1.1 2002/07/12 19:28:32 jim Exp $
"""
from Zope.App.OFS.ApplicationControl.ApplicationControl \
import ApplicationController
from Namespaces import provideNamespaceHandler
from Exceptions import UnexpectedParameters
from Zope.Exceptions import NotFoundError
def skin(name, parameters, pname, ob, request):
if parameters:
raise UnexpectedParameters(parameters)
request.setViewSkin(name)
return ob
=== Added File Zope3/lib/python/Zope/App/Traversing/meta.zcml ===
<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
<directives namespace="http://namespaces.zope.org/zope">
<directive name="traversalNamespace" attributes="name handler"
handler=".Namespaces.directive" />
</directives>
</zopeConfigure>
=== Zope3/lib/python/Zope/App/Traversing/AcquireNamespace.py 1.2 => 1.3 ===
raise ExcessiveWrapping(origOb, pname)
-provideNamespaceHandler('acquire', acquire)
-
=== Zope3/lib/python/Zope/App/Traversing/AttrItemNamespaces.py 1.2 => 1.3 ===
raise UnexpectedParameters(parameters)
return getattr(ob, name)
-provideNamespaceHandler('attribute', attr)
-
def item(name, parameters, pname, ob, request):
if parameters:
raise UnexpectedParameters(parameters)
return ob[name]
-
-provideNamespaceHandler('item', item)
-
-
-# YAGNI
-#
-# def accessor(name, parameters, ob, request):
-# if parameters:
-# raise UnexpectedParameters(parameters)
-#
-# method = getattr(ob, name, None)
-# if method is None:
-# raise NotFound(ob, name, request)
-#
-# return method()
-#
-# provideNamespaceHandler('accessor', accessor)
=== Zope3/lib/python/Zope/App/Traversing/EtcNamespace.py 1.3 => 1.4 ===
raise NotFoundError(ob, pname, request)
return method()
-
-provideNamespaceHandler('etc', etc)
=== Zope3/lib/python/Zope/App/Traversing/Namespaces.py 1.3 => 1.4 ===
from Zope.Exceptions import NotFoundError
from Zope.Proxy.ContextWrapper import ContextWrapper
+from Zope.Configuration.Action import Action
_namespace_handlers = {}
def provideNamespaceHandler(ns, handler):
_namespace_handlers[ns] = handler
+def directive(_context, name, handler):
+ handler = _context.resolve(handler)
+ return [Action(
+ discriminator=("traversalNamespace", name),
+ callable=provideNamespaceHandler,
+ args=(name, handler),
+ )]
+
def namespaceLookup(name, ns, qname, parameters, object, request=None):
"""Lookup a value from a namespace
@@ -38,8 +47,3 @@
new = ContextWrapper(handler(qname, parameters, name, object, request),
object, name=name)
return new
-
-# XXX should get this from zcml
-# Register the etc, view, and resource namespaces
-import EtcNamespace, PresentationNamespaces, AttrItemNamespaces
-import AcquireNamespace
=== Zope3/lib/python/Zope/App/Traversing/PhysicalLocationAdapters.py 1.1 => 1.2 ===
container = getAdapter(container, IPhysicallyLocatable)
container_path = container.getPhysicalPath()
+ if name == '.':
+ # skip
+ return container_path
+
return container_path + (name, )
=== Zope3/lib/python/Zope/App/Traversing/PresentationNamespaces.py 1.3 => 1.4 ===
raise NoRequest(pname)
return getView(ob, name, request)
-provideNamespaceHandler('view', view)
-
def resource(name, parameters, pname, ob, request):
if parameters:
raise UnexpectedParameters(parameters)
@@ -47,6 +45,4 @@
raise NotFoundError(ob, pname)
return resource
-
-provideNamespaceHandler('resource', resource)
=== Zope3/lib/python/Zope/App/Traversing/configure.zcml 1.4 => 1.5 ===
factory=".PhysicalLocationAdapters.RootPhysicallyLocatable"
/>
+<traversalNamespace name="etc" handler=".EtcNamespace.etc" />
+<traversalNamespace name="view" handler=".PresentationNamespaces.view" />
+<traversalNamespace name="view" handler=".PresentationNamespaces.resource" />
+<traversalNamespace name="attribute" handler=".AttrItemNamespaces.attr" />
+<traversalNamespace name="item" handler=".AttrItemNamespaces.attr" />
+<traversalNamespace name="acquire" handler=".AcquireNamespace.acquire" />
+<traversalNamespace name="skin" handler=".SkinNamespace.skin" />
</zopeConfigure>