Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Users

Catalog a dictionary

 

 

Zope users RSS feed   Index | Next | Previous | View Threaded


giampiero.benvenuti at chiaroscuro

Aug 3, 2012, 4:13 AM

Post #1 of 5 (700 views)
Permalink
Catalog a dictionary

Hello!

can you please give me some hints on how to catalog a list of dictionaries? Is it possible?

L= [{'id':'1','lastName':'Rossi','firstName':'Mario'}, {...), etc..]

for d in L:
context.Mycatalog.catalog_object( d, d['id'])

Thanks so much in advance!

GP

_______________________________________________
Zope maillist - Zope [at] zope
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )


lists at zopyx

Aug 5, 2012, 10:24 PM

Post #2 of 5 (662 views)
Permalink
Re: Catalog a dictionary [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Giampiero Benvenuti wrote:
> Hello!
>
> can you please give me some hints on how to catalog a list of
> dictionaries? Is it possible?

What have you tried? What exactly is not working?
>
> L= [{'id':'1','lastName':'Rossi','firstName':'Mario'}, {...), etc..]
>
> for d in L: context.Mycatalog.catalog_object( d, d['id'])
>
>
Are you use that you created the related indexes that you are using for
indexes?

Please provide a reasonable description of the problem (if you have one).

- -aj
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJQH1UOAAoJEADcfz7u4AZjbbwLwIj/kqgzC8DazRlomyO4Auv0
B751yKOSYWo+v6j1Ren8SFfuImie3d98oaOp5w2RHL7TyqDU9iEbfDFhTjKmFE9t
KeihBckCkBcsquE04Uih5vnKNVh1IOZhD6VB0yebtr4776bm7HBXi4b8ZVfWjH1Z
NV8HBMRku+0f4M0X8MyWGETSat5wCBO8WnnoYCsHGxpE2VNvgYAIk8LcXGdZsExa
HGEFmmXJy1Z8NAMrGPMQurw9JfBrC7LWDd4feEmXMw6az06kkZWNnp42Zp9YLzcR
tBMwigyZLMNOO9Tt+s+orGKWbKzKxoGqU1/uxGngpR+8/n4bYgFv86/46QwvMFqF
ScInrrYwufvqQUo9jks4HDv+BoRg6v1tUkKipu50ICXk7f1nwRsSy0OGDGmSegN+
JeGcFvUCJb2y0t6/ruBNTiM8Gf1cKr50Z6M5I+lG09Hoyl0iyYwdJu0s8RoGMTOQ
WAYeUXCbzu/CKevZIcXvU6qP/mx5Bfc=
=XvKh
-----END PGP SIGNATURE-----
Attachments: lists.vcf (0.30 KB)


giampiero.benvenuti at chiaroscuro

Aug 6, 2012, 12:37 AM

Post #3 of 5 (660 views)
Permalink
Re: Catalog a dictionary [In reply to]

Hi Andreas,

what I'm trying to do is indexing in a Catalog some Folder objects manipulating some properties.

If I assign to the request the new key value everything works as expected.
For instance:
req=context.REQUEST

for obj in context.objectValues('Folder'):
req.set('city', obj.city+' '+obj.province)
req.set('id', ('/').join(obj.getPhysicalPath()))
container.MyCatalog.catalog_object(req,req['id'])

I was just wondering why I am not able to get the same results (only the id get indexed but not the city) building and indexing dictionaries in the following way:

for obj in context.objectValues('Folder'):
D={}
D['id'] = ('/').join(obj.getPhysicalPath())
D['city'] = obj.city+' '+obj.province
container.MyCatalog.catalog_object(D,D['id'])

And yes, the indexes name are the same and they are listed in the catalog.

P.S. I know i can assign multiple attributes to an index in the catalog, still I wonder why the above code doesn't work.

Thanks for your help,


G.

On Aug 6, 2012, at 07:24 31, Andreas Jung wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
>
> Giampiero Benvenuti wrote:
>> Hello!
>>
>> can you please give me some hints on how to catalog a list of
>> dictionaries? Is it possible?
>
> What have you tried? What exactly is not working?
>>
>> L= [{'id':'1','lastName':'Rossi','firstName':'Mario'}, {...), etc..]
>>
>> for d in L: context.Mycatalog.catalog_object( d, d['id'])
>>
>>
> Are you use that you created the related indexes that you are using for
> indexes?
>
> Please provide a reasonable description of the problem (if you have one).
>
> - -aj
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (Darwin)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQGUBAEBAgAGBQJQH1UOAAoJEADcfz7u4AZjbbwLwIj/kqgzC8DazRlomyO4Auv0
> B751yKOSYWo+v6j1Ren8SFfuImie3d98oaOp5w2RHL7TyqDU9iEbfDFhTjKmFE9t
> KeihBckCkBcsquE04Uih5vnKNVh1IOZhD6VB0yebtr4776bm7HBXi4b8ZVfWjH1Z
> NV8HBMRku+0f4M0X8MyWGETSat5wCBO8WnnoYCsHGxpE2VNvgYAIk8LcXGdZsExa
> HGEFmmXJy1Z8NAMrGPMQurw9JfBrC7LWDd4feEmXMw6az06kkZWNnp42Zp9YLzcR
> tBMwigyZLMNOO9Tt+s+orGKWbKzKxoGqU1/uxGngpR+8/n4bYgFv86/46QwvMFqF
> ScInrrYwufvqQUo9jks4HDv+BoRg6v1tUkKipu50ICXk7f1nwRsSy0OGDGmSegN+
> JeGcFvUCJb2y0t6/ruBNTiM8Gf1cKr50Z6M5I+lG09Hoyl0iyYwdJu0s8RoGMTOQ
> WAYeUXCbzu/CKevZIcXvU6qP/mx5Bfc=
> =XvKh
> -----END PGP SIGNATURE-----
> <lists.vcf>


regebro at gmail

Aug 6, 2012, 4:02 AM

Post #4 of 5 (661 views)
Permalink
Re: Catalog a dictionary [In reply to]

On Mon, Aug 6, 2012 at 9:37 AM, Giampiero Benvenuti
<giampiero.benvenuti [at] chiaroscuro> wrote:
> P.S. I know i can assign multiple attributes to an index in the catalog,
> still I wonder why the above code doesn't work.

I don't know, but first I'd like to know why you are doing this? The
objects in the folder are already indexed, aren't they?

//Lennart
_______________________________________________
Zope maillist - Zope [at] zope
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )


regebro at gmail

Aug 6, 2012, 6:21 AM

Post #5 of 5 (657 views)
Permalink
Re: Catalog a dictionary [In reply to]

On Mon, Aug 6, 2012 at 2:53 PM, Giampiero Benvenuti
<giampiero.benvenuti [at] chiaroscuro> wrote:
> Hi,
>
> I just would like to index a string property of the Folder object in a proper "searchebale" DateTime format.
> Right now I have just a string property like 12:30:30 and I would like to index it as DateTime(DateTime().Date()+' '+mystring)

Then make sure that the folder have an attribute that returns what you
want, and add an index that indexes that attribute.

The folder attribute can be acquired, which means if for example can
be a script in a skin folder, or it can be something you monkey-patch
to the folder. Or it can be calculated, or it can be a view (I think)
etc, etc.

//Lennart
_______________________________________________
Zope maillist - Zope [at] zope
https://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
https://mail.zope.org/mailman/listinfo/zope-announce
https://mail.zope.org/mailman/listinfo/zope-dev )

Zope users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.