[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/TraversalViews - ObjectName.py:1.2 __init__.py:1.3 config.zcml:1.2
Steve Alexander
steve@cat-box.net
Sat, 15 Jun 2002 16:38:49 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/TraversalViews
In directory cvs.zope.org:/tmp/cvs-serv22871/lib/python/Zope/App/ZopePublication/TraversalViews
Modified Files:
ObjectName.py __init__.py config.zcml
Log Message:
Added a set of convenience functions that you can import from
Zope.App.Traversing.
Fixed a few typos in the ContextWrapper docstrings, and also added
an isWrapper method to Zope/Proxy/IContextWrapper, mainly so that
I can raise nice errors if the convenience functions are passed
an unwrapped object, rather than returning objs or Nones or []s and
having programs fail at tenuously related other places.
=== Zope3/lib/python/Zope/App/ZopePublication/TraversalViews/ObjectName.py 1.1 => 1.2 ===
from Zope.Publisher.Browser.IBrowserView import IBrowserView
from Zope.Proxy.ContextWrapper import getWrapperData
+from Zope.App.Traversing.ObjectName \
+ import IObjectName, ObjectName, SiteObjectName
from Interface import Interface
-class IObjectName(Interface):
-
- def __str__():
- """Get a human-readable string representation
- """
-
- def __repr__():
- """Get a string representation
- """
-
- def __call__():
- """Get a string representation
- """
-
-class ObjectName(object):
- # functions as both view and adapter
+class ObjectNameView(ObjectName):
__implements__ = IBrowserView, IObjectName
- def __init__(self, context, request=None):
+ def __init__(self, context, request):
self.context = context
- def __str__(self):
- dict = getWrapperData(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):
- # functions as both view and adapter
+class SiteObjectNameView(SiteObjectName):
__implements__ = IBrowserView, IObjectName
- def __init__(self, context, request=None):
+ def __init__(self, context, request):
pass
-
- def __str__(self):
- return ''
-
- __call__ = __str__
=== Zope3/lib/python/Zope/App/ZopePublication/TraversalViews/__init__.py 1.2 => 1.3 ===
-#
-# This is the only "external" interface to this package.
-
-from ObjectName import IObjectName
+# empty __init__.py to make this a Package.
=== Zope3/lib/python/Zope/App/ZopePublication/TraversalViews/config.zcml 1.1 => 1.2 ===
>
- <browser:view
- name="absolute_url"
- factory=".AbsoluteURL."
- permission='Zope.Public'
- allowed_interface=".AbsoluteURL.IAbsoluteURL"
- />
-
- <browser:view
- for="Zope.App.OFS.Content.Folder.RootFolder.IRootFolder"
- name="absolute_url"
- factory=".AbsoluteURL.SiteAbsoluteURL"
- permission='Zope.Public'
- allowed_interface=".AbsoluteURL.IAbsoluteURL"
- />
+<browser:view
+ name="absolute_url"
+ factory=".AbsoluteURL."
+ permission='Zope.Public'
+ allowed_interface=".AbsoluteURL.IAbsoluteURL" />
- <browser:view
- name="object_name"
- factory=".ObjectName."
- permission='Zope.Public'
- allowed_interface=".ObjectName.IObjectName"
- />
-
- <browser:view
- for="Zope.App.OFS.Content.Folder.RootFolder.IRootFolder"
- name="object_name"
- factory=".ObjectName.SiteObjectName"
- permission='Zope.Public'
- allowed_interface=".ObjectName.IObjectName"
- />
+<browser:view
+ for="Zope.App.OFS.Content.Folder.RootFolder.IRootFolder"
+ name="absolute_url"
+ factory=".AbsoluteURL.SiteAbsoluteURL"
+ permission='Zope.Public'
+ allowed_interface=".AbsoluteURL.IAbsoluteURL" />
- <adapter
- factory=".ObjectName."
- provides=".ObjectName.IObjectName"
- permission='Zope.Public'
- />
-
- <adapter
- factory=".ObjectName.SiteObjectName"
- provides=".ObjectName.IObjectName"
- for="Zope.App.OFS.Content.Folder.RootFolder.IRootFolder"
- permission='Zope.Public'
- />
+<browser:view
+ name="object_name"
+ factory=".ObjectName.ObjectNameView"
+ permission='Zope.Public'
+ allowed_interface="Zope.App.Traversing.ObjectName.IObjectName" />
+
+<browser:view
+ for="Zope.App.OFS.Content.Folder.RootFolder.IRootFolder"
+ name="object_name"
+ factory=".ObjectName.SiteObjectNameView"
+ permission='Zope.Public'
+ allowed_interface="Zope.App.Traversing.ObjectName.IObjectName" />
</zopeConfigure>