Forcing Python to detect DocumentRoot

Piet van Oostrum piet at vanoostrum.org
Sat Jan 19 21:01:15 CET 2013


Ferrous Cranus <nikos.gr33k at gmail.com> writes:

> This is addon domain's counter.py snippet tried to load an image mail.png and failed because it cant see past its document root
>
> ========================================
>     # render html template and print it
>     data = f.read()
>     counter = '''<center>
>                  <a href="mailto:support at superhost.gr"> <img src="/data/images/mail.png"> </a>
>                  
>                  <table border=2 cellpadding=2 bgcolor=black>
>                  <td><font color=lime> Αριθμός Επισκεπτών </td>
>                  <td><font color=cyan> %d </td>''' % hits[0]
> ========================================
>

> While from within the same counter.py file
>
> # open html template file
>     f = open( '/home/nikos/public_html/test.txt' )
>
> opens OK the page file which is also past addons domain's document root
>
> Can you help counter.py to load the image? Why does it fail to load it? Python can have access to ANY filesystempath , no matter from what folder counter.py script runs from. Correct?

That piece of code is not opening the image file. It just issues the URL
for the image file. The file will then be loaded by the browser in a new
request. The image should be at
/home/nikos/public_html/data/images/mail.png

P.S. I don't understand what you mean by "addon domain".

-- 
Piet van Oostrum <piet at vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]



More information about the Python-list mailing list