[Zope-CMF] Help on catalog query

Andrew Sawyers andrew@zope.com
Fri, 15 Mar 2002 11:12:18 -0500


This is a multi-part message in MIME format.

------=_NextPart_000_0019_01C1CC12.452AE040
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

If you just want to return back brains objects, the following worked for me
in the debugger:
types = ['ItemType1', 'ItemType2']
catalog = root.portal.portal_catalog
res = []
for t in types:
    res.append(catalog(Type=t))

Hope this helps,
Andrew


  -----Original Message-----
  From: zope-cmf-admin@zope.org [mailto:zope-cmf-admin@zope.org]On Behalf Of
Gitte Wange
  Sent: Friday, March 15, 2002 9:42 AM
  To: zope-cmf@zope.org
  Subject: [Zope-CMF] Help on catalog query


  Hello,

  I want to create some dynamic portal_catalog querys based on different
portal types ...

  I want to have a query that fetches all the 'event_like' objects (because
they have the start_date property) and all other properties from there Date
property ...

  It's no problem making one query ..
  But how do I make a loop that fetches some results and then adds the
results to a variabel to I can return only on catalog result ?
  I have tried with:
  result = ''
  for type in types:
      res = catalog.searchResults(some parameters)
      result = result + res

  but that gave me an error (something with bad operator '+') ..
  Then I tried with:

  result = []
  for type in types:
      res = catalog.searchResults(some parameters)
      result.append(res)

  But that didn't return anything useful ..
  Isn't there some way to join results from querys ?

  TIA,
  Gitte Wange

------=_NextPart_000_0019_01C1CC12.452AE040
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial color=3D#0000ff =
size=3D2>If you=20
just want to return back brains objects, the following worked for me in =
the=20
debugger:</FONT></SPAN></DIV>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial color=3D#0000ff =
size=3D2>types=20
=3D ['ItemType1', 'ItemType2']</FONT></SPAN></DIV>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial color=3D#0000ff =

size=3D2>catalog =3D root.portal.portal_catalog</FONT></SPAN></DIV>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial color=3D#0000ff =
size=3D2>res =3D=20
[]</FONT></SPAN></DIV>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial color=3D#0000ff =
size=3D2>for t=20
in types:</FONT></SPAN></DIV>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial color=3D#0000ff =

size=3D2>&nbsp;&nbsp;&nbsp; =
res.append(catalog(Type=3Dt))</FONT></SPAN></DIV>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial color=3D#0000ff =
size=3D2>Hope=20
this helps,</FONT></SPAN></DIV>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial color=3D#0000ff =

size=3D2>Andrew</FONT></SPAN></DIV>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial color=3D#0000ff =

size=3D2>&nbsp;&nbsp; </FONT></SPAN></DIV>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial color=3D#0000ff =

size=3D2>&nbsp;&nbsp; </FONT></SPAN></DIV>
<BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
  <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B> =
zope-cmf-admin@zope.org=20
  [mailto:zope-cmf-admin@zope.org]<B>On Behalf Of </B>Gitte=20
  Wange<BR><B>Sent:</B> Friday, March 15, 2002 9:42 AM<BR><B>To:</B>=20
  zope-cmf@zope.org<BR><B>Subject:</B> [Zope-CMF] Help on catalog=20
  query<BR><BR></FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>Hello, </FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>I want to create some dynamic =
portal_catalog=20
  querys based on different portal types ... </FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>I want to have a query that fetches =
all the=20
  'event_like' objects (because they have the start_date property) and =
all other=20
  properties from there Date property ... </FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>It's no problem making one query .. =
</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>But how do I make a loop that fetches =
some=20
  results and then adds the results to a variabel to I can return only =
on=20
  catalog result ?</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>I have tried with:</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>result =3D ''</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>for type in types:</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; res =3D=20
  catalog.searchResults(some parameters)</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; result =3D result =
+=20
  res</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>but that gave me an error (something =
with bad=20
  operator '+') .. </FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>Then I&nbsp;tried with:</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV>
  <DIV><FONT face=3DArial size=3D2>result =3D []</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>for type in types:</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; res =3D=20
  catalog.searchResults(some parameters)</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
result.append(res)</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>But that didn't return anything =
useful ..=20
  </FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>Isn't there some way to join results =
from querys=20
  ?</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>TIA,</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>Gitte=20
Wange</FONT></DIV></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0019_01C1CC12.452AE040--