Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

cannot concatenate 'str' and 'list' objects

 

 

First page Previous page 1 2 Next page Last page  View All Python python RSS feed   Index | Next | Previous | View Threaded


nikos.gr33k at gmail

Sep 15, 2012, 5:22 AM

Post #1 of 44 (3104 views)
Permalink
cannot concatenate 'str' and 'list' objects

Hello,

I recently changed webhost and in the new one iam getting this error you can see if you visit http://superhost.gr when program execution reaches the line:

f = open( '../' + page )

In the previous host i wasn't getting this error.

page's contents is:

page = form.getvalue('page')
--
http://mail.python.org/mailman/listinfo/python-list


nikos.gr33k at gmail

Sep 15, 2012, 5:26 AM

Post #2 of 44 (3122 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

Sorry the problem appears when you try to input data botton down the page in the text area boxes and click submit.

this is the error apperaing:

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/counter.py in ()
56 # I would suggest using some kind of verification function to check that the value of 'page' is OK, before opening the file.
57
58 f = open( '../' + page )
59
60 # read first line of the file
f undefined, builtin open = <built-in function open>, page = ['index.html', 'index.html']
<type 'exceptions.TypeError'>: cannot concatenate 'str' and 'list' objects
args = ("cannot concatenate 'str' and 'list' objects",)
message = "cannot concatenate 'str' and 'list' objects"
--
http://mail.python.org/mailman/listinfo/python-list


rosuav at gmail

Sep 15, 2012, 5:33 AM

Post #3 of 44 (3067 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

On Sat, Sep 15, 2012 at 10:22 PM, <nikos.gr33k [at] gmail> wrote:
> Hello,
>
> I recently changed webhost and in the new one iam getting this error you can see if you visit http://superhost.gr when program execution reaches the line:
>
> f = open( '../' + page )
>
> In the previous host i wasn't getting this error.
>
> page's contents is:
>
> page = form.getvalue('page')

Well, clearly '../' is a string (str), and page must be a list. But
without knowing your web framework it's hard to be sure what's going
on.

My guess is that form.getvalue() is returning a list of form elements
with that name, so you have a list with one element in it. But check
your documentation to be sure.

Since this changed when you changed hosts, it may mean you now have a
completely different framework. Possibly you can configure this.
Alternatively, it may simply be a different version of the same
system. It's hard to know just based on this, though.

ChrisA
--
http://mail.python.org/mailman/listinfo/python-list


nikos.gr33k at gmail

Sep 15, 2012, 6:28 AM

Post #4 of 44 (3049 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

, 15 2012 3:34:34 .. UTC+3, Chris Angelico :
> On Sat, Sep 15, 2012 at 10:22 PM, <nikos.gr33k [at] gmail> wrote:
>
> > Hello,
>
> >
>
> > I recently changed webhost and in the new one iam getting this error you can see if you visit http://superhost.gr when program execution reaches the line:
>
> >
>
> > f = open( '../' + page )
>
> >
>
> > In the previous host i wasn't getting this error.
>
> >
>
> > page's contents is:
>
> >
>
> > page = form.getvalue('page')
>
>
>
> Well, clearly '../' is a string (str), and page must be a list. But
>
> without knowing your web framework it's hard to be sure what's going
>
> on.
>
>
>
> My guess is that form.getvalue() is returning a list of form elements
>
> with that name, so you have a list with one element in it. But check
>
> your documentation to be sure.
>
>
>
> Since this changed when you changed hosts, it may mean you now have a
>
> completely different framework. Possibly you can configure this.
>
> Alternatively, it may simply be a different version of the same
>
> system. It's hard to know just based on this, though.
>
>
>
> ChrisA

Iam not using frameworks just plain python code written in Notepad++

Can you please tell me how to switch this line in order for this line to work?
--
http://mail.python.org/mailman/listinfo/python-list


nikos.gr33k at gmail

Sep 15, 2012, 6:28 AM

Post #5 of 44 (3048 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

