Re: Select fails when cookie tried to get a numeric value

2013-10-06 Thread Piet van Oostrum
Νίκος Αλεξόπουλος writes: > i use 'cgi', but i noticed you used 'mod-wsgi'. > I want to ask you why you chose the latter? Is the latter better than > the former? > > Is it faster? Does it bahave the same way? > I my code works works with cgi, which it does, will the same code works > with mod-wcg

Re: Select fails when cookie tried to get a numeric value

2013-10-06 Thread Denis McMahon
On Sun, 06 Oct 2013 08:20:35 +0300, Νίκος Αλεξόπουλος wrote: > Thank you Denis, i didn't knew about sessions up until i saw you post. > Your code is very advanced for me to read but i will try to "decode it" > I though that if we want to read something from our visitor, something > we want, we hav

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 6/10/2013 2:36 πμ, ο/η Denis McMahon έγραψε: On Sat, 05 Oct 2013 16:38:14 +0300, Νίκος Αλεξόπουλος wrote: [my cookie code is fucked] Hi Nick I had never used python for www before yesterday. I had never used python before about 6 months ago. In the last 24 hours I have installed mod-ws

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Denis McMahon
On Sat, 05 Oct 2013 16:38:14 +0300, Νίκος Αλεξόπουλος wrote: > [my cookie code is fucked] Hi Nick I had never used python for www before yesterday. I had never used python before about 6 months ago. In the last 24 hours I have installed mod-wsgi on my apache web server, and written test code

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Chris Angelico
On Sun, Oct 6, 2013 at 1:31 AM, Νίκος Αλεξόπουλος wrote: > # find the visitor record for the (saved) cID and current > host > cur.execute('''SELECT * FROM visitors WHERE counterID = %s > and cookieID = %s''', (cID, cookieID) ) > > data = cur.fetchone

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Terry Reedy
On 10/5/2013 9:38 AM, Νίκος Αλεξόπουλος wrote: # initialize cookie cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') ) cookie.load( cookie ) vip = cookie.get('ID') ... ... # if browser cookie does not exist, set it vip = random.randrange(0, 1) cookie['ID'] = vip cookie['I

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Benjamin Rovny
On Oct 5, 2013 8:42 AM, "Νίκος Αλεξόπουλος" wrote: > > # initialize cookie > cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') ) > cookie.load( cookie ) > vip = cookie.get('ID') > > ... > ... > > # if browser cookie does not exist, set it > vip = random.randrange(0, 1) > coo

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 7:56 μμ, ο/η Andreas Perstinger έγραψε: On 05.10.2013 16:24, Νίκος Αλεξόπουλος wrote: # initialize cookie cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') ) cookie.load( cookie ) Watch: >>> cookie1 = cookies.SimpleCookie('ID=42') >>> cookie1.load(cookie1) >>> pri

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Andreas Perstinger
On 05.10.2013 16:24, Νίκος Αλεξόπουλος wrote: # initialize cookie cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') ) cookie.load( cookie ) Watch: >>> cookie1 = cookies.SimpleCookie('ID=42') >>> cookie1.load(cookie1) >>> print(cookie1) Set-Cookie: ID="Set-Cookie: ID=42" >>> cookie1.

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 7:42 μμ, ο/η Ned Batchelder έγραψε: A better solution is to check to see if you got None: if cookie.get('ID') is None: # make a new cookie I have tried everythign even wgat you suggested right now: here is is: # initialize cookie and retrieve cookie from clie

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread MRAB
On 05/10/2013 15:44, Zero Piraeus wrote: On Sat, Oct 05, 2013 at 05:30:53PM +0300, Νίκος Αλεξόπουλος wrote: Every mysql statemtns that involved cookieID fails. in this example this: # find the visitor record for the (saved) cID and current host cur.execute('''SELECT * FROM visitors WHERE count

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Ned Batchelder
On 10/5/13 12:17 PM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 7:14 μμ, ο/η Νίκος Αλεξόπουλος έγραψε: Στις 5/10/2013 7:08 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 11:52 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrot

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Zero Piraeus
: On Sat, Oct 05, 2013 at 05:30:53PM +0300, Νίκος Αλεξόπουλος wrote: > Every mysql statemtns that involved cookieID fails. > > in this example this: > > # find the visitor record for the (saved) cID and current host > cur.execute('''SELECT * FROM visitors WHERE counterID = %s and > cookieID = %s

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 7:14 μμ, ο/η Νίκος Αλεξόπουλος έγραψε: Στις 5/10/2013 7:08 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 11:52 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έ

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 7:08 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 11:52 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε: From reading the bottom-most frame, you can s

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Ned Batchelder
On 10/5/13 11:52 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε: From reading the bottom-most frame, you can see that the problem is that "val" is an http.cookies

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε: From reading the bottom-most frame, you can see that the problem is that "val" is an http.cookies.Morsel object. This means you probably tried t

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 6:06 μμ, ο/η Zero Piraeus έγραψε: : On Sat, Oct 05, 2013 at 05:40:23PM +0300, Νίκος Αλεξόπουλος wrote: When i print CookieID i was under the impression i would see a random number like '5369' but instead it display the follwong. Set-Cookie: ID="Set-Cookie: ID=5369" On Sat, Oct

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Andreas Perstinger
On 05.10.2013 17:31, Νίκος Αλεξόπουλος wrote: Now i have it like this: # connect to database con = pymysql.connect( db = 'nikos_metrites', user = 'nikos_root', passwd = 't1abhp2r!', charset = 'utf8', host = 'localhost' ) Just to be sure: That's not your real password, is it? Bye, Andreas --

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 6:12 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε: From reading the bottom-most frame, you can see that the problem is that "val" is an http.cookies.Morsel object. This means you probably tried t

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Zero Piraeus
: On Sat, Oct 05, 2013 at 05:40:23PM +0300, Νίκος Αλεξόπουλος wrote: > When i print CookieID i was under the impression i would see a > random number like '5369' but instead it display the follwong. > > Set-Cookie: ID="Set-Cookie: ID=5369" On Sat, Oct 05, 2013 at 05:47:54PM +0300, Νίκος Αλεξόπου

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Ned Batchelder
On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε: From reading the bottom-most frame, you can see that the problem is that "val" is an http.cookies.Morsel object. This means you probably tried to use a cookie object as data in your SQL query, and

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Ned Batchelder
On 10/5/13 10:40 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε: From reading the bottom-most frame, you can see that the problem is that "val" is an http.cookies.Morsel object. This means you probably tried to use a cookie object as data in your SQL query, and

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 5:43 μμ, ο/η Ned Batchelder έγραψε: On 10/5/13 10:30 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 5:28 μμ, ο/η Chris Angelico έγραψε: On Sun, Oct 6, 2013 at 12:24 AM, Νίκος Αλεξόπουλος wrote: But i have given you the line that produces the error: The statement you quoted is an

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 4:53 μμ, ο/η Ned Batchelder έγραψε: From reading the bottom-most frame, you can see that the problem is that "val" is an http.cookies.Morsel object. This means you probably tried to use a cookie object as data in your SQL query, and MySQL doesn't know what to do with that object

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Ned Batchelder
On 10/5/13 10:30 AM, Νίκος Αλεξόπουλος wrote: Στις 5/10/2013 5:28 μμ, ο/η Chris Angelico έγραψε: On Sun, Oct 6, 2013 at 12:24 AM, Νίκος Αλεξόπουλος wrote: But i have given you the line that produces the error: The statement you quoted is an INSERT. The traceback quotes a SELECT. These are no

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 5:28 μμ, ο/η Chris Angelico έγραψε: On Sun, Oct 6, 2013 at 12:24 AM, Νίκος Αλεξόπουλος wrote: But i have given you the line that produces the error: The statement you quoted is an INSERT. The traceback quotes a SELECT. These are not the same line of code. You still have not sho

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 5:24 μμ, ο/η Νίκος Αλεξόπουλος έγραψε: Στις 5/10/2013 4:59 μμ, ο/η Chris Angelico έγραψε: On Sat, Oct 5, 2013 at 11:38 PM, Νίκος Αλεξόπουλος wrote: cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city, useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s,

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Chris Angelico
On Sun, Oct 6, 2013 at 12:24 AM, Νίκος Αλεξόπουλος wrote: > But i have given you the line that produces the error: The statement you quoted is an INSERT. The traceback quotes a SELECT. These are not the same line of code. You still have not shown us the actual line from the traceback. ChrisA --

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
Στις 5/10/2013 4:59 μμ, ο/η Chris Angelico έγραψε: On Sat, Oct 5, 2013 at 11:38 PM, Νίκος Αλεξόπουλος wrote: cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city, useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)''', (cID, vip, host, city, useros, browser,

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Chris Angelico
On Sat, Oct 5, 2013 at 11:38 PM, Νίκος Αλεξόπουλος wrote: > cur.execute('''INSERT INTO visitors (counterID, cookieID, host, city, > useros, browser, ref, lastvisit) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)''', > (cID, vip, host, city, useros, browser, ref, lastvisit) ) > ===

Re: Select fails when cookie tried to get a numeric value

2013-10-05 Thread Ned Batchelder
On 10/5/13 9:38 AM, Νίκος Αλεξόπουλος wrote: # initialize cookie cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') ) cookie.load( cookie ) vip = cookie.get('ID') ... ... # if browser cookie does not exist, set it vip = random.randrange(0, 1) cookie['ID'] = vip cookie['ID'

Select fails when cookie tried to get a numeric value

2013-10-05 Thread Νίκος Αλεξόπουλος
# initialize cookie cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') ) cookie.load( cookie ) vip = cookie.get('ID') ... ... # if browser cookie does not exist, set it vip = random.randrange(0, 1) cookie['ID'] = vip cookie['ID']['path'] = '/' # fir