[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/ZPTPage - ZPTPage.py:1.14 configure.zcml:1.13

Benjamin Saller bcsaller@yahoo.com
Thu, 5 Dec 2002 07:36:49 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/ZPTPage
In directory cvs.zope.org:/tmp/cvs-serv16565

Modified Files:
	ZPTPage.py configure.zcml 
Log Message:
*added SearchableText adapter to the source of a ZPT page, this still has some unicode issues to resolve

=== Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/ZPTPage.py 1.13 => 1.14 ===
--- Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/ZPTPage.py:1.13	Tue Nov 12 12:30:09 2002
+++ Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/ZPTPage.py	Thu Dec  5 07:36:48 2002
@@ -102,3 +102,25 @@
 
     source = property(getSource, setSource, None,
                       """Source of the Page Template.""")
+
+# Adapter for ISearchableText
+
+from Zope.App.index.text.interfaces import ISearchableText
+
+class SearchableText:
+
+    __implements__ = ISearchableText
+    __used_for__ = IZPTPage
+
+    def __init__(self, page):
+        self.page = page
+        
+    def getSearchableText(self):
+        try:
+            # XXX check about encoding here and in the ZPTPage.read
+            #     the exception should go away when we know how this
+            #     works in terms of conversion, for now on problems
+            #     don't index the object
+            return [unicode(self.page.source)]
+        except:
+            return None


=== Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/configure.zcml 1.12 => 1.13 ===
--- Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/configure.zcml:1.12	Tue Nov 19 18:21:45 2002
+++ Zope3/lib/python/Zope/App/OFS/Content/ZPTPage/configure.zcml	Thu Dec  5 07:36:48 2002
@@ -26,6 +26,10 @@
       interface="Zope.App.OFS.Annotation.IAttributeAnnotatable." />
 </content>
 
+<adapter factory=".ZPTPage.SearchableText"
+         provides="Zope.App.index.text.interfaces.ISearchableText"
+         for="Zope.App.OFS.Content.ZPTPage.ZPTPage.IZPTPage" />
+
 <include package=".Views" />
 
 </zopeConfigure>