, 15 2012 3:34:34 .. UTC+3, Chris Angelico :
> On Sat, Sep 15, 2012 at 10:22 PM, <nikos.gr33k [at] gmail> wrote:
>
> > Hello,
>
> >
>
> > I recently changed webhost and in the new one iam getting this error you can see if you visit http://superhost.gr when program execution reaches the line:
>
> >
>
> > f = open( '../' + page )
>
> >
>
> > In the previous host i wasn't getting this error.
>
> >
>
> > page's contents is:
>
> >
>
> > page = form.getvalue('page')
>
>
>
> Well, clearly '../' is a string (str), and page must be a list. But
>
> without knowing your web framework it's hard to be sure what's going
>
> on.
>
>
>
> My guess is that form.getvalue() is returning a list of form elements
>
> with that name, so you have a list with one element in it. But check
>
> your documentation to be sure.
>
>
>
> Since this changed when you changed hosts, it may mean you now have a
>
> completely different framework. Possibly you can configure this.
>
> Alternatively, it may simply be a different version of the same
>
> system. It's hard to know just based on this, though.
>
>
>
> ChrisA

Iam not using frameworks just plain python code written in Notepad++

Can you please tell me how to switch this line in order for this line to work?
--
http://mail.python.org/mailman/listinfo/python-list


sahnov.m at gmail

Sep 15, 2012, 6:33 AM

Post #6 of 44 (3061 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

f = open( '../' + page.pop() )
15.09.2012 17:32 пользователь "Νικόλαος Κούρας" <nikos.gr33k [at] gmail>
написал:

> Τη Σάββατο, 15 Σεπτεμβρίου 2012 3:34:34 μ.μ. UTC+3, ο χρήστης Chris
> Angelico έγραψε:
> > On Sat, Sep 15, 2012 at 10:22 PM, Νικόλαος Κούρας <nikos.gr33k [at] gmail>
> wrote:
> >
> > > Hello,
> >
> > >
> >
> > > I recently changed webhost and in the new one iam getting this error
> you can see if you visit http://superhost.gr when program execution
> reaches the line:
> >
> > >
> >
> > > f = open( '../' + page )
> >
> > >
> >
> > > In the previous host i wasn't getting this error.
> >
> > >
> >
> > > page's contents is:
> >
> > >
> >
> > > page = form.getvalue('page')
> >
> >
> >
> > Well, clearly '../' is a string (str), and page must be a list. But
> >
> > without knowing your web framework it's hard to be sure what's going
> >
> > on.
> >
> >
> >
> > My guess is that form.getvalue() is returning a list of form elements
> >
> > with that name, so you have a list with one element in it. But check
> >
> > your documentation to be sure.
> >
> >
> >
> > Since this changed when you changed hosts, it may mean you now have a
> >
> > completely different framework. Possibly you can configure this.
> >
> > Alternatively, it may simply be a different version of the same
> >
> > system. It's hard to know just based on this, though.
> >
> >
> >
> > ChrisA
>
> Iam not using frameworks just plain python code written in Notepad++
>
> Can you please tell me how to switch this line in order for this line to
> work?
> --
> http://mail.python.org/mailman/listinfo/python-list
>


rosuav at gmail

Sep 15, 2012, 6:38 AM

Post #7 of 44 (3078 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

On Sat, Sep 15, 2012 at 11:28 PM, <nikos.gr33k [at] gmail> wrote:
> Iam not using frameworks just plain python code written in Notepad++
>
> Can you please tell me how to switch this line in order for this line to work?

f = open( '../' + page[0])

will possibly work. But do try to understand what's happening, rather
than simply solve the problem. You may find that something else has
changed too.

ChrisA
--
http://mail.python.org/mailman/listinfo/python-list


nikos.gr33k at gmail

Sep 15, 2012, 6:53 AM

Post #8 of 44 (3050 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

, 15 2012 4:38:51 .. UTC+3, Chris Angelico :
> On Sat, Sep 15, 2012 at 11:28 PM, <nikos.gr33k [at] gmail> wrote:
>
> > Iam not using frameworks just plain python code written in Notepad++
>
> >
>
> > Can you please tell me how to switch this line in order for this line to work?
>
>
>
> f = open( '../' + page[0])
>
>
>
> will possibly work. But do try to understand what's happening, rather
>
> than simply solve the problem. You may find that something else has
>
> changed too.
>
>
>
> ChrisA

i see you try to extract only the 1st element of the list, i tried that too but it gives me now this weird message:

if you visit my website http://superhost.gr
--
http://mail.python.org/mailman/listinfo/python-list


