Re: Grok-dev Digest, Vol 60, Issue 1

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Grok-dev Digest, Vol 60, Issue 1

Danilo G B
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')
cat.updateIndexes()

Regards,

Danilo G. Botelho

--- On Wed, 9/7/11, [hidden email] <[hidden email]> wrote:

From: [hidden email] <[hidden email]>
Subject: Grok-dev Digest, Vol 60, Issue 1
To: [hidden email]
Date: Wednesday, September 7, 2011, 9:00 AM

Send Grok-dev mailing list submissions to
    grok-dev@...

To subscribe or unsubscribe via the World Wide Web, visit
    https://mail.zope.org/mailman/listinfo/grok-dev
or, via email, send a message with subject or body 'help' to
    grok-dev-request@...

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

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@...>
Subject: [Grok-dev] Upgrading catalog utility
To: grok-dev@...
Message-ID:
    <CABZRKQQ2i-qcu0kNocS4YTK+zPjOKCn1-fNQ6+uoYp-yubHE=Q@...>
Content-Type: text/plain; charset=ISO-8859-1

Hello

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):
    grok.site(Testvalueindex)
    grok.context(MyObject)
    grok.name('my_catalog')

    counter = Value()

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

class SiteCatalog(grok.Indexes):
    grok.site(Testvalueindex)
    grok.context(MyObject)
    grok.name('my_catalog')

    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@...
https://mail.zope.org/mailman/listinfo/grok-dev


End of Grok-dev Digest, Vol 60, Issue 1
***************************************

_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev