[Checkins] SVN: z3c.website/trunk/src/z3c/website/ Implemented
Tales API for page title
Roger Ineichen
roger at projekt01.ch
Thu May 24 08:10:51 EDT 2007
Log message for revision 75932:
Implemented Tales API for page title
Implemented catalog
Changed:
A z3c.website/trunk/src/z3c/website/catalog.py
A z3c.website/trunk/src/z3c/website/catalog.zcml
U z3c.website/trunk/src/z3c/website/configure.zcml
U z3c.website/trunk/src/z3c/website/interfaces.py
U z3c.website/trunk/src/z3c/website/tales.py
-=-
Added: z3c.website/trunk/src/z3c/website/catalog.py
===================================================================
--- z3c.website/trunk/src/z3c/website/catalog.py (rev 0)
+++ z3c.website/trunk/src/z3c/website/catalog.py 2007-05-24 12:10:51 UTC (rev 75932)
@@ -0,0 +1,85 @@
+###############################################################################
+#
+# Copyright (c) 2007 Projekt01 GmbH.
+# All Rights Reserved.
+#
+###############################################################################
+"""
+$Id: catalog.py 367 2007-03-25 15:25:33Z roger.ineichen $
+"""
+
+import zope.interface
+import zope.component
+from zope.index.text import textindex
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.app.catalog.text import ITextIndex
+from zope.app.catalog import catalog
+from zope.app.component import hooks
+from zope.app.container import contained
+from zope.app import intid
+
+from zc.catalog import catalogindex
+from z3c.configurator import configurator
+
+from z3c.website import interfaces
+
+
+class TextIndex(textindex.TextIndex, contained.Contained):
+
+ # not really true but needed by query.Text
+ zope.interface.implements(ITextIndex)
+
+ def index_doc(self, docid, obj):
+ text = ''
+ if interfaces.IContent.providedBy(obj):
+ text += obj.title + ' '
+ text += obj.description + ' '
+ text += obj.keyword + ' '
+ text += obj.body
+ if interfaces.ISample.providedBy(obj):
+ text += ' '
+ text += obj.headline + ' '
+ text += obj.summary + ' '
+ text += obj.author
+ return super(TextIndex, self).index_doc(docid, text)
+
+ def __repr__(self):
+ return '<%s for IFeed>' %self.__class__.__name__
+
+
+class AddWebSiteCatalog(configurator.ConfigurationPluginBase):
+ """Add a catalog for the site."""
+
+ zope.component.adapts(interfaces.IWebSite)
+
+ def __call__(self, data):
+ # Get the local site manager
+ sm = self.context.getSiteManager()
+
+ # Create an intid utility
+ ids = zope.component.queryUtility(intid.interfaces.IIntIds)
+ if ids is None:
+ ids = intid.IntIds()
+ sm['default']['ids' ] = ids
+ sm.registerUtility(ids, intid.interfaces.IIntIds)
+
+ # Create a IFeed catalog
+ ctlg = catalog.Catalog()
+ sm['default']['WebSiteCatalog'] = ctlg
+ sm.registerUtility(ctlg, zope.app.catalog.interfaces.ICatalog,
+ name='WebSiteCatalog')
+
+ # Set the site, so that the indices don't go crazy
+ originalSite = hooks.getSite()
+ hooks.setSite(self.context)
+
+ # Feed text index
+ ctlg['text'] = TextIndex()
+
+ # Dublin Core Indices
+ ctlg['creator'] = catalogindex.SetIndex('creators', IZopeDublinCore)
+ ctlg['created'] = catalogindex.DateTimeValueIndex(
+ 'created', IZopeDublinCore)
+
+ # Reset the site
+ hooks.setSite(originalSite)
Added: z3c.website/trunk/src/z3c/website/catalog.zcml
===================================================================
--- z3c.website/trunk/src/z3c/website/catalog.zcml (rev 0)
+++ z3c.website/trunk/src/z3c/website/catalog.zcml 2007-05-24 12:10:51 UTC (rev 75932)
@@ -0,0 +1,21 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope">
+
+ <!-- full text index -->
+ <class class=".catalog.TextIndex">
+ <require
+ permission="zope.Public"
+ interface="zope.app.catalog.text.ITextIndex"
+ />
+ <require
+ permission="zope.Public"
+ set_schema="zope.app.catalog.text.ITextIndex"
+ />
+ </class>
+
+ <adapter
+ factory=".catalog.AddWebSiteCatalog"
+ name="AddWebSiteCatalog"
+ />
+
+</configure>
Modified: z3c.website/trunk/src/z3c/website/configure.zcml
===================================================================
--- z3c.website/trunk/src/z3c/website/configure.zcml 2007-05-24 11:43:47 UTC (rev 75931)
+++ z3c.website/trunk/src/z3c/website/configure.zcml 2007-05-24 12:10:51 UTC (rev 75932)
@@ -9,6 +9,7 @@
/>
<include file="authentication.zcml" />
+ <include file="catalog.zcml" />
<include file="security.zcml" />
<include file="sample.zcml" />
<include file="session.zcml" />
Modified: z3c.website/trunk/src/z3c/website/interfaces.py
===================================================================
--- z3c.website/trunk/src/z3c/website/interfaces.py 2007-05-24 11:43:47 UTC (rev 75931)
+++ z3c.website/trunk/src/z3c/website/interfaces.py 2007-05-24 12:10:51 UTC (rev 75932)
@@ -42,28 +42,24 @@
title=_(u'Title'),
description=_(u'Title of the html page.'),
default=u'',
- missing_value=u'',
required=False)
description = zope.schema.Text(
title=_(u'Description'),
description=_(u'Description of the content.'),
default=u'',
- missing_value=u'',
required=False)
keyword = zope.schema.Text(
title=_(u'Keyword'),
description=_(u'Keyword of the content.'),
default=u'',
- missing_value=u'',
required=False)
body = zope.schema.Text(
title=_(u'Body'),
description=_(u'Body is the main part of the page.'),
default=u'',
- missing_value=u'',
required=False)
Modified: z3c.website/trunk/src/z3c/website/tales.py
===================================================================
--- z3c.website/trunk/src/z3c/website/tales.py 2007-05-24 11:43:47 UTC (rev 75931)
+++ z3c.website/trunk/src/z3c/website/tales.py 2007-05-24 12:10:51 UTC (rev 75932)
@@ -1,13 +1,21 @@
-###############################################################################
+##############################################################################
#
-# Copyright 2006 by refline (Schweiz) AG, CH-5630 Muri
+# Copyright (c) 2005 Zope Foundation and Contributors.
+# All Rights Reserved.
#
-###############################################################################
-"""``refline`` TALES Namespace implementation
-
-$Id: api.py 1426 2006-11-10 04:05:22Z roger.ineichen $
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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: provider.py 72087 2007-01-18 01:03:33Z rogerineichen $
+"""
__docformat__ = "reStructuredText"
+
import zope.component
import zope.interface
import zope.schema
More information about the Checkins
mailing list