Re: [Zope] External Methods newbie question
Alric Aneron schrieb: Hello, I see I can only execute python functions in external methods. Is there any way to execute the whole file, not just a certain function? In linux I created a python script, and it doesn't have functions. I just want to execute the whole file. I tried using self or init for function names in Zope and it doesn't want to do it, telling me The specified object, /init/, was not found in module, /test/. Is there a way to execute a file? Yes, you can use os.popen* for example - but what is the point? You would waste memory and CPU cycles in firing another complete interpreter environment. Instead move the commands in the file into a function, use the common pattern: def main(): foo.. bar... if __name__=='__main__': main() As you see in many modules. This was you just import the file as module in your external method and call yourmodule.main() (another question: is there a way to execute bash commands in linux? or is external methods only good for python?) What are bash commands? Builtin commands like if, fi, while, case etc? Or do you mean just external executables (binaries, scripts)? And if so, what are they fore? Python is very capable and you can do most with it as easy/easier then with extra commands. If not, see above for os.popen and friends. Regards Tino ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] External Methods newbie question
Hello,I see I can only execute python functions in external methods. Is there any way to execute the whole file, not just a certain function? In linux I created a python script, and it doesn't have functions. I just want to execute the whole file. I tried using "self" or "init" for function names in Zope and it doesn't want to do it, telling me "The specified object, init, was not found in module, test."Is there a way to execute a file?(another question: is there a way to execute bash commands in linux? or is external methods only good for python?)Thanks in advance guys!! Yahoo! Mail Use Photomail to share photos without annoying attachments.___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] External Methods newbie question
--On 28. Februar 2006 17:14:50 -0800 Alric Aneron [EMAIL PROTECTED] wrote: Hello, I see I can only execute python functions in external methods. Is there any way to execute the whole file, not just a certain function? In linux I created a python script, and it doesn't have functions. I just want to execute the whole file. I tried using self or init for function names in Zope and it doesn't want to do it, telling me The specified object, init, was not found in module, test. Is there a way to execute a file? This is basically a Pyhthon question. Look at os.system(), the subprocess module, popenX callsthe Python Library Reference is your friend. -aj pgpIA6YvPZudO.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] External Methods newbie question
I don't understand your question regarding 'execute the whole file'? Why can't you just put all of the python commands you want into an external method, then use a single 'main-line function' to call the 'sub-functions' as needed? python has a command called 'commands' which can be used for executing bash commands. hth Jonathan - Original Message - From: Alric Aneron To: zope@zope.org Sent: Tuesday, February 28, 2006 8:14 PM Subject: [Zope] External Methods newbie question Hello,I see I can only execute python functions in external methods. Is there any way to execute the whole file, not just a certain function? In linux I created a python script, and it doesn't have functions. I just want to execute the whole file. I tried using "self" or "init" for function names in Zope and it doesn't want to do it, telling me "The specified object, init, was not found in module, test."Is there a way to execute a file?(another question: is there a way to execute bash commands in linux? or is external methods only good for python?)Thanks in advance guys!! Yahoo! MailUse Photomail to share photos without annoying attachments. ___Zope maillist - Zope@zope.orghttp://mail.zope.org/mailman/listinfo/zope** No cross posts or HTML encoding! **(Related lists - http://mail.zope.org/mailman/listinfo/zope-announcehttp://mail.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] External Methods newbie question
--On 28. Februar 2006 20:26:13 -0500 Jonathan [EMAIL PROTECTED] wrote: python has a command called 'commands' which can be used for executing bash commands. talk about modules, not commands. -aj pgpBHzYiv1PtN.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] External Methods newbie question
thanks guys, I'll tryAndreas Jung [EMAIL PROTECTED] wrote: --On 28. Februar 2006 20:26:13 -0500 Jonathan <[EMAIL PROTECTED]> wrote: python has a command called 'commands' which can be used for executing bash commands.talk about modules, not commands.-aj Yahoo! Mail Bring photos to life! New PhotoMail makes sharing a breeze. ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] External Methods newbie question
To executed a whole file you need to wrap it as a function -- def foo( self ): the script and call foo as an external method. The self argument gives the context. Python provides several modules which give access to execute bash commands, linux commands, etc. Look at the modules subprocess and commands. On Tue, 28 Feb 2006, Alric Aneron wrote: Hello, I see I can only execute python functions in external methods. Is there any way to execute the whole file, not just a certain function? In linux I created a python script, and it doesn't have functions. I just want to execute the whole file. I tried using self or init for function names in Zope and it doesn't want to do it, telling me The specified object, init, was not found in module, test. Is there a way to execute a file? (another question: is there a way to execute bash commands in linux? or is external methods only good for python?) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )