Comment 2 for bug 1375882

Revision history for this message
Paul Everitt (paul-agendaless) wrote : Re: [Bug 1375882] KarlPGTextIndex is missing index_doc method

At first I thought this was a re-index of the universe. So this would be a very fast forwards/backwards operation.

--Paul

On Sep 30, 2014, at 5:04 PM, Chris Rossi <email address hidden> wrote:

> This is caused by moving KarlPGTextIndex from karlserve to karl--the
> dotted path name to the class has changed so we can't unpickle the old
> index and end up with a broken object. The fix is pretty easy--just
> instantiate a new index and stick it in the right place. Because we're
> a little worried about being able to roll back easily, I'll just post
> this as a snippet that can be run in bin/debug. To roll back just
> import KarlPGTextIndex from the old location in karlserve and do the
> exact same thing:
>
> chris@curiosity:~/proj/karl/devless$ bin/debug
> Python 2.6.9 (unknown, Mar 21 2014, 10:34:41)
> [GCC 4.8.1] on linux3
> Type "help" for more information. "app" is the karl Pyramid application.
>>>> import transaction
>>>> from karl.textindex import KarlPGTextIndex
>>>> from karl.models.site import get_weighted_textrepr
>>>> root.catalog['texts'] = KarlPGTextIndex(get_weighted_textrepr)
>>>> transaction.commit()
>>>>
>
> Also, you might end up with more than one text index as a result of past
> reindex operations. If there is a 'new_texts' index, remove it:
>
> Python 2.6.9 (unknown, Jan 8 2014, 15:38:00)
> [GCC 4.5.4] on linux2
> Type "help" for more information. "app" is the karl Pyramid application.
>>>> root.catalog.keys()
> ['creator', 'member_name', 'creation_date', 'texts', 'titlestartswith', 'allowed', 'modified_date', 'modified_by', 'content_modified', 'virtual', 'email', 'end_date', 'tags', 'interfaces', 'lastfirst', 'publication_date', 'mimetype', 'name', 'title', 'start_date', 'containment', 'path', 'new_texts']
>>>> del root.catalog['new_texts']
>>>> import transaction
>>>> transaction.commit()
>>>>
>
> I've done this on staging and it fixes the problem.
>
> ** Changed in: karl3
> Status: In Progress => Fix Committed
>
> --
> You received this bug notification because you are subscribed to KARL3.
> https://bugs.launchpad.net/bugs/1375882
>
> Title:
> KarlPGTextIndex is missing index_doc method
>
> Status in KARL3:
> Fix Committed
>
> Bug description:
> When adding a blog post we get this stack trace:
>
>
> Traceback (most recent call last):
> File "/srv/karlstaging/staging/63/eggs/pyramid-1.2.1-py2.6.egg/pyramid/tweens.py", line 17, in excview_tween
> response = handler(request)
> File "/srv/karlstaging/staging/63/eggs/pyramid_tm-0.5-py2.6.egg/pyramid_tm/__init__.py", line 107, in tm_tween
> return response
> File "/srv/karlstaging/staging/63/eggs/pyramid_tm-0.5-py2.6.egg/pyramid_tm/__init__.py", line 75, in __exit__
> return self._retry_or_raise(t, v, tb)
> File "/srv/karlstaging/staging/63/eggs/pyramid_tm-0.5-py2.6.egg/pyramid_tm/__init__.py", line 60, in _retry_or_raise
> reraise(t, v, tb) # otherwise reraise the exception
> File "/srv/karlstaging/staging/63/eggs/pyramid_tm-0.5-py2.6.egg/pyramid_tm/__init__.py", line 100, in tm_tween
> response = handler(request)
> File "/srv/karlstaging/staging/63/eggs/pyramid-1.2.1-py2.6.egg/pyramid/router.py", line 153, in handle_request
> response = view_callable(context, request)
> File "/srv/karlstaging/staging/63/eggs/pyramid-1.2.1-py2.6.egg/pyramid/config/views.py", line 523, in __call__
> return view(context, request)
> File "/srv/karlstaging/staging/63/eggs/pyramid-1.2.1-py2.6.egg/pyramid/config/views.py", line 266, in attr_view
> return view(context, request)
> File "/srv/karlstaging/staging/63/eggs/pyramid-1.2.1-py2.6.egg/pyramid/config/views.py", line 239, in predicate_wrapper
> return view(context, request)
> File "/srv/karlstaging/staging/63/eggs/pyramid-1.2.1-py2.6.egg/pyramid/config/views.py", line 186, in _secured_view
> return view(context, request)
> File "/srv/karlstaging/staging/63/eggs/pyramid-1.2.1-py2.6.egg/pyramid/config/views.py", line 292, in rendered_view
> result = view(context, request)
> File "/srv/karlstaging/staging/63/eggs/pyramid_formish-0.2a1-py2.6.egg/pyramid_formish/zcml.py", line 171, in __call__
> return submitted(request, form, controller, self.action, controller)
> File "/srv/karlstaging/staging/63/eggs/pyramid_formish-0.2a1-py2.6.egg/pyramid_formish/zcml.py", line 210, in submitted
> result = getattr(controller, handler)(converted)
> File "/srv/karlstaging/staging/63/src/karl/karl/content/views/blog.py", line 414, in handle_submit
> context[name] = blogentry
> File "/srv/karlstaging/staging/63/eggs/repoze.folder-0.6.2-py2.6.egg/repoze/folder/__init__.py", line 113, in __setitem__
> return self.add(name, other)
> File "/srv/karlstaging/staging/63/eggs/repoze.folder-0.6.2-py2.6.egg/repoze/folder/__init__.py", line 146, in add
> objectEventNotify(ObjectAddedEvent(other, self, name))
> File "/srv/karlstaging/staging/63/eggs/zope.component-3.6.0-py2.6.egg/zope/component/event.py", line 33, in objectEventNotify
> adapters = zope.component.subscribers((event.object, event), None)
> File "/srv/karlstaging/staging/63/eggs/zope.component-3.6.0-py2.6.egg/zope/component/_api.py", line 138, in subscribers
> return sitemanager.subscribers(objects, interface)
> File "/srv/karlstaging/staging/63/eggs/zope.component-3.6.0-py2.6.egg/zope/component/registry.py", line 315, in subscribers
> return self.adapters.subscribers(objects, provided)
> File "/srv/karlstaging/staging/63/eggs/zope.interface-3.5.1-py2.6-linux-i686.egg/zope/interface/adapter.py", line 535, in subscribers
> subscription(*objects)
> File "/srv/karlstaging/staging/63/src/karl/karl/models/subscribers.py", line 77, in index_content
> catalog.index_doc(docid, node)
> File "/srv/karlstaging/staging/63/src/karl/karl/models/catalog.py", line 47, in index_doc
> super(CachingCatalog, self).index_doc(*arg, **kw)
> File "/srv/karlstaging/staging/63/eggs/repoze.catalog-0.8.3-py2.6.egg/repoze/catalog/catalog.py", line 31, in index_doc
> index.index_doc(docid, obj)
> AttributeError: 'KarlPGTextIndex' object has no attribute 'index_doc'
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/karl3/+bug/1375882/+subscriptions