Write the time to a text file
Hello, from a python script I want to write a new line containing the current time to a text file. The textfile is contained in the ZODB. How can I do that? Thx, Florian
Florian Lindner wrote at 2003-10-28 19:44 +0100:
from a python script I want to write a new line containing the current time to a text file. The textfile is contained in the ZODB. How can I do that?
Use an "External Method". While it would be possible to make the built in "open" available to PythonScripts (you would read "README.txt" in "PythonScripts" for this -- an FAQ -- even you yourself were already pointed to it), it woule be a *really* bad idea. -- Dieter
. I've developed a fair number of external python scripts - all of which are located in the Zope\Extensions directory (thats the protocal). Of course when the number of scripts becomes large the directory becomes crowded. I would like to include the ability to add *addional* directories that would be searched when an external script is called. For examaple, the start script could have a new paramater EXTERNAL=Extensions;extern1;extern2;etc Does this sound like something that is implementable? Does it even sound like a good idea? Thanks for any thoughts, David
Of course when the number of scripts becomes large the directory becomes crowded.
I would like to include the ability to add *addional* directories that would be searched when an external script is called. For examaple, the start script could have a new paramater EXTERNAL=Extensions;extern1;extern2;etc
Does this sound like something that is implementable? Does it even sound like a good idea?
IMHO if your Extensions directory gets too crowded you should consider writing real file system python products instead of hacking on a maze of scriptlets. jens
Depending upon how you set things up, there can be multiple Extension directories. I have found that it works well to group Extensions into a single file and then provide multiple entry points into the file using the External Method specification. And it's but a short step from that to making an actual product. On Sat, 1 Nov 2003, David Hassalevris wrote:
. I've developed a fair number of external python scripts - all of which are located in the Zope\Extensions directory (thats the protocal).
Of course when the number of scripts becomes large the directory becomes crowded.
I would like to include the ability to add *addional* directories that would be searched when an external script is called. For examaple, the start script could have a new paramater EXTERNAL=Extensions;extern1;extern2;etc
Does this sound like something that is implementable? Does it even sound like a good idea?
Dennis, Great idea! thx ----- Original Message ----- From: "Dennis Allison" <allison@sumeru.stanford.EDU> To: "David Hassalevris" <bluepaul@earthlink.net> Cc: <zope@zope.org> Sent: Saturday, November 01, 2003 9:16 PM Subject: Re: [Zope] Mutliple "Extension" directories?
Depending upon how you set things up, there can be multiple Extension directories.
I have found that it works well to group Extensions into a single file and then provide multiple entry points into the file using the External Method specification. And it's but a short step from that to making an actual product.
On Sat, 1 Nov 2003, David Hassalevris wrote:
. I've developed a fair number of external python scripts - all of which
are
located in the Zope\Extensions directory (thats the protocal).
Of course when the number of scripts becomes large the directory becomes crowded.
I would like to include the ability to add *addional* directories that would be searched when an external script is called. For examaple, the start script could have a new paramater EXTERNAL=Extensions;extern1;extern2;etc
Does this sound like something that is implementable? Does it even sound like a good idea?
from a python script I want to write a new line containing the current time to a text file. The textfile is contained in the ZODB. How can I do that?
There's no such thing in the ZODB. But there are Files with the type text/plain. I can't get why, but if you really want to, the API for adding a file is in the online Zope help under Zope Help > API Reference
File
Take a look at the addEntry script in the GuestBook example. http://zope.org/Documentation/Books/ZopeBook/2_6Edition/SimpleExamples.stx You could also do something like http://www.zopelabs.com/cookbook/990792795 which fakes having a file. --jcc -- "My point and period will be throughly wrought, Or well or ill, as this day's battle's fought."
participants (6)
-
David Hassalevris -
Dennis Allison -
Dieter Maurer -
Florian Lindner -
J. Cameron Cooper -
Jens Vagelpohl