runtime error when creating selection property from function
HI, I don't know if this is the correct list, but here goes. I have written a custom python product and recieve the following error when I try to view the "Properties" page: Error Type: RuntimeError Error Value: function attributes not accessible in restricted mode The source of the error is a selection property I have defined in _properties like so: {'id':'data_source', 'type':'selection', 'mode': 'w', 'select_variable':'getDataSources'} Directly following my _properties definition in the class, I have the getDataSources method: def getDataSources (self): """ Get the sources (methods, queries, etc.) that we can pull data from. """ ds = [] for item in self.superValues(('DTML Method', 'External Method', 'Script (Python)', 'Z SQL Method')): ds.append(item.id) return ds More specifically, the error stems from the call to self.superValues(...) in the for loop. If I comment out the for loop and manually populate the ds list, it works fine. It also works fine if I change the 'type':'selection' to 'type':'multiple selection' in the _properties definition. I am running Zope 2.6.1 on Windows ME with Pyton 2.1.3. Why does Zope think I am runnng in restricted mode when I make this call? Why does this work for multiple selection but not selection types? Any help/suggestions are greatly appreciated. Thanks! ===== Chris Leonello cleonello@yahoo.com __________________________________ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/
Chris Leonello wrote at 2003-10-28 10:16 -0800:
I don't know if this is the correct list, but here goes. I have written a custom python product and recieve the following error when I try to view the "Properties" page:
Error Type: RuntimeError Error Value: function attributes not accessible in restricted mode
In the future, please post the traceback as well...
... for item in self.superValues(('DTML Method', 'External Method', 'Script (Python)', 'Z SQL Method')): ds.append(item.id)
Your problem almost surely is in the "id" above: For many objects "id" is a (string) attribute but for some (old) object types, it is a method. Never use "id" (unless you know precisely what you are doing). Always use the method "getId". I.e., your code should read: ds.append(item.getId()) -- Dieter
--- Dieter Maurer <dieter@handshake.de> wrote:
Chris Leonello wrote at 2003-10-28 10:16 -0800:
I don't know if this is the correct list, but here goes. I have written a custom python product and recieve the following error when I try to view the "Properties" page:
Error Type: RuntimeError Error Value: function attributes not accessible in restricted mode
In the future, please post the traceback as well...
Will do.
... for item in self.superValues(('DTML Method', 'External Method', 'Script (Python)', 'Z SQL Method')): ds.append(item.id)
Your problem almost surely is in the "id" above:
For many objects "id" is a (string) attribute but for some (old) object types, it is a method.
Never use "id" (unless you know precisely what you are doing). Always use the method "getId". I.e., your code should read:
ds.append(item.getId())
That was it! Being very new to Python and Zope, I wasn't aware of the id as sometimes a method sometimes an attribute. This is invaluable advice. Thanks!
-- Dieter
===== Chris Leonello cleonello@yahoo.com __________________________________ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/
participants (2)
-
Chris Leonello -
Dieter Maurer