Problem getting to my variables
Newbie question: What's the syntax for accessing a variable in one method from another. Say the two methods: ---------- def manage_addFoo(self, id, title, REQUEST=None): A_folder = getattr(base_folder,someID) def manage_addBar(self, id, REQUEST=None): manage_addFoo.A_folder._setObject(id, BarObject) ---------- In the second method I simply want to add an object to A_folder which is defined in the first method. I would like to know what's the correct syntax (obviously my line 4 is wrong). And I don't want to use 'return A_folder' in manage_addFoo because it defines many such variables, each accessed by different other methods. I just want to selectively get at some specific variable. Regards, Vio
This is a python question, in the future please ask this kind of question in a python list.
def manage_addFoo(self, id, title, REQUEST=None): A_folder = getattr(base_folder,someID)
def manage_addBar(self, id, REQUEST=None): manage_addFoo.A_folder._setObject(id, BarObject)
Use this. The variable belongs to the object, not the method. def manage_addFoo(self, id, title, REQUEST=None): self.A_folder = getattr(base_folder,someID) def manage_addBar(self, id, REQUEST=None): self.A_folder._setObject(id, BarObject) Florent Guillaume Nuxeo
participants (2)
-
Florent Guillaume -
vio