[Zope] ZCatalog and dictionary python instances variables (QUEST)
Michel Pelletier
michel@digicool.com
Sat, 08 Apr 2000 12:57:30 -0700
Oscar Picasso wrote:
>
> Hi,
>
> I' trying to use ZCatalog to index some values stored in a dictionary. The
> dictionary is an instance variable of a python class which is a base for a
> ZClass.
>
> **my python class**
>
> class Multi:
> def set(self):
> self.a = 'The a attribute'
> self.b = {'one' : 'un', 'two': 'deux', 'three': 'trois'}
>
> ZMulti is a ZClass derived from Multi, and multi is a ZMulti instance.
>
> Before Cataloging my object I run:
> <dtml-call "multi.set()">
Just to make sure you know, python classes can define an __init__ method
to initialize attributes like this.
>
> But it never works.
>
> Any help greatly appreciated.
I'd like to help, but 'But it never works' is just not enough detail for
me or anyone else to even begin to help you.
_How_ does it never work?
Does it tell you an error?
If there is an error, do you get a traceback?
Does nothing happen?
By default, nothing will happen if it _does_ work. What are you
searching for in this case to try and match your dictionary value? How
are you searching? How does this not return what you expect?
Obviously a TextIndex is not what you want, that's for indexing
documents of text, and trying to text index a dictionary will be ignored
by the Catalog. So we can discard that part of your problem right off.
FieldIndexes index a value to a sequence of documents, and that value
can be any python object. So a FieldIndex should work just fine in this
case.
-Michel