Major newbie here. I am wanting to create a python method that iterates over items in a folder object in Zope. I am struggling with how to access objects in the ZODB in python. Here's the script in the simplest form. for x in folderObject : return x I am going to do things to the items once I have access to them, I just can't figure out how to reference ZODB objects in Python. I have done searches on the zope site and looked through the zdp but could not find anything. I am calling the method from a <DTML-var pythonMethodName> with no args. My assumption is that since this is a Python Method, it has access to the ODB structure without having to pass it anything. Am I wrong here? Thanks, Scott B. Voice: 661-325-0288 Business: www.launchpoint.net Weblog Portal: www.blogthis.com
On Thu, 1 Jun 2000, Scott Burton wrote:
for x in folderObject : return x
I am going to do things to the items once I have access to them, I just can't figure out how to reference ZODB objects in Python. I have
for x in folderObject.objectValues(['some_meta_type','some_other_type']): do stuff If the external method is in a folder, then 'self' is the folder object when the method gets called. --RDM
----- Original Message ----- From: "Scott Burton" <scott@launchpoint.net> To: <zope@zope.org> Sent: Thursday, June 01, 2000 6:58 PM Subject: [Zope] Python and Zope Question
Major newbie here. I am wanting to create a python method that iterates over items in a folder object in Zope. I am struggling with how to access objects in the ZODB in python. Here's the script in the simplest form. for x in folderObject : return x
You need to put self as a parameter to your method and then do for x in self.folderObject.objectValues(): return x You use "self" to get at all of the stuff in the ZODB. Note that self is bound to the container of the PythonMethod. So, if you want the PM to work on the current folder, you can just do: for x in self.objectValues(): return x (Of course, this will just return the first value, but that was your example :) Kevin
participants (3)
-
Kevin Dangoor -
R. David Murray -
Scott Burton