[Zope-CMF] Help on catalog query

Gitte Wange gitte@mmmanager.org
Mon, 18 Mar 2002 11:45:47 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_00AF_01C1CE72.72172E80
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

Sorry for my late reply ...

Normally ... wouldn't you call catalog.searchResults for getting the =
brains objects ?

TIA,
Gitte Wange
  ----- Original Message -----=20
  From: Andrew Sawyers=20
  To: Gitte Wange ; zope-cmf@zope.org=20
  Sent: Friday, March 15, 2002 5:12 PM
  Subject: RE: [Zope-CMF] Help on catalog query


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

  Hope this helps,
  Andrew
    =20
    =20
    -----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,=20

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

    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 ...=20

    It's no problem making one query ..=20
    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 =3D ''
    for type in types:
        res =3D catalog.searchResults(some parameters)
        result =3D result + res

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

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

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

    TIA,
    Gitte Wange

------=_NextPart_000_00AF_01C1CE72.72172E80
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.2713.1100" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sorry for my late reply =
...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Normally ... wouldn't you call=20
catalog.searchResults for getting the brains objects ?</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 Wange</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A title=3Dandrew@zope.com href=3D"mailto:andrew@zope.com">Andrew =
Sawyers</A>=20
  </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
title=3Dgitte@mmmanager.org=20
  href=3D"mailto:gitte@mmmanager.org">Gitte Wange</A> ; <A =
title=3Dzope-cmf@zope.org=20
  href=3D"mailto:zope-cmf@zope.org">zope-cmf@zope.org</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Friday, March 15, 2002 =
5:12=20
PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> RE: [Zope-CMF] Help on =
catalog=20
  query</DIV>
  <DIV><BR></DIV>
  <DIV><SPAN class=3D103310016-15032002><FONT face=3DArial =
color=3D#0000ff size=3D2>If=20
  you just want to return back brains objects, the following worked for =
me in=20
  the debugger:</FONT></SPAN></DIV>
  <DIV><SPAN class=3D103310016-15032002><FONT face=3DArial =
color=3D#0000ff=20
  size=3D2>types =3D ['ItemType1', 'ItemType2']</FONT></SPAN></DIV>
  <DIV><SPAN class=3D103310016-15032002><FONT face=3DArial =
color=3D#0000ff=20
  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=20
  =3D []</FONT></SPAN></DIV>
  <DIV><SPAN class=3D103310016-15032002><FONT face=3DArial =
color=3D#0000ff size=3D2>for=20
  t in types:</FONT></SPAN></DIV>
  <DIV><SPAN class=3D103310016-15032002><FONT face=3DArial =
color=3D#0000ff=20
  size=3D2>&nbsp;&nbsp;&nbsp; =
res.append(catalog(Type=3Dt))</FONT></SPAN></DIV>
  <DIV><SPAN class=3D103310016-15032002><FONT face=3DArial =
color=3D#0000ff=20
  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=20
  size=3D2>Andrew</FONT></SPAN></DIV>
  <DIV><SPAN class=3D103310016-15032002><FONT face=3DArial =
color=3D#0000ff=20
  size=3D2>&nbsp;&nbsp; </FONT></SPAN></DIV>
  <DIV><SPAN class=3D103310016-15032002><FONT face=3DArial =
color=3D#0000ff=20
  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> <A=20
    href=3D"mailto:zope-cmf-admin@zope.org">zope-cmf-admin@zope.org</A>=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=20
    other 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=20
    querys ?</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></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_00AF_01C1CE72.72172E80--