How to check with ZOPE/Python if file "x.html" exists in path container.REQUEST.PARENTS[0].getPhysicalPath()?
I simply want to check in a ZOPE/Python script, whether the file "x.html" exists at the exact path defined by container.REQUEST.PARENTS[0].getPhysicalPath(). And I want to make sure that ZOPE does NO TRAVERSAL, i.e. does not look in folders above the given path in case the file was not found. The statement path = container.REQUEST.PARENTS[0].getPhysicalPath() returns correctly something like: path = "('', 'silva', 'kom', 'web', 'topic1', 'subtopic1a')" The Python script "checkFile.py" to check for the file will reside at /silva/kom/checkFile.py and is called from a tal:define="fileExists python:here.checkFile('x.html'))" in /silva/kom/web/main.html. Any idea how I can do that? Thanks for your answers. Regards, Thomas
Thomas Duebendorfer writes:
I simply want to check in a ZOPE/Python script, whether the file "x.html" exists at the exact path defined by container.REQUEST.PARENTS[0].getPhysicalPath(). And I want to make sure that ZOPE does NO TRAVERSAL, i.e. does not look in folders above the given path in case the file was not found. Please search the mailing list archives for "aq_base".
Dieter
On Wed, 4 Dec 2002, Dieter Maurer wrote:
Thomas Duebendorfer writes:
I simply want to check in a ZOPE/Python script, whether the file "x.html" exists at the exact path defined by container.REQUEST.PARENTS[0].getPhysicalPath(). And I want to make sure that ZOPE does NO TRAVERSAL, i.e. does not look in folders above the given path in case the file was not found. Please search the mailing list archives for "aq_base".
Dieter
I found a the following solution: myfile = 'x.html' if(hasattr(container.REQUEST.PARENTS[0].aq_explicit, myfile)): # file exists (no traversal) else: # file does not exist (no traversal) (Note: .aq_base did not work) Regards, Thomas
This also works: if myfile in container.REQUEST.PARENTS[0].aq_explicit.objectIds(): # file exists (no traversal) else: # file does not exist (no traversal) hth Phil On Thu, 5 Dec 2002 10:53:38 +0100 (CET) Thomas Duebendorfer <duebendorfer@tik.ee.ethz.ch> wrote:
On Wed, 4 Dec 2002, Dieter Maurer wrote:
Thomas Duebendorfer writes:
I simply want to check in a ZOPE/Python script, whether the file "x.html" exists at the exact path defined by container.REQUEST.PARENTS[0].getPhysicalPath(). And I want to make sure that ZOPE does NO TRAVERSAL, i.e. does not look in folders above the given path in case the file was not found. Please search the mailing list archives for "aq_base".
Dieter
I found a the following solution:
myfile = 'x.html'
if(hasattr(container.REQUEST.PARENTS[0].aq_explicit, myfile)): # file exists (no traversal) else: # file does not exist (no traversal)
(Note: .aq_base did not work)
Regards,
Thomas
_______________________________________________ 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 )
participants (3)
-
Dieter Maurer -
Phil Harris -
Thomas Duebendorfer