[Zope] Calling a dtml-method that has an extension (Was: Re: [Zope]
Creating files on server)
Gitte Wange
gitte@babytux.dk
25 Apr 2001 11:02:18 +0200
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 )
>
>
>