Hello, I have a problem I don't know how to solve. I am about to create some SMIL-files on my RealServer. We are using Zope as an interface to our Media Portal. We have a database with all attributes in needed to create a SMIL file. Now I would like to - when a submit button is hitted - that a DTML method is called. This method should create a new file with some specifik data in. Now how do I do this ? I have installed the LocalFS but I can't see how this products writes files, except that it uploads them. I don't need to display an upload form - just write a file directly. Regards, Gitte
On 23 Apr 2001 16:54:53 +0200, Gitte Wange wrote:
Hello,
I have a problem I don't know how to solve. I am about to create some SMIL-files on my RealServer. We are using Zope as an interface to our Media Portal. We have a database with all attributes in needed to create a SMIL file. Now I would like to - when a submit button is hitted - that a DTML method is called. This method should create a new file with some specifik data in. Now how do I do this ?
I have installed the LocalFS but I can't see how this products writes files, except that it uploads them. I don't need to display an upload form - just write a file directly.
Regards, Gitte
Okay maybe I didn't express myself very clear. Can anyone tell me how I - in somw way - create a file on the server through Zope ? Regards, Gitte
Gitte Wange wrote:
Okay maybe I didn't express myself very clear. Can anyone tell me how I - in somw way - create a file on the server through Zope ?
On the filesystem? LocalFS might be right, read the documentation for it (it can eb a bit tricky to find the useful bits from what I remember ;-) Failing that, use an external method: def write_stuff(self,path,stuff): f = open(path,'w') f.write(stuff) f.close() cheers, Chris
On 24 Apr 2001 12:31:08 +0100, Chris Withers wrote:
Gitte Wange wrote:
Okay maybe I didn't express myself very clear. Can anyone tell me how I - in somw way - create a file on the server through Zope ?
On the filesystem? LocalFS might be right, read the documentation for it (it can eb a bit tricky to find the useful bits from what I remember ;-)
Failing that, use an external method:
def write_stuff(self,path,stuff): f = open(path,'w') f.write(stuff) f.close()
cheers,
Chris
I have tried the following: I added a script(Python): argument list: server, mediafile, tcin, tcout, id, clipname The code looks like this: fil = open("/root/Real/Content/" + id + clipname + ".smil", 'w') #Open file text = "<smil>\n\t<body>\n\t\t<audio src=\"rtps://" + server + "/" + mediafile + " clip-begin=\"" + tcin + "\" clip-end=\"" + tcout + "\">\n\t</body>\n\n</smil>" fil.write(text) fil.close() Now when running this script I get a NameError on "open". What is wrong ? Regards, Gitte
Gitte Wange wrote:
Now when running this script I get a NameError on "open". What is wrong ?
Read the "Using External Methods" bit of: http://www.zope.org/Members/michel/ZB/ScriptingZope.dtml cheers, Chris
On 24 Apr 2001 13:21:08 +0100, Chris Withers wrote:
Gitte Wange wrote:
Now when running this script I get a NameError on "open". What is wrong ?
Read the "Using External Methods" bit of:
http://www.zope.org/Members/michel/ZB/ScriptingZope.dtml
cheers,
Chris
What do I put in the "Function Name" field? I have nothing like "def" in my script ... Gitte
Remember, the '\' is an escape character in Python. You need to double it when you embed it in a string, like so: filename='c:\\temp\\testfile.txt' Or you can use the raw string syntax: filename=r'c:\temp\testfile.txt' I don't know if a Zope Python script supports the raw syntax, but I doubt if it will let you write a file to the filesystem. An external method is no doubt what you want. Cheers, Tom P Gitte Wange asked -
I have tried the following: I added a script(Python): argument list: server, mediafile, tcin, tcout, id, clipname
The code looks like this: fil = open("/root/Real/Content/" + id + clipname + ".smil", 'w') #Open file text = "<smil>\n\t<body>\n\t\t<audio src=\"rtps://" + server + "/" + mediafile + " clip-begin=\"" + tcin + "\" clip-end=\"" + tcout + "\">\n\t</body>\n\n</smil>" fil.write(text) fil.close()
Now when running this script I get a NameError on "open". What is wrong ?
Wouldn't you want to use os.path.join() to retain OS-independence?? e.g. filename = os.path.join('c:\\', 'temp', 'testfile.txt')
From: "Thomas B. Passin" <tpassin@mitretek.org> Date: Tue, 24 Apr 2001 10:48:19 -0400 To: <zope@zope.org> Subject: Re: [Zope] Creating files on server
Remember, the '\' is an escape character in Python. You need to double it when you embed it in a string, like so:
filename='c:\\temp\\testfile.txt'
Or you can use the raw string syntax:
filename=r'c:\temp\testfile.txt'
I don't know if a Zope Python script supports the raw syntax, but I doubt if it will let you write a file to the filesystem. An external method is no doubt what you want.
Cheers,
Tom P
Probably, but the original example used a backslash and I wanted to point out that it can have special properties. You'd usually want to use relative paths, anyway, instead of things like "c:\". Cheers, Tom P marc lindahl wrote -
Wouldn't you want to use os.path.join() to retain OS-independence?? e.g. filename = os.path.join('c:\\', 'temp', 'testfile.txt')
From: "Thomas B. Passin" <tpassin@mitretek.org>
Remember, the '\' is an escape character in Python. You need to double it when you embed it in a string, like so:
filename='c:\\temp\\testfile.txt'
Or you can use the raw string syntax:
filename=r'c:\temp\testfile.txt'
I don't know if a Zope Python script supports the raw syntax, but I doubt if it will let you write a file to the filesystem. An external method is no doubt what you want.
Hi Gitte, the built in "open()" is a high security risk and therefore not exposed to pythonmethods. For this you should stick to Chris' solution with external method. However keep sure your script cannot be tricked to write files anywhere on the filesystem! Dont use + to concenat pathname parts. Use os.path.join() instead. Try os.path.split(os.path.normpath(os.path.join(part,of,your,pathname))) to see the result of the concenation and if its still in the directory you want it to be. (someone could feed '../../name' into your script) HTH Tino --On Dienstag, 24. April 2001 13:48 +0200 Gitte Wange <gitte@mmmanager.org> wrote:
On 24 Apr 2001 12:31:08 +0100, Chris Withers wrote:
Gitte Wange wrote:
Okay maybe I didn't express myself very clear. Can anyone tell me how I - in somw way - create a file on the server through Zope ?
On the filesystem? LocalFS might be right, read the documentation for it (it can eb a bit tricky to find the useful bits from what I remember ;-)
Failing that, use an external method:
def write_stuff(self,path,stuff): f = open(path,'w') f.write(stuff) f.close()
cheers,
Chris
I have tried the following: I added a script(Python): argument list: server, mediafile, tcin, tcout, id, clipname
The code looks like this: fil = open("/root/Real/Content/" + id + clipname + ".smil", 'w') #Open file text = "<smil>\n\t<body>\n\t\t<audio src=\"rtps://" + server + "/" + mediafile + " clip-begin=\"" + tcin + "\" clip-end=\"" + tcout + "\">\n\t</body>\n\n</smil>" fil.write(text) fil.close()
Now when running this script I get a NameError on "open". What is wrong ?
Regards, Gitte
_______________________________________________ Zope maillist - Zope@zope.org 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 )
Yes, it's a good idea to ALWAYS compute your file names instead of letting a user pass in a name (and perhaps a path) that you just accept. Either strip down to the filename and generate your own path, or generate the complete path and name yourself. Cheers, Tom P Tino Wildenhain wrote -
... Dont use + to concenat pathname parts. Use os.path.join() instead. Try os.path.split(os.path.normpath(os.path.join(part,of,your,pathname))) to see the result of the concenation and if its still in the directory you want it to be. (someone could feed '../../name' into your script)
Hi again, For secure reasons I have dropped the idea of creating a physical file on the server. Instead I can create the files dynamically inside Zope and link to the method. I have a method called fncSmileGenerate.smil I call this from another method. Now when doing this I get the following NameError: Error Type: NameError Error Value: fncSmileGenerate The traceback is this: Traceback (innermost last): File /usr/local/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /usr/local/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/Zope-2.3.0-linux2-x86/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/local/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: index_html) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: index_html) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/OFS/DTMLMethod.py, line 189, in __call__ (Object: index_html) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_String.py, line 538, in __call__ (Object: index_html) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_With.py, line 146, in render (Object: portal_properties) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_With.py, line 146, in render (Object: admin) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/OFS/DTMLDocument.py, line 182, in __call__ (Object: index) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_String.py, line 538, in __call__ (Object: index) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/OFS/DTMLMethod.py, line 182, in __call__ (Object: dspDisplayShow) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_String.py, line 538, in __call__ (Object: dspDisplayShow) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_In.py, line 713, in renderwob (Object: sqlGetShowClips(showid=showid)) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_Util.py, line 334, in eval (Object: fncSmileGenerate.smil(clipid=clipid)) (Info: fncSmileGenerate) File <string>, line 0, in ? NameError: (see above) It seems to me that Zope won't recognize the .smil extension. Is it possible in any way to make it do so ? I need the extension because of RealServer. Regards, Gitte On 24 Apr 2001 18:27:00 +0200, Tino Wildenhain wrote:
Hi Gitte,
the built in "open()" is a high security risk and therefore not exposed to pythonmethods. For this you should stick to Chris' solution with external method. However keep sure your script cannot be tricked to write files anywhere on the filesystem! Dont use + to concenat pathname parts. Use os.path.join() instead. Try os.path.split(os.path.normpath(os.path.join(part,of,your,pathname))) to see the result of the concenation and if its still in the directory you want it to be. (someone could feed '../../name' into your script)
HTH Tino
--On Dienstag, 24. April 2001 13:48 +0200 Gitte Wange <gitte@mmmanager.org> wrote:
On 24 Apr 2001 12:31:08 +0100, Chris Withers wrote:
Gitte Wange wrote:
Okay maybe I didn't express myself very clear. Can anyone tell me how I - in somw way - create a file on the server through Zope ?
On the filesystem? LocalFS might be right, read the documentation for it (it can eb a bit tricky to find the useful bits from what I remember ;-)
Failing that, use an external method:
def write_stuff(self,path,stuff): f = open(path,'w') f.write(stuff) f.close()
cheers,
Chris
I have tried the following: I added a script(Python): argument list: server, mediafile, tcin, tcout, id, clipname
The code looks like this: fil = open("/root/Real/Content/" + id + clipname + ".smil", 'w') #Open file text = "<smil>\n\t<body>\n\t\t<audio src=\"rtps://" + server + "/" + mediafile + " clip-begin=\"" + tcin + "\" clip-end=\"" + tcout + "\">\n\t</body>\n\n</smil>" fil.write(text) fil.close()
Now when running this script I get a NameError on "open". What is wrong ?
Regards, Gitte
_______________________________________________ Zope maillist - Zope@zope.org 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 )
Hi Gitte, are you sure, the extension .smil is really needed? Setting the mime-type in return should be sufficient: <dtml-call "RESPONSE.setHeader('application/smilwhatever')"> of course you have to know how the mime-type is called actually ;) Can you explain in short what you really want to do? Do you link to a page which should serve the smil-file? Then you have something like <a href="/where/you/did/your/smilgenerator_put.smil"> eventually with several url-encoded parameters after it. HTH Tino Wildenhain --On Mittwoch, 25. April 2001 11:02 +0200 Gitte Wange <gitte@babytux.dk> wrote:
Hi again,
For secure reasons I have dropped the idea of creating a physical file on the server. Instead I can create the files dynamically inside Zope and link to the method.
I have a method called fncSmileGenerate.smil
I call this from another method. Now when doing this I get the following NameError:
Error Type: NameError Error Value: fncSmileGenerate
The traceback is this: Traceback (innermost last): File /usr/local/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /usr/local/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/Zope-2.3.0-linux2-x86/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/local/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: index_html) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: index_html) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/OFS/DTMLMethod.py, line 189, in __call__ (Object: index_html) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_String.py , line 538, in __call__ (Object: index_html) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_With.py, line 146, in render (Object: portal_properties) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_With.py, line 146, in render (Object: admin) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/OFS/DTMLDocument.py, line 182, in __call__ (Object: index) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_String.py , line 538, in __call__ (Object: index) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/OFS/DTMLMethod.py, line 182, in __call__ (Object: dspDisplayShow) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_String.py , line 538, in __call__ (Object: dspDisplayShow) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_In.py, line 713, in renderwob (Object: sqlGetShowClips(showid=showid)) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_Util.py, line 334, in eval (Object: fncSmileGenerate.smil(clipid=clipid)) (Info: fncSmileGenerate) File <string>, line 0, in ? NameError: (see above)
It seems to me that Zope won't recognize the .smil extension. Is it possible in any way to make it do so ? I need the extension because of RealServer.
Regards, Gitte
On 24 Apr 2001 18:27:00 +0200, Tino Wildenhain wrote:
Hi Gitte,
the built in "open()" is a high security risk and therefore not exposed to pythonmethods. For this you should stick to Chris' solution with external method. However keep sure your script cannot be tricked to write files anywhere on the filesystem! Dont use + to concenat pathname parts. Use os.path.join() instead. Try os.path.split(os.path.normpath(os.path.join(part,of,your,pathname))) to see the result of the concenation and if its still in the directory you want it to be. (someone could feed '../../name' into your script)
HTH Tino
--On Dienstag, 24. April 2001 13:48 +0200 Gitte Wange <gitte@mmmanager.org> wrote:
On 24 Apr 2001 12:31:08 +0100, Chris Withers wrote:
Gitte Wange wrote:
Okay maybe I didn't express myself very clear. Can anyone tell me how I - in somw way - create a file on the server through Zope ?
On the filesystem? LocalFS might be right, read the documentation for it (it can eb a bit tricky to find the useful bits from what I remember ;-)
Failing that, use an external method:
def write_stuff(self,path,stuff): f = open(path,'w') f.write(stuff) f.close()
cheers,
Chris
I have tried the following: I added a script(Python): argument list: server, mediafile, tcin, tcout, id, clipname
The code looks like this: fil = open("/root/Real/Content/" + id + clipname + ".smil", 'w') #Open file text = "<smil>\n\t<body>\n\t\t<audio src=\"rtps://" + server + "/" + mediafile + " clip-begin=\"" + tcin + "\" clip-end=\"" + tcout + "\">\n\t</body>\n\n</smil>" fil.write(text) fil.close()
Now when running this script I get a NameError on "open". What is wrong ?
Regards, Gitte
_______________________________________________ Zope maillist - Zope@zope.org 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 )
On 25 Apr 2001 15:49:19 +0200, Tino Wildenhain wrote:
Hi Gitte,
are you sure, the extension .smil is really needed? Setting the mime-type in return should be sufficient:
<dtml-call "RESPONSE.setHeader('application/smilwhatever')">
of course you have to know how the mime-type is called actually ;)
Can you explain in short what you really want to do? Do you link to a page which should serve the smil-file? Then you have something like <a href="/where/you/did/your/smilgenerator_put.smil">
eventually with several url-encoded parameters after it.
HTH Tino Wildenhain
[SNIP a lot of text] Hello again, Okay here is exactly what I need to do: When streaming mediafiles through a RealServer, you can (instead of linking directly to the mediafile) link to a SMIL-file. SMIL is a markup language just as HTML, DTML etc. This SMIL-file contains the description (or receipie) for how RealServer should play your mediafile (e.g. clip-length etc.) ... In order to make the RealServer recognize the SMIL-file, it needs to have an extension of .smil (or .smi). I have these shows (containing a lot of clips from a mediafile) that I need to play. So I want to create a bunch of SMIL files (one for the complete show and one for each clip). When first displaying the show, the player must start by playing the show-SMIL-file. Then you can hit each clip and the player will play these clips SMIL-files. I have - maybe - found a solution for my problem. I have made a DTML-method called SmilGenerator (no extension). This is called with a clipid. Then you find all the clips data in the database from the id. And the you call manage.addDTMLDocument(docid,doctitlle,smilfile.smil) But I have som problems here. I need to pass some variables from the database result to this new SMIL-file but how ? I have tried with <dtml-let> and it worked - sort of. The big problem is that the first line in the SmilGenerator method is <dtml-in expr="sqlGetClipData(clipid=clipid)"> but I get a NameError here because Zope says it can't find the sqlGetClipData query. It is in the same directory as the method that calls the SmilGenerator is .... weird ? So if you have any hints, good ideas ... anything .. your are most welcome to post them to me. Regards, Gitte
On 25 Apr 2001 15:49:19 +0200, Tino Wildenhain wrote:
Hi Gitte,
are you sure, the extension .smil is really needed?
Yes - if the RealServer should recognize the file.
Setting the mime-type in return should be sufficient:
<dtml-call "RESPONSE.setHeader('application/smilwhatever')">
of course you have to know how the mime-type is called actually ;)
And I don't :-) Perhaps I could find it ... but then wherer should I change the header ?
Can you explain in short what you really want to do? Do you link to a page which should serve the smil-file? Then you have something like <a href="/where/you/did/your/smilgenerator_put.smil">
No ... I put a link on a page to the smil-file ... and when you click the link the content of the smil-file is being played in a RealPlayer
eventually with several url-encoded parameters after it.
HTH Tino Wildenhain
Regards, Gitte
--On Mittwoch, 25. April 2001 11:02 +0200 Gitte Wange <gitte@babytux.dk> wrote:
Hi again,
For secure reasons I have dropped the idea of creating a physical file on the server. Instead I can create the files dynamically inside Zope and link to the method.
I have a method called fncSmileGenerate.smil
I call this from another method. Now when doing this I get the following NameError:
Error Type: NameError Error Value: fncSmileGenerate
The traceback is this: Traceback (innermost last): File /usr/local/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /usr/local/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/Zope-2.3.0-linux2-x86/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/local/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: index_html) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: index_html) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/OFS/DTMLMethod.py, line 189, in __call__ (Object: index_html) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_String.py , line 538, in __call__ (Object: index_html) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_With.py, line 146, in render (Object: portal_properties) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_With.py, line 146, in render (Object: admin) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/OFS/DTMLDocument.py, line 182, in __call__ (Object: index) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_String.py , line 538, in __call__ (Object: index) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/OFS/DTMLMethod.py, line 182, in __call__ (Object: dspDisplayShow) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_String.py , line 538, in __call__ (Object: dspDisplayShow) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_In.py, line 713, in renderwob (Object: sqlGetShowClips(showid=showid)) File /usr/local/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_Util.py, line 334, in eval (Object: fncSmileGenerate.smil(clipid=clipid)) (Info: fncSmileGenerate) File <string>, line 0, in ? NameError: (see above)
It seems to me that Zope won't recognize the .smil extension. Is it possible in any way to make it do so ? I need the extension because of RealServer.
Regards, Gitte
On 24 Apr 2001 18:27:00 +0200, Tino Wildenhain wrote:
Hi Gitte,
the built in "open()" is a high security risk and therefore not exposed to pythonmethods. For this you should stick to Chris' solution with external method. However keep sure your script cannot be tricked to write files anywhere on the filesystem! Dont use + to concenat pathname parts. Use os.path.join() instead. Try os.path.split(os.path.normpath(os.path.join(part,of,your,pathname))) to see the result of the concenation and if its still in the directory you want it to be. (someone could feed '../../name' into your script)
HTH Tino
--On Dienstag, 24. April 2001 13:48 +0200 Gitte Wange <gitte@mmmanager.org> wrote:
On 24 Apr 2001 12:31:08 +0100, Chris Withers wrote:
Gitte Wange wrote:
Okay maybe I didn't express myself very clear. Can anyone tell me how I - in somw way - create a file on the server through Zope ?
On the filesystem? LocalFS might be right, read the documentation for it (it can eb a bit tricky to find the useful bits from what I remember ;-)
Failing that, use an external method:
def write_stuff(self,path,stuff): f = open(path,'w') f.write(stuff) f.close()
cheers,
Chris
I have tried the following: I added a script(Python): argument list: server, mediafile, tcin, tcout, id, clipname
The code looks like this: fil = open("/root/Real/Content/" + id + clipname + ".smil", 'w') #Open file text = "<smil>\n\t<body>\n\t\t<audio src=\"rtps://" + server + "/" + mediafile + " clip-begin=\"" + tcin + "\" clip-end=\"" + tcout + "\">\n\t</body>\n\n</smil>" fil.write(text) fil.close()
Now when running this script I get a NameError on "open". What is wrong ?
Regards, Gitte
_______________________________________________ Zope maillist - Zope@zope.org 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 maillist - Zope@zope.org 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 )
Hi Gitte, --On Donnerstag, 26. April 2001 09:20 +0200 Gitte Wange <gitte@mmmanager.org> wrote:
On 25 Apr 2001 15:49:19 +0200, Tino Wildenhain wrote:
Hi Gitte,
are you sure, the extension .smil is really needed?
Yes - if the RealServer should recognize the file.
Is it really the RealServer who reads the file? I would rather think of the browser reading the file. It looks like the whole proccess works this way: You have a link in a html-page, this page may or may not be dynamically generated. This link or object-embedding directs to the smil-resource, which is also handled by zope and generated on the fly or whatever. In this resource there must be a reference to the RealMedia server itself. Since the first reference inside the html-page is only a text string, it can read anything, of course also a URL with .smil extension. The browser usually looks for the mime-type unless broken (the Internet-Explorer is usually broken and looks on the extension rather then the mime-type). Anyway, your smil-file generating object is only called by URL, not by object-reference. So the identifier is not critical. http://yourhost/yourpath/smilgenerator.smil?whatever=needs_to_be_transfered _to_the_script In opposition to the fact calling an zope-object in zope-context: (here with dtml: ) <dtml-var smilgenerator.smil> or <dtml-var "_.['smilgenerator.smil'](_.None,_,whatever='needs_to_be_transfered_to_the_ script')"> Which would obvously render the object inside another object, mixing the output. The extension does not make any sense in this setup. HTH Tino Wildenhain
Hi,
Failing that, use an external method:
def write_stuff(self,path,stuff): f = open(path,'w') f.write(stuff) f.close()
cheers,
I would recommend to have a closer look what is to be written where. May be the path and the name of the file could be hard-coded or at least filtered. Otherwise there is a very big security hole! Regards Tino
hi gitte, you can write a python script, save it in the extensions directory, then create an external method with the name of the python program. the program will take the input and write it out. if you want files to write to different places on disk you can pass variables to the script to have it parse the file. the from your dtml method, you will make the call to the external method and pass the values that the program will need. ciao! greg. Gregory Haley DBA/Web Programmer Venaca, LLC.
Okay maybe I didn't express myself very clear. Can anyone tell me how I - in somw way - create a file on the server through Zope ?
Regards, Gitte
On 24 Apr 2001 07:56:56 -0400, ghaley@mail.venaca.com wrote:
hi gitte,
you can write a python script, save it in the extensions directory, then create an external method with the name of the python program. the program will take the input and write it out. if you want files to write to different places on disk you can pass variables to the script to have it parse the file. the from your dtml method, you will make the call to the external method and pass the values that the program will need.
ciao! greg.
Gregory Haley DBA/Web Programmer Venaca, LLC.
Sorry I don't get this ... If I put the code into a file and name ie.g. myscript.py and then create an external method in my folder and in a dtml-call calls the external method this will call the script in the extension folder ? Okay .. but can you then help me with putting the output file the right place ?
Gitte Wange asked -
Okay maybe I didn't express myself very clear. Can anyone tell me how I - in somw way - create a file on the server through Zope ?
I use an external method. You can get a python module to disclose its absolute path, so you can locate your files relative to the script. (Of course, you could use a hard-coded absolute path, but that's not so desirable except for testing). The idea is that the script in the Extensions directory that is hooked to the external method should not do anything else but call the script you really want to run, which is located in some convenient place. Of course, you have to get that script into your pythonpath, using one of the ways that has been discussed on the list in the last few days. Cheers, Tom P
participants (7)
-
Chris Withers -
ghaley@mail.venaca.com -
Gitte Wange -
Gitte Wange -
marc lindahl -
Thomas B. Passin -
Tino Wildenhain