[Zope3-checkins] CVS: Zope3/lib/python/Zope/Proxy - ContextWrapper.py:1.6

Jim Fulton jim@zope.com
Sat, 30 Nov 2002 13:41:34 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Proxy
In directory cvs.zope.org:/tmp/cvs-serv12648/lib/python/Zope/Proxy

Modified Files:
	ContextWrapper.py 
Log Message:
Added convenience functions for getting wrapped attributes and items.

=== Zope3/lib/python/Zope/Proxy/ContextWrapper.py 1.5 => 1.6 ===
--- Zope3/lib/python/Zope/Proxy/ContextWrapper.py:1.5	Sat Jul 13 10:18:37 2002
+++ Zope3/lib/python/Zope/Proxy/ContextWrapper.py	Sat Nov 30 13:41:33 2002
@@ -119,3 +119,17 @@
         _ob = getinnercontext(_ob)
         self._ob = _ob
         return _ob
+
+def getItem(collection, name):
+    return ContextWrapper(collection[name], collection, name=name)
+
+def getAttr(collection, name):
+    return ContextWrapper(getattr(collection, name), collection, name=name)
+
+def queryItem(collection, name, default=None):
+    return ContextWrapper(collection.get(name, default),
+                          collection, name=name)
+
+def queryAttr(collection, name, default=None):
+    return ContextWrapper(getattr(collection, name, default),
+                          collection, name=name)