[Zope3-checkins] CVS: Zope3/src/zope/app/browser/catalog - __init__.py:1.1.2.1 advanced.pt:1.1.2.1 catalog.py:1.1.2.1 catalog_icon.gif:1.1.2.1 configure.zcml:1.1.2.1

Anthony Baxter anthony@interlink.com.au
Sat, 12 Jul 2003 02:15:13 -0400


Update of /cvs-repository/Zope3/src/zope/app/browser/catalog
In directory cvs.zope.org:/tmp/cvs-serv26101/browser/catalog

Added Files:
      Tag: melb-2003-content-catalog-branch
	__init__.py advanced.pt catalog.py catalog_icon.gif 
	configure.zcml 
Log Message:
first cut at catalogs. There are both content-space catalogs and utility-space
catalogs - in zope/app/catalog/catalog.txt is an example of creating the 
latter.

Next up is to re-work the Catalog<->Index interface. If you create 
catalogs now, you'll need to throw them away when those changes land
(soon). Note also that the search interface at the moment is a little
bit primitive - you call 'searchResults(key=value, key2=value2)'.



=== Added File Zope3/src/zope/app/browser/catalog/__init__.py ===


=== Added File Zope3/src/zope/app/browser/catalog/advanced.pt ===
<html metal:use-macro="context/@@standard_macros/page">
<head>
<title>Title Here</title>
</head>
<body>
<div metal:fill-slot="body">
    <table border="0">
    <caption i18n:translate="">Advanced Catalog Thingies</caption>
    <tbody>
      <tr>
	<span tal:condition="context/getSubscribed" tal:omit-tag="">
	    <td>Catalog is currently <strong>subscribed</strong> to the objectHub.</td>
	    <td><form method="post" action="unsubscribe.html">
	    <input type="submit" name="unsubscribe" value="Unsubscribe">
	    </form></td>
	</span>
	<span tal:condition="not:context/getSubscribed" tal:omit-tag="">
	    <td>Catalog is currently <strong>unsubscribed</strong> from the objectHub.</td>
	    <td><form method="post" action="subscribe.html">
	    <input type="submit" name="subscribe" value="Subscribe">
	    <input type="checkbox" value="true" name="update" CHECKED> (and reindex all objects, if checked)
	    </form></td>
	</span>
      </tr>
      <tr>
        <form method="POST" action="clear.html">
        <td align="right">Clear all indexes<br><i>not hooked up yet</i></td>
        <td><input type="submit" name="submit" value="Clear"></td>
        </form>
      </tr>
      <tr>
        <form method="POST" action="reindex.html">
        <td align="right">Refresh all indexes<br><i>not hooked up yet</i></td>
        <td><input type="submit" name="submit" value="Refresh"></td>
        </form>
      </tr>
    </tbody>
    </table>
</div>
</body>
</html>


=== Added File Zope3/src/zope/app/browser/catalog/catalog.py ===
from persistence import Persistent
from zope.interface import implements
from zope.component import getAdapter

from zope.app.event import publish
from zope.app.event.objectevent import ObjectCreatedEvent, ObjectModifiedEvent

from zope.app.index.field.index import FieldIndex
from zope.app.index.text.index import TextIndex

from zope.app.interfaces.container import IAdding

from zope.app.browser.container.adding import Adding

from zope.app.catalog.catalog import Catalog

import time

from zope.app.interfaces.catalog.catalog import ICatalog, ICatalogView

class CatalogEditView:
    "Provides a user interface for configuring a catalog"

    __used_for__ = ICatalog

    def __init__(self, context, request):
	self.context = context
	self.request = request

    def subscribe(self, update=False):
        self.context.subscribeEvents(update)
	self.request.response.redirect(".")

    def unsubscribe(self):
        self.context.unsubscribeEvents()
	self.request.response.redirect(".")

    def clear(self):
        self.context.clearIndexes()

    def reindex(self):
        self.context.updateIndexes()

class IndexAdding(Adding):
    menu_id = 'catalog_index_menu'



=== Added File Zope3/src/zope/app/browser/catalog/catalog_icon.gif ===
  <Binary-ish file>

=== Added File Zope3/src/zope/app/browser/catalog/configure.zcml ===
<zopeConfigure xmlns="http://namespaces.zope.org/zope"
               xmlns:browser="http://namespaces.zope.org/browser"
	       xmlns:global_translation="http://namespaces.zope.org/gts"
>

<global_translation:registerTranslations directory="translation_files"/>

<!-- Allow a catalog to be added to content space -->
<browser:menuItem menu="add_content"
  for="zope.app.interfaces.container.IAdding"
  title="Catalog"
  action="zope.app.catalog"
  description="Catalog"
/>

<browser:icon name="zmi_icon" 
              for="zope.app.interfaces.catalog.catalog.ICatalog"
              file="catalog_icon.gif"/>

<browser:menuItem
  menu="add_component"
  action="zope.app.catalogutility"
  title="Catalog"
  for="zope.app.interfaces.container.IAdding"
  permission="zope.ManageServices"
  />

<!-- Standard container 'contents' tab -->
<browser:page
  for="zope.app.interfaces.catalog.catalog.ICatalog"
  name="contents.html"
  menu="zmi_views"
  title="Indexes"
  attribute="contents"
  class="zope.app.browser.container.contents.Contents"
  permission="zope.ManageContent"
/>

<!-- This hooks up a custom add menu. This will be improved when
     Jim finished refactoring Containers to suck less. -->
<browser:view
   for="zope.app.interfaces.catalog.catalog.ICatalog"
   name="+"
   menu="zmi_actions" title="Add"
   class="zope.app.browser.catalog.catalog.IndexAdding"
   permission="zope.ManageContent">
   <browser:page name="index.html"  attribute="index" />
   <browser:page name="action.html" attribute="action" />
</browser:view>

<!-- the add menu is browser.IndexAdding -->
<browser:menu id="catalog_index_menu" title="Add Index" />

<!-- Add a couple of items to the add menu -->
<!-- TextIndex -->
<!-- Text index disabled for now, need to hook it's search index up better.
<browser:menuItem
  menu="catalog_index_menu"
  for="zope.app.interfaces.container.IAdding"
  action="zope.app.index.text.TextIndex"
  title="Text Index"
  description="An index to support full-text search"
/>
-->

<!-- FieldIndex -->
<browser:addform
  name="AddFieldIndexToCatalog"
  menu="catalog_index_menu" title="Field Index"
  schema="zope.app.interfaces.index.field.IUIFieldIndex"
  permission="zope.ManageServices"
  content_factory="zope.app.index.field.index.FieldIndex"
  arguments="field_name"
  keyword_arguments="interface"
/>

<!-- the Advanced tab of the Catalog -->
<browser:pages
  for="zope.app.interfaces.catalog.catalog.ICatalog"
  class="zope.app.browser.catalog.catalog.CatalogEditView"
  permission="zope.ManageContent">
  <browser:page name="index.html" template="advanced.pt"
   menu="zmi_views" title="Advanced"/>
  <browser:page name="subscribe.html" attribute="subscribe"/>
  <browser:page name="unsubscribe.html" attribute="unsubscribe"/>
  <browser:page name="clear.html" attribute="clear"/>
  <browser:page name="reindex.html" attribute="reindex"/>
</browser:pages>

</zopeConfigure>