nikos.gr33k at gmail

Sep 15, 2012, 6:53 AM

Post #9 of 44 (3048 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

, 15 2012 4:38:51 .. UTC+3, Chris Angelico :
> On Sat, Sep 15, 2012 at 11:28 PM, <nikos.gr33k [at] gmail> wrote:
>
> > Iam not using frameworks just plain python code written in Notepad++
>
> >
>
> > Can you please tell me how to switch this line in order for this line to work?
>
>
>
> f = open( '../' + page[0])
>
>
>
> will possibly work. But do try to understand what's happening, rather
>
> than simply solve the problem. You may find that something else has
>
> changed too.
>
>
>
> ChrisA

i see you try to extract only the 1st element of the list, i tried that too but it gives me now this weird message:

if you visit my website http://superhost.gr
--
http://mail.python.org/mailman/listinfo/python-list


roy at panix

Sep 15, 2012, 7:21 AM

Post #10 of 44 (3060 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

In article <mailman.750.1347717221.27098.python-list [at] python>,

> i see you try to extract only the 1st element of the list, i tried that too
> but it gives me now this weird message:
>
> if you visit my website http://superhost.gr

Do you realize that the hosting service you're using (HostGator) is so
mis-configured that it is exposing your source code and credentials to
the entire world?

When I go to that URL, I get a page which includes the name of the CGI
script you are running (/home/nikos/public_html/cgi-bin/counter.py). I
can then do a GET on http://superhost.gr/~nikos/cgi-bin/counter.py, and
can see your script source code, including the credentials to attach to
your database:

conn = MySQLdb.connect( db = 'nikos_tech', host = 'localhost', user =
'nikos_nikos', passwd = <elided>)

How to properly configure a web server is way beyond the scope of this
mailing list, but you really need to do some research there to safeguard
your own data.
--
http://mail.python.org/mailman/listinfo/python-list


__peter__ at web

Sep 15, 2012, 7:29 AM

Post #11 of 44 (3057 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

Νικόλαος Κούρας wrote:

> Τη Σάββατο, 15 Σεπτεμβρίου 2012 4:38:51 μ.μ. UTC+3, ο χρήστης Chris
> Angelico έγραψε:
>> On Sat, Sep 15, 2012 at 11:28 PM, Νικόλαος Κούρας <nikos.gr33k [at] gmail>
>> wrote:
>>
>> > Iam not using frameworks just plain python code written in Notepad++
>>
>> >
>>
>> > Can you please tell me how to switch this line in order for this line
>> > to work?
>>
>>
>>
>> f = open( '../' + page[0])
>>
>>
>>
>> will possibly work. But do try to understand what's happening, rather
>>
>> than simply solve the problem. You may find that something else has
>>
>> changed too.
>>
>>
>>
>> ChrisA
>
> i see you try to extract only the 1st element of the list, i tried that
> too but it gives me now this weird message:
>
> if you visit my website http://superhost.gr

You seem to have encoding problems:

>>> print '\xc4\xe5\xed \xf5\xf0\xdc\xf1\xf7\xe5\xe9
\xf4\xdd\xf4\xef\xe9\xef \xe1\xf1\xf7\xe5\xdf\xef \xde
\xea\xe1\xf4\xdc\xeb\xef\xe3\xef\xf2'.decode("iso-8859-7")
Δεν υπάρχει τέτοιο αρχείο ή κατάλογος

That doesn't look weird (I'd guess) for someone who knows Greek...

Proceeding to

http://superhost.gr/cgi-bin/counter.py?page=foo.html

versus

http://superhost.gr/cgi-bin/counter.py?page=foo.html&page=bar.html

it turns out that you get a list as the page variable only in the latter
case. So you might have provoked your initial problem by following a buggy
url with a duplicate page argument.

--
http://mail.python.org/mailman/listinfo/python-list


nikos.gr33k at gmail

Sep 15, 2012, 7:44 AM

Post #12 of 44 (3067 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

