ReferenceFields and the portal_catalog

1 message Options
Embed this post
Permalink
Will B-2 () ReferenceFields and the portal_catalog
Reply Threaded More More options
Print post
Permalink
Hello All,

I have a question about using ReferenceFields in the catalog.  I have
the following situation.

I have a content type, "state", which represents US states.  I have
other content types which include a ReferenceField for multiple
"state" objects:

    ReferenceField(
        name='states',
        index='FieldIndex:schema',
        widget=InAndOutWidget(
            label="Jurisdictions",
            description="Highlight one or more jurisdictions, then
click the >> button to select the highlighted jurisdictions.",
        ),
        allowed_types=('state',),
        multiValued=True,
        relationship='State CategoryStateMixin',
        required=1,
        vocabulary_custom_label="b.Title",
    ),

Looking at the index in the portal_catalog in ZMI, everything looks
fine, the index exists, and if I "Browse" it, I see the objects I
should see, associated with the appropriate state objects's UIDs.  If
I search the catalog using any other index, and get an object back, I
can easily look up the correct state.  None of this is a problem.

My problem however is attempting to search the catalog for objects
with a specific state in their "states" reference field.  The reason
I'm trying to do this is as a filter-type option to a search that
includes content-types and text searching, so that it all goes through
the portal_catalog (basically, a modified version of Plone's "Advanced
Search" page.)  To illustrate basically what I'm attempting to do, and
to test, I'm using the following script:

    from Products.CMFCore.utils import getToolByName
    portal_catalog = getToolByName(container, "portal_catalog")

    uid = "50a4bf8730850119c5e3c2046689a51e"
    results = portal_catalog(getRawStates = [uid,])
    print len(results)
    return printed

If I "Find Objects" in the portal_catalog, I can easily find an object
with the following listed under "Index Contents":

 getRawStates   ['50a4bf8730850119c5e3c2046689a51e']

My basic question is whether there is any documentation that exists
for querying reference fields in the portal_catalog.  If not, does
anyone have any hints to help with what I'm trying to do?  I don't see
a reason why this shouldn't be possible, but the only thing I could
dig up in Google was a question about doing this same thing, but with
single values instead of multi-values.  Based on that, I really
thought this should work, but there is obviously something I'm either
doing wrong, or an assumption I'm making that's wrong.

This is Plone 2.5.2 with Zope 2.9.6, and Archetypes 1.4.2.  If there's
any more information I can provide, please, let me know.  Everything
else about the ReferenceField

Thanks very much in advance!

-Will

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users