[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Archetypes-users] Searching on a field in a custom content type
On Fri, Feb 27, 2009 at 12:10 AM, audleman <kevin.audleman@xxxxxxxxx> wrote:
>
> I am struggling with searching on a custom content type. I could use some
> help understanding how to search on, let's say, first name. My SpeakerSchema
> has that field defined as:
>
> atapi.StringField('first_name',
> schemata='default',
> searchable=True,
> required=True,
> languageIndependent=True,
> widget = atapi.StringWidget(
> label=_(u'First Name'),
> description = _(u''),
> ),
> storage = atapi.AnnotationStorage(),
> ),
>
> I have tried several things, including searching on the getFirst_name
> function:
>
> self.catalog = getToolByName(context, 'portal_catalog')
> self.catalog.searchResults({'portal_type' :'Speaker', 'getFirst_name' :
> 'Kevin'})
>
> ...searching on the field name itself
>
> self.catalog = getToolByName(context, 'portal_catalog')
> self.catalog.searchResults({'portal_type':'Speaker',
> 'first_name':'Kevin'})
>
> In both cases the query returns all Speaker objects, totally ignoring the
> extra search parameter.
>
> Any suggestions?
You need a getFirst_name index too.
A getFirst_name should exist in portal_catalog.
In profiles/default/catalog.xml, you should have something like this:
<?xml version="1.0"?>
<object name="portal_catalog" meta_type="Plone Catalog Tool">
<index name="getFirst_name"
meta_type="FieldIndex">
<indexed_attr value="getFirst_name"/>
</index>
</object>
ArchGenXML takes care of generating all this code for you.
--
Vincent Fretin
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Archetypes-users mailing list
Archetypes-users@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/archetypes-users
This mailing list archive is a service of Copilotco.