Re: [Zope] Something missing in Python Methods
From: Curtis Maloney <[EMAIL PROTECTED]> > What I want to know is, why can't Python Methods refer to anything not > explicitly passed to them? I don't want to have to make everything that > invokes the method have to know to pass it half a dozen objects. > > Isn't the idea of a method to be executed in the namespace of it's parent? I > want my method to be able to access objects in it's own folder... Yep. You just need to make the first parameter of your method 'self', and not have any parameters with default values. For example, method plusX:: self, x return len(self.objectIds()) + x ...can be called like 'folder.plusX(3)'. You can also acquire objects that your method needs from 'self'. Cheers, Evan @ digicool & 4-am ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] Something missing in Python Methods
Hi, Curtis... You're right for the word "method"... But that's in fact why they are not called "methods" anymore ! :-)) Don't blame Python Script team : it's a non-trivial problem, both for security and... feasibility reasons ! I don't know wether it actually works for Python Methods, but you should try to pass your environment, just as you would for DTML Methods, like this : And then you should gain access to Zope environment. But remember this is not elegant and may lead you to security problems. Regards, P.-J. Curtis Maloney wrote: > > Greetings > > Yeh, yeh.. I know.. I should be using Python Scripts, or whatever... but for > various reasons, I'm still using 2.1.6... > > What I want to know is, why can't Python Methods refer to anything not > explicitly passed to them? I don't want to have to make everything that > invokes the method have to know to pass it half a dozen objects. > > Isn't the idea of a method to be executed in the namespace of it's parent? I > want my method to be able to access objects in it's own folder... > > What am I missing? > > Curtis > > ___ > Zope maillist - [EMAIL PROTECTED] > 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 ) -- If the only tool you have is a hammer, you tend to see every problem as a nail. Si le seul outil dont vous disposez est un marteau, vous avez tendance à voir chaque problème comme un clou. --Abraham Maslow ___ Zope maillist - [EMAIL PROTECTED] 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 )
[Zope] Something missing in Python Methods
Greetings Yeh, yeh.. I know.. I should be using Python Scripts, or whatever... but for various reasons, I'm still using 2.1.6... What I want to know is, why can't Python Methods refer to anything not explicitly passed to them? I don't want to have to make everything that invokes the method have to know to pass it half a dozen objects. Isn't the idea of a method to be executed in the namespace of it's parent? I want my method to be able to access objects in it's own folder... What am I missing? Curtis ___ Zope maillist - [EMAIL PROTECTED] 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 )