[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container/Find/Views/Browser - Find.py:1.2 __init__.py:1.2 browser.zcml:1.2 find.pt:1.2

Jim Fulton jim@zope.com
Mon, 10 Jun 2002 19:28:26 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Container/Find/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv17445/lib/python/Zope/App/OFS/Container/Find/Views/Browser

Added Files:
	Find.py __init__.py browser.zcml find.pt 
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.


=== Zope3/lib/python/Zope/App/OFS/Container/Find/Views/Browser/Find.py 1.1 => 1.2 ===
+#
+# 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$
+"""
+
+from Zope.App.PageTemplate import ViewPageTemplateFile
+from Zope.App.OFS.Container.Find.IFind import IFind
+# XXX this needs to be looked up in a registry
+from Zope.App.OFS.Container.Find.FindAdapter import SimpleIdFindFilter
+
+from Zope.ComponentArchitecture import getAdapter, getView
+
+from Zope.Publisher.Browser.BrowserView import BrowserView
+
+# XXX very simple implementation right now
+class Find(BrowserView):
+    
+    index = ViewPageTemplateFile('find.pt')
+        
+    def findByIds(self, ids):
+        """Do a find for the ids listed in ids, which is a string.
+        """
+        finder = getAdapter(self.context, IFind)
+        ids = ids.split()
+        # if we don't have any ids listed, don't search at all
+        if not ids:
+            return []
+        request = self.request
+        result = []
+        for object in finder.find([SimpleIdFindFilter(ids)]):
+            id = getId(object)
+            url = str(getView(object, 'absolute_url', request))
+            result.append({ 'id': id, 'url': url})
+        return result
+    
+from Zope.Proxy.ContextWrapper import getWrapperData
+
+# XXX get the id of an object (should be imported from somewhere)
+def getId(object):
+    dict = getWrapperData(object)
+    if dict:
+        return dict.get('name')
+    return None


=== Zope3/lib/python/Zope/App/OFS/Container/Find/Views/Browser/__init__.py 1.1 => 1.2 ===


=== Zope3/lib/python/Zope/App/OFS/Container/Find/Views/Browser/browser.zcml 1.1 => 1.2 ===
+   xmlns='http://namespaces.zope.org/zope'
+   xmlns:security='http://namespaces.zope.org/security' 
+   xmlns:browser='http://namespaces.zope.org/browser'
+>
+
+  <browser:view
+      for="Zope.App.OFS.Container.IContainer.IReadContainer"
+      permission="Zope.ManageContent" 
+      factory=".Find.">
+
+     <browser:page name="find.html" attribute="index" />
+  </browser:view>
+
+</zopeConfigure>


=== Zope3/lib/python/Zope/App/OFS/Container/Find/Views/Browser/find.pt 1.1 => 1.2 ===
+<body>
+<div metal:fill-slot="body" >
+<form action="@@find.html" method="GET">
+<input type="text" name="ids" value="" /><br />
+<input type="submit" name="find_submit" value=" Find " />
+</form>
+<table tal:condition="request/ids | nothing">
+<tr tal:repeat="item python:view.findByIds(request['ids'])">
+<td><a href="" tal:attributes="href item/url" tal:content="item/id">id</a></td>
+</tr>
+</table>
+</div>
+</body>
+</html>