, 15 2012 5:21:22 .. UTC+3, Roy Smith :
> In article <mailman.750.1347717221.27098.python-list [at] python>,
>
>
>
> > i see you try to extract only the 1st element of the list, i tried that too
>
> > but it gives me now this weird message:
>
> >
>
> > if you visit my website http://superhost.gr
>
>
>
> Do you realize that the hosting service you're using (HostGator) is so
>
> mis-configured that it is exposing your source code and credentials to
>
> the entire world?
>
>
>
> When I go to that URL, I get a page which includes the name of the CGI
>
> script you are running (/home/nikos/public_html/cgi-bin/counter.py). I
>
> can then do a GET on http://superhost.gr/~nikos/cgi-bin/counter.py, and
>
> can see your script source code, including the credentials to attach to
>
> your database:
>
>
>
> conn = MySQLdb.connect( db = 'nikos_tech', host = 'localhost', user =
>
> 'nikos_nikos', passwd = <elided>)
>
>
>
> How to properly configure a web server is way beyond the scope of this
>
> mailing list, but you really need to do some research there to safeguard
>
> your own data.

I cant beleive that my source code can be seen form ANYONE this easily!!!!

I moved to HostGaot because i heard there were the best in the hosting business.....
--
http://mail.python.org/mailman/listinfo/python-list


rosuav at gmail

Sep 15, 2012, 7:49 AM

Post #13 of 44 (3053 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

On Sun, Sep 16, 2012 at 12:44 AM, <nikos.gr33k [at] gmail> wrote:
> , 15 2012 5:21:22 .. UTC+3, Roy Smith :
>> Do you realize that the hosting service you're using (HostGator) is so
>> mis-configured that it is exposing your source code and credentials to
>> the entire world?
>
> I cant beleive that my source code can be seen form ANYONE this easily!!!!
>
> I moved to HostGaot because i heard there were the best in the hosting business.....

It's probably a simple misconfiguration that can be easily fixed. If
you don't yourself understand it, talk to HostGator support;
presumably you're paying them money for hosting, so they should be
both able and willing to help you sort that out.

I would recommend that you change your database password as soon as
that's done, lest someone "seize the day" and take control of your
database.

ChrisA
--
http://mail.python.org/mailman/listinfo/python-list


nikos.gr33k at gmail

Sep 15, 2012, 7:51 AM

Post #14 of 44 (3053 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

in my case an .htaccess file gives redirects all html requests to /cgi-bin/counter.py by also provide as an argument to the counter.py script the initical html file request

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^/?(.+\.html) /cgi-bin/counter.py?page=$1 [L,PT,QSA]

so the latter you mentioned its not the case for me.
But iam wondering why this doesnt work on this server while on my previous host did.....
--
http://mail.python.org/mailman/listinfo/python-list


nikos.gr33k at gmail

Sep 15, 2012, 7:51 AM

Post #15 of 44 (3050 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

in my case an .htaccess file gives redirects all html requests to /cgi-bin/counter.py by also provide as an argument to the counter.py script the initical html file request

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^/?(.+\.html) /cgi-bin/counter.py?page=$1 [L,PT,QSA]

so the latter you mentioned its not the case for me.
But iam wondering why this doesnt work on this server while on my previous host did.....
--
http://mail.python.org/mailman/listinfo/python-list


rosuav at gmail

Sep 15, 2012, 7:55 AM

Post #16 of 44 (3062 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

On Sun, Sep 16, 2012 at 12:51 AM, <nikos.gr33k [at] gmail> wrote:
> in my case an .htaccess file gives redirects all html requests to /cgi-bin/counter.py by also provide as an argument to the counter.py script the initical html file request
>
> RewriteEngine On
> RewriteCond %{REQUEST_FILENAME} -f
> RewriteRule ^/?(.+\.html) /cgi-bin/counter.py?page=$1 [L,PT,QSA]
>
> so the latter you mentioned its not the case for me.
> But iam wondering why this doesnt work on this server while on my previous host did.....

Okay, now we're getting to a possible difference. Check if this is
properly working; perhaps HostGator don't let you use the rewrite
engine in .htaccess. Make sure your .htaccess is in the right
directory, too. I just tried a quick check and was greeted with a 404
page, so the rule you describe isn't active.

ChrisA
--
http://mail.python.org/mailman/listinfo/python-list


nikos.gr33k at gmail

Sep 15, 2012, 7:56 AM

Post #17 of 44 (3063 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

Thank i will do that, ill inform the support right away!
--
http://mail.python.org/mailman/listinfo/python-list


