RE: [Zope] Generating lists of dicionaries from properties
Sure, you could use something itemValues() to get a list of items in a folder, then some combination of: propertyItems(): Return a list of (id, property) tuples. propertyIds(): Returns a list of property ids. getProperty(id, d=None): Get the property id, returning the optional second argument or None if no such property is found. to put the properties into a dictionary for each item in the folder. Scott -----Original Message----- From: Andreas Brinner [mailto:abrinner@gmx.de] Sent: Tuesday, October 15, 2002 3:38 PM To: zope@zope.org Subject: [Zope] Generating lists of dicionaries from properties Hello, I'm looking for a way to generate lists of dicionaries from string properties. As this is for a public website eval doesn't seem to be the best choice. For an example, I want to get this list of dictionaries: prop = ( { "id":"first_entry", "title":"first_title" }, { "id":"second_entry", "title":"second_title" }, ) It should be possible, that this information is entered in a human readable way as a string property. Any suggestions? Thanks Andreas _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) The information contained in this email message may be privileged and is confidential information intended only for the use of the recipient or any employee or agent responsible for delivering it to the intended recipient. Any unauthorized use, distribution or copying of this information is strictly prohibited and may be unlawful. If you have received this communication in error, please notify the sender immediately and destroy the original message and all attachments from your electronic files.
Sure, you could use something itemValues() to get a list of items in a folder, then some combination of:
I think, that you have misunderstood me. The thing is, that I would like to have this dictionary list stored in a string property, so that a python script can 1. generate this list of dictionaries 2. create new items in a folder, with this properties So your solution doesn't work, because the items are subject to create and not already available... Anyway, thank you for your answer. If I don't find an other solution, I can think about creating a tree structure as a pattern, which I then replicate. This would be a solution, but not so nice :-( Andreas
I think, that you have misunderstood me. The thing is, that I would like to have this dictionary list stored in a string property,
That doesn't make sense. Unless you just str the dict and then eval it back you can't do that. You shouldn't be able to do eval in a Python Script, if you'd want to, which you don't.
so that a python script can
So put your dictionary in that Python Script, or make a second Python Script the dictionary. -- Andy McKay www.agmweb.ca ----- Original Message ----- From: "Andreas Brinner" <abrinner@gmx.de> To: "Meilicke, Scott" <scott.meilicke@intp.com>; <zope@zope.org> Sent: Tuesday, October 15, 2002 4:04 PM Subject: RE: [Zope] Generating lists of dicionaries from properties
Sure, you could use something itemValues() to get a list of items in a folder, then some combination of:
I think, that you have misunderstood me. The thing is, that I would like
to
have this dictionary list stored in a string property, so that a python script can 1. generate this list of dictionaries 2. create new items in a folder, with this properties
So your solution doesn't work, because the items are subject to create and not already available...
Anyway, thank you for your answer. If I don't find an other solution, I can think about creating a tree structure as a pattern, which I then replicate. This would be a solution, but not so nice :-(
Andreas
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
so that a python script can
So put your dictionary in that Python Script, or make a second Python Script the dictionary.
I found a practical way to solve the problem. But while writing this an other question occured. First what I'm doing now: I have this external script (e_crea), that creates the files and therefor need the dictionary. A user using my product should be able to influence this creation by changing the dictionary. My first idea was this property string, but I would need eval... Now I'm calling a internal Python Script (i_prop) from my external script. This internal script returns the dicrionary. So a user can create a python script and so influence the files that are created. In the external script I have this line: prop = self['i_prop']() Now my question is: is this a security risk, calling a internal Python Script this way? Cause normally the set of basic funktions are restricted. Are they now restricted too, or do I have to use a special calling method? Thanks, Andreas
participants (3)
-
Andreas Brinner -
Andy McKay -
Meilicke, Scott