I cant understand this error when i click a link on my website

  • Thread starter Íßêïò Ãêñ33ê
  • Start date
Í

Íßêïò Ãêñ33ê

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

/home/nikos/public_html/cgi-bin/metrites.py in ()
12
13 htmlpage = form.getvalue('htmlpage')
14 if re.search( r'(.html|.py)', htmlpage ):
15 htmlpage = htmlpage.replace( '/home/nikos/public_html/', '' )
16 else:
re = <module 're' from '/usr/lib64/python2.6/re.pyc'>, re.search = <function search>, htmlpage = ['/home/nikos/public_html/index.html', 'pelatologio.py']
/usr/lib64/python2.6/re.py in search(pattern='(.html|.py)', string=['/home/nikos/public_html/index.html', 'pelatologio.py'], flags=0)
140 """Scan through string looking for a match to the pattern, returning
141 a match object, or None if no match was found."""
142 return _compile(pattern, flags).search(string)
143
144 def sub(pattern, repl, string, count=0):
global _compile = <function _compile>, pattern = '(.html|.py)', flags = 0, ).search undefined, string = ['/home/nikos/public_html/index.html', 'pelatologio.py']
<type 'exceptions.TypeError'>: expected string or buffer
args = ('expected string or buffer',)
message = 'expected string or buffer'
==============================

The code worksmy webpoage appear when i http://superhost.gr but whne i click a link on it for exmaple the 1st imaeg shown i get this error, and in evry link too.
 
C

Chris Angelico

15 htmlpage = htmlpage.replace( '/home/nikos/public_html/', '' )
re = <module 're' from '/usr/lib64/python2.6/re.pyc'>, re.search = <function search>, htmlpage = ['/home/nikos/public_html/index.html', 'pelatologio.py']
<type 'exceptions.TypeError'>: expected string or buffer

The regular expression functions expect a string (or a buffer), but
you're passing it a list.

Learning to read exception tracebacks is one of the important parts of
becoming a competent programmer.

ChrisA
 
Í

Íßêïò Ãêñ33ê

Ôç ÐáñáóêåõÞ, 8 Ìáñôßïõ 2013 6:46:35 ì.ì. UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
15 htmlpage = htmlpage.replace( '/home/nikos/public_html/', '' )
re = <module 're' from '/usr/lib64/python2.6/re.pyc'>, re.search = <function search>, htmlpage = ['/home/nikos/public_html/index.html', 'pelatologio.py']
<type 'exceptions.TypeError'>: expected string or buffer



The regular expression functions expect a string (or a buffer), but

you're passing it a list.



Learning to read exception tracebacks is one of the important parts of

becoming a competent programmer.



ChrisA

but that same exact code is executed withour errors when someone is http://superhost.gr

the erro is produces when he is requesting a link from that page...
 
Í

Íßêïò Ãêñ33ê

Ôç ÐáñáóêåõÞ, 8 Ìáñôßïõ 2013 6:46:35 ì.ì. UTC+2, ï ÷ñÞóôçò Chris Angelico Ýãñáøå:
15 htmlpage = htmlpage.replace( '/home/nikos/public_html/', '' )
re = <module 're' from '/usr/lib64/python2.6/re.pyc'>, re.search = <function search>, htmlpage = ['/home/nikos/public_html/index.html', 'pelatologio.py']
<type 'exceptions.TypeError'>: expected string or buffer



The regular expression functions expect a string (or a buffer), but

you're passing it a list.



Learning to read exception tracebacks is one of the important parts of

becoming a competent programmer.



ChrisA

but that same exact code is executed withour errors when someone is http://superhost.gr

the erro is produces when he is requesting a link from that page...
 
S

Sven

M

MRAB

On 8 March 2013 16:50, Îίκος ΓκÏ33κ <[email protected]



but that same exact code is executed withour errors when someone is
http://superhost.gr

the erro is produces when he is requesting a link from that page...
--


But with different arguments. It's
http://superhost.gr/?htmlpage=files.py http://superhost.gr/ and the
arguments to your regex are coming up as
"string=['/home/nikos/public_html/index.html', 'files.py']" which is
clearly a list of strings.
In the case of http://superhost.gr/ it's probably just a single string
The documentation for getvalue says """If the submitted form data contains
more than one field with the same name, the object retrieved by
form[key] is
not a FieldStorage or MiniFieldStorage instance but a list of such
instances.
Similarly, in this situation, form.getvalue(key) would return a list of
strings."""

This suggests that the webpage may in fact have 2 fields with the name
"htmlpage".
 
I

info

Ôç ÐáñáóêåõÞ, 8 Ìáñôßïõ 2013 7:04:29 ì.ì. UTC+2, ï ÷ñÞóôçò sven Ýãñáøå:
but that same exact code is executed withour errors when someone is http://superhost.gr



the erro is produces when he is requesting a link from that page...

--



But with different arguments. It's http://superhost.gr/?htmlpage=files.py  http://superhost.gr/ and the arguments to your regex are coming up as"string=['/home/nikos/public_html/index.html', 'files.py']" which is clearly a list of strings.

In the case of http://superhost.gr/ it's probably just a single string

Thanks i have fixed the problem just now after 3 hours!
 
I

info

Ôç ÐáñáóêåõÞ, 8 Ìáñôßïõ 2013 7:04:29 ì.ì. UTC+2, ï ÷ñÞóôçò sven Ýãñáøå:
but that same exact code is executed withour errors when someone is http://superhost.gr



the erro is produces when he is requesting a link from that page...

--



But with different arguments. It's http://superhost.gr/?htmlpage=files.py  http://superhost.gr/ and the arguments to your regex are coming up as"string=['/home/nikos/public_html/index.html', 'files.py']" which is clearly a list of strings.

In the case of http://superhost.gr/ it's probably just a single string

Thanks i have fixed the problem just now after 3 hours!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top