nikos.gr33k at gmail

Sep 15, 2012, 8:01 AM

Post #18 of 44 (3051 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

The .htaccess file works with HostGator because the page was working all day rediecting all html requests fine to the counter.py script.

Only when i tried to post data to the text area boxes this problem made its appearance.
--
http://mail.python.org/mailman/listinfo/python-list


roy at panix

Sep 15, 2012, 8:01 AM

Post #19 of 44 (3072 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

In article <dc558687-9ae1-4dab-aa82-422b069f7cfa [at] googlegroups>,
<nikos.gr33k [at] gmail> wrote:

> I cant beleive that my source code can be seen form ANYONE this easily!!!!

Which is why I pointed it out. I mean no disrespect, but you appear to
be in over your head. That's fine (we're all in over our heads at some
point, that's how we learn new things), but once you're running a server
on the Internet, the consequences of your actions become much more
severe.

> I moved to HostGaot because i heard there were the best in the hosting
> business.....

The hosting business means different things to different people. At one
end, there's places like WordPress and Tumblr which hide all the details
and let you pour content into a blog with some control over styling. At
the other end, there's places like AWS, Rackspace, etc, which give you a
raw (virtual) machine, and you're free to do anything you want on it.

In between, there's paces like HostGator, which give you a slice of a
shared host, and you're free to install cgi scripts under the control of
Apache. How much you get to play with the Apache configuration probably
varies wildly from provider to provider. It looks like HostGator either
has things mis-configured to allow your /cgi-bin directory to be
visible, or allows you the ability to configure those things yourself,
and you mis-configured it.


nikos.gr33k at gmail

Sep 15, 2012, 8:06 AM

Post #20 of 44 (3069 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

Previous webhost has the same flaw as well, look:

http://www.errorweb.gr/~nikos/cgi-bin/

giving away all my scripts.

Webhost misconfiguration in both hosts!
--
http://mail.python.org/mailman/listinfo/python-list


rosuav at gmail

Sep 15, 2012, 8:23 AM

Post #21 of 44 (3056 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

On Sun, Sep 16, 2012 at 1:06 AM, <nikos.gr33k [at] gmail> wrote:
> Previous webhost has the same flaw as well, look:
>
> http://www.errorweb.gr/~nikos/cgi-bin/
>
> giving away all my scripts.
>
> Webhost misconfiguration in both hosts!

And when I look at the scripts, I see things that do not fill me with
confidence. You appear to be reinventing the wheel, and making it
hexagonal in the process. That's not to say you shouldn't tinker with
wheel design now and then, but as Roy said, the consequences get quite
severe once you're hosting a web site to the world.

I've been guilty of the same sorts of issues myself. I was poking at
some old code today (code that dates back a few years to when I was
new to PHP and didn't know of any other way to make a dynamic web site
other than CGI) and found some pretty ridiculous coding bloopers.
Stuff that didn't stop the site's primary functionality from working,
but it sure isn't what I'd call good code. Some day I'll rewrite it
all... some day I'll have time available... anyway.

Your counter.py appears to be doing what most people do after the fact
with log-file analysis. It's usually a lot better to simply parse
Apache's log files to find out how many people view your pages, rather
than maintaining the statistics. This has a race condition in it:

# update existing visitor record if same pin and same host found
try:
cursor.execute( '''UPDATE visitors SET hits = hits + 1, agent = %s,
date = %s WHERE pin = %s AND host = %s''', (agent, date, pin, host))
except MySQLdb.Error, e:
print ( "Error %d: %s" % (e.args[0], e.args[1]) )

# insert new visitor record if above update did not affect a row
if cursor.rowcount == 0:
cursor.execute( '''INSERT INTO visitors(pin, host, hits, agent,
date) VALUES(%s, %s, %s, %s, %s)''', (pin, host, 1, agent, date) )


If two page loads simultaneously execute this code, they'll both fail
to update, and then both attempt to insert.

Also, it's extremely insecure to simply print your database errors.
Emit them to a separate log file that only you have access to, and
monitor that log while you're developing. Once you're done developing,
switch to an alert system if you can, because SQL errors should never
occur (obviously don't alert if there are specific errors that you
intend to cause and catch).

