[Grok-dev] Grok-dev Digest, Vol 60, Issue 1

Danilo G B danilogbotelho at yahoo.com
Wed Sep 7 22:08:02 EST 2011

Hello, Roberto.

grok.index.Field and all IndexDefinition subclasses are actually just there for grokkers. The actual indexes are defined elsewhere. So to upgrade catalogs you should do:

cat = getUtility(ICatalog, 'my_catalog')
cat['new_attribute'] = grok.index.Field.index_class('new_attribute')


Danilo G. Botelho

--- On Wed, 9/7/11, grok-dev-request at zope.org <grok-dev-request at zope.org> wrote:

From: grok-dev-request at zope.org <grok-dev-request at zope.org>
Subject: Grok-dev Digest, Vol 60, Issue 1
To: grok-dev at zope.org
Date: Wednesday, September 7, 2011, 9:00 AM

Send Grok-dev mailing list submissions to
    grok-dev at zope.org

To subscribe or unsubscribe via the World Wide Web, visit
or, via email, send a message with subject or body 'help' to
    grok-dev-request at zope.org

You can reach the person managing the list at
    grok-dev-owner at zope.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Grok-dev digest..."

Today's Topics:

   1. Upgrading catalog utility (Roberto Allende)


Message: 1
Date: Tue, 6 Sep 2011 14:28:53 -0300
From: Roberto Allende <rover at menttes.com>
Subject: [Grok-dev] Upgrading catalog utility
To: grok-dev at zope.org
    <CABZRKQQ2i-qcu0kNocS4YTK+zPjOKCn1-fNQ6+uoYp-yubHE=Q at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1


Short version:
How do i recreate, ie delete an create a new catalog for an existing
application ?.

Long Version:
I need to upgrate an applcation made with grok to a new version and i
need to add a new index to its catalog. Following the example at Grok
Documentation[1], let's say i've:

class SiteCatalog(grok.Indexes):

    counter = Value()

An my new catalog has a new attribute, called new_attribute:

class SiteCatalog(grok.Indexes):

    counter = Value()
    new_attribute = grok.index.Field()

So, the problem is i've to re create SiteCatalog for my application
and "Source code for grok.index"[2] says  "Note that, since index
creation (and thus a call to our :meth:`setup()` method) currently
occurs only during the creation of a new Grok `Application` object in
the Zope Database".

I tried to instantiate the index and they monkey patch, which it
wouldn't be the most elegant solution but it could solve the problem
runing an upgrade method just once and i got an "can only be
instantiated on class level" exception.

So... any suggestion is very appreciated.

Kind Regards
Roberto Allende

1. http://grok.zope.org/documentation/how-to/implementing-search/view
2. http://grok.zope.org/doc/dev/_modules/grok/index.html


Grok-dev mailing list
Grok-dev at zope.org

End of Grok-dev Digest, Vol 60, Issue 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20110907/a3eb8f60/attachment.html 

More information about the Grok-dev mailing list