TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'

Νίκος Γκρ33κ nikos.gr33k at gmail.com
Sun May 26 06:32:18 EDT 2013


Perhaps cna you help a bit with tha too:
used to work in 2.6 but not with 3.3.1

#!/usr/bin/python3
# coding=utf-8

import cgitb; cgitb.enable()
import cgi, os, sys
from http import cookies


# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )
nikos = cookie.get('nikos')


# if visitor cookie does exist
if nikos:
	msg = "ΑΠΟ ΤΗΝ ΕΠΟΜΕΝΗ ΕΠΙΣΚΕΨΗ ΣΟΥ ΘΑ ΣΕ ΥΠΟΛΟΓΙΖΩ ΩΣ ΕΠΙΣΚΕΠΤΗ ΑΥΞΑΝΟΝΤΑΣ ΤΟΝ ΜΕΤΡΗΤΗ!"
	cookie['nikos'] = 'admin'
	cookie['nikos']['path'] = '/'
	cookie['nikos']['expires'] = -1		#this cookie will expire now
else:
	msg = "ΑΠΟ ΔΩ ΚΑΙ ΣΤΟ ΕΞΗΣ ΔΕΝ ΣΕ ΕΙΔΑ, ΔΕΝ ΣΕ ΞΕΡΩ, ΔΕΝ ΣΕ ΑΚΟΥΣΑ! ΘΑ ΕΙΣΑΙ ΠΛΕΟΝ Ο ΑΟΡΑΤΟΣ ΕΠΙΣΚΕΠΤΗΣ!!"
	cookie['nikos'] = 'admin'
	cookie['nikos']['path'] = '/'
	cookie['nikos']['expires'] = 60*60*24*30*12		#this cookie will expire in a year


print ( "Content-type: text/html; charset=utf-8\n" )
print( cookie, msg )
sys.exit(0)

ima getting internal server error.



More information about the Python-list mailing list