See if you can replace the whole mess of CGI scripts with flat HTML
files and AWStats. You'll have much more flexibility in hosting
company choice, less risk of security breaches, and much MUCH easier
management.

ChrisA
--
http://mail.python.org/mailman/listinfo/python-list


nikos.gr33k at gmail

Sep 15, 2012, 8:23 AM

Post #22 of 44 (3057 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

I swicthed back my code to: f = open( '../' + page )

and http://superhost.gr works which means that line gets parsed correctly.

Only when i post data to the text area boxes iam getting the error:

cannot concatenate 'str' and 'list' objects

how is this possible to work before and NOT work when i enter data to the page for storing to the database?
--
http://mail.python.org/mailman/listinfo/python-list


nikos.gr33k at gmail

Sep 15, 2012, 8:33 AM

Post #23 of 44 (3047 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

You are right but iam a new python learner and i created this logging system script as a poject to better learn the lalguage itself.

I can always use google analytics for serious visitor logging.

Apart from that i enjoy reading my logs by typing:

http://superhost.gr/?show=log

:-)
--
http://mail.python.org/mailman/listinfo/python-list


rosuav at gmail

Sep 15, 2012, 8:44 AM

Post #24 of 44 (3062 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

On Sun, Sep 16, 2012 at 1:23 AM, <nikos.gr33k [at] gmail> wrote:
> I swicthed back my code to: f = open( '../' + page )
>
> and http://superhost.gr works which means that line gets parsed correctly.
>
> Only when i post data to the text area boxes iam getting the error:
>
> cannot concatenate 'str' and 'list' objects
>
> how is this possible to work before and NOT work when i enter data to the page for storing to the database?

Okay. Putting everything together, I think I can see what's going on.

You have a rewrite rule that's changing http://superhost.gr/ into a
request that, if my hand-parsing of Apache directives is working,
looks like this:
http://superhost.gr/cgi-bin/counter.py?page=index.html

That page doesn't quite work, as the browser goes looking for images
and CSS in cgi-bin instead of the root, but that's pretty much what's
going on. (I had to guess that it was index.html, as that part is
implicit in the original URL.)

You then have a request with a GET variable named 'page', and also a
POST variable named 'page', courtesy of the hidden form variable. This
would be why you're getting a list instead of a string.

Is the hidden form field completely redundant? If so, just remove it.
If you need that information for some other reason (eg you want to
record which page the user came from), then rename one or other of
them.

I would recommend a naming convention whereby you keep "internal
stuff" away from your main site. For instance, change your rewrite
rule to create a form field called _page and have counter.py look for
that. Or better still, don't use the query string for that at all, if
you can (I can't remember off-hand what a rewrite rule can set, but I
think you can carry extra information around in other ways).
Currently, your site can be broken by adding a query string to the
URL:

http://superhost.gr/?page=hahahaha

As a general rule, a web site should not get confused by the presence
of an unexpected form field. It's not good for someone to be able to
break your page like this!

It appears that part of the problem is that your getvalue() function
has three possibilities, similar to the issue I had a while ago with a
similar PHP function. Readers of CS Lewis may recognize what I'm
saying... Either she is lying, and there is no array at all; or she is
mad - a single item as a scalar instead of an array; or she is telling
the truth, and we have an array just like we need.

ChrisA
--
http://mail.python.org/mailman/listinfo/python-list


rosuav at gmail

Sep 15, 2012, 8:46 AM

Post #25 of 44 (3046 views)
Permalink
Re: cannot concatenate 'str' and 'list' objects [In reply to]

On Sun, Sep 16, 2012 at 1:33 AM, <nikos.gr33k [at] gmail> wrote:
> You are right but iam a new python learner and i created this logging system script as a poject to better learn the lalguage itself.
>
> I can always use google analytics for serious visitor logging.
>
> Apart from that i enjoy reading my logs by typing:
>
> http://superhost.gr/?show=log

Yes, and I'm sure random visitors will enjoy reading them too, with no
authentication required. You really shouldn't make all your visitors'
IP addresses and usage stats public. Also, you may want to consider
recording IP addresses for the "reverse dns lookup failed" entries, as
there'll be a lot of them :)

ChrisA
--
http://mail.python.org/mailman/listinfo/python-list

First page Previous page 1 2 Next page Last page  View All Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.