[Zope3-checkins] CVS: Zope3/src/zope/app/traversing - __init__.py:1.23 adapters.py:1.11 configure.zcml:1.8
Steve Alexander
steve@cat-box.net
Fri, 13 Jun 2003 13:41:51 -0400
Update of /cvs-repository/Zope3/src/zope/app/traversing
In directory cvs.zope.org:/tmp/cvs-serv28622/src/zope/app/traversing
Modified Files:
__init__.py adapters.py configure.zcml
Log Message:
Removed the @@object_name view, as used in some page templates, and
the ObjectName view and adapter also.
Extended IPhysicallyLocatable with a getName method.
Renamed the convenience function objectName to getName.
If you have page templates that use @@object_name, then you can replace it
with zope:name.
=== Zope3/src/zope/app/traversing/__init__.py 1.22 => 1.23 ===
--- Zope3/src/zope/app/traversing/__init__.py:1.22 Tue Jun 3 15:43:45 2003
+++ Zope3/src/zope/app/traversing/__init__.py Fri Jun 13 13:41:20 2003
@@ -19,9 +19,8 @@
from zope.interface import moduleProvides
from zope.component import getAdapter
-from zope.app.interfaces.traversing import IObjectName, IContainmentRoot
+from zope.app.interfaces.traversing import IContainmentRoot, ITraversalAPI
from zope.app.interfaces.traversing import ITraverser, IPhysicallyLocatable
-from zope.app.interfaces.traversing import ITraversalAPI
from zope.context import getWrapperContainer, isWrapper
moduleProvides(ITraversalAPI)
@@ -120,12 +119,10 @@
else:
return obj
-def objectName(obj):
+def getName(obj):
"""Get the name an object was traversed via
-
- Raises TypeError if the object is not context-wrapped
"""
- return getAdapter(obj, IObjectName)()
+ return getAdapter(obj, IPhysicallyLocatable).getName()
def getParent(obj):
"""Returns the container the object was traversed via.
=== Zope3/src/zope/app/traversing/adapters.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/traversing/adapters.py:1.10 Wed Jun 4 04:46:33 2003
+++ Zope3/src/zope/app/traversing/adapters.py Fri Jun 13 13:41:20 2003
@@ -17,7 +17,7 @@
from zope.exceptions import NotFoundError
-from zope.app.interfaces.traversing import IObjectName, IPhysicallyLocatable
+from zope.app.interfaces.traversing import IPhysicallyLocatable
from zope.app.interfaces.traversing import IContainmentRoot
from zope.app.interfaces.traversing import ITraverser, ITraversable
@@ -58,36 +58,6 @@
else:
raise NotFoundError(subject, name)
-class ObjectName(object):
-
- implements(IObjectName)
-
- def __init__(self, context):
- self.context = context
-
- def __str__(self):
- dict = getInnerWrapperData(self.context)
- name = dict and dict.get('name') or None
- if name is None:
- raise TypeError, \
- 'Not enough context information to get an object name'
- return name
-
- __call__ = __str__
-
-
-class SiteObjectName(object):
-
- implements(IObjectName)
-
- def __init__(self, context):
- pass
-
- def __str__(self):
- return ''
-
- __call__ = __str__
-
class WrapperPhysicallyLocatable:
__doc__ = IPhysicallyLocatable.__doc__
@@ -123,6 +93,10 @@
else:
return container_path + u'/' + name
+ def getName(self):
+ "See IPhysicallyLocatable"
+ return getInnerWrapperData(self.context)['name']
+
class RootPhysicallyLocatable:
__doc__ = IPhysicallyLocatable.__doc__
@@ -140,6 +114,10 @@
def getRoot(self):
"See IPhysicallyLocatable"
return self.context
+
+ def getName(self):
+ "See IPhysicallyLocatable"
+ return u''
class Traverser:
"""Provide traverse features"""
=== Zope3/src/zope/app/traversing/configure.zcml 1.7 => 1.8 ===
--- Zope3/src/zope/app/traversing/configure.zcml:1.7 Tue Apr 15 05:37:26 2003
+++ Zope3/src/zope/app/traversing/configure.zcml Fri Jun 13 13:41:20 2003
@@ -12,20 +12,6 @@
factory="zope.app.traversing.adapters.DefaultTraversable"
provides="zope.app.interfaces.traversing.ITraversable" />
-<adapter
- for="*"
- factory="zope.app.traversing.adapters.ObjectName"
- provides="zope.app.interfaces.traversing.IObjectName"
- permission='zope.Public'
- />
-
-<adapter
- factory="zope.app.traversing.adapters.SiteObjectName"
- provides="zope.app.interfaces.traversing.IObjectName"
- for="zope.app.interfaces.content.folder.IRootFolder"
- permission='zope.Public'
- />
-
<adapter
for="*"
provides="zope.app.interfaces.traversing.IPhysicallyLocatable"