[Zope-CMF] Help on catalog query
Andrew Sawyers
andrew@zope.com
Mon, 18 Mar 2002 11:26:57 -0500
This is a multi-part message in MIME format.
------=_NextPart_000_0002_01C1CE6F.D07254D0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Gitte,
the __call__ in Catalog.py and ZCatalog.py are aliased to searchResults; so
it's the same thing. I don't know what is 'normal'; but I typically just
call the catalog.
Andrew
-----Original Message-----
From: zope-cmf-admin@zope.org [mailto:zope-cmf-admin@zope.org]On Behalf Of
Gitte Wange
Sent: Monday, March 18, 2002 5:46 AM
To: zope-cmf@zope.org
Subject: Re: [Zope-CMF] Help on catalog query
Hi,
Sorry for my late reply ...
Normally ... wouldn't you call catalog.searchResults for getting the
brains objects ?
TIA,
Gitte Wange
----- Original Message -----
From: Andrew Sawyers
To: Gitte Wange ; zope-cmf@zope.org
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 = ['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_0002_01C1CE6F.D07254D0
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=3D851052016-18032002><FONT face=3DArial color=3D#0000ff =
size=3D2>Gitte,</FONT></SPAN></DIV>
<DIV><SPAN class=3D851052016-18032002><FONT face=3DArial color=3D#0000ff =
size=3D2>the=20
__call__ in Catalog.py and ZCatalog.py are aliased to =
searchResults; so=20
it's the same thing. I don't know what is 'normal'; but I =
typically just=20
call the catalog.</FONT></SPAN></DIV>
<DIV><SPAN class=3D851052016-18032002><FONT face=3DArial color=3D#0000ff =
size=3D2>Andrew</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> Monday, March 18, 2002 5:46 AM<BR><B>To:</B>=20
zope-cmf@zope.org<BR><B>Subject:</B> Re: [Zope-CMF] Help on catalog=20
query<BR><BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Sorry for my late reply =
...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </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> </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=20
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=20
size=3D2>res =3D []</FONT></SPAN></DIV>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2>for t in types:</FONT></SPAN></DIV>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2> =
res.append(catalog(Type=3Dt))</FONT></SPAN></DIV>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2>Hope 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> </FONT></SPAN></DIV>
<DIV><SPAN class=3D103310016-15032002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2> </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> =
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> </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> </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> </DIV>
<DIV><FONT face=3DArial size=3D2>It's no problem making one query =
..=20
</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> res =3D=20
catalog.searchResults(some parameters)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> result =3D =
result +=20
res</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </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 tried =
with:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </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> res =3D=20
catalog.searchResults(some parameters)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
result.append(res)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </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> </DIV>
<DIV><FONT face=3DArial size=3D2>TIA,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Gitte=20
=
Wange</FONT></DIV></DIV></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY></H=
TML>
------=_NextPart_000_0002_01C1CE6F.D07254D0--