A certainl part of an if() structure never gets executed.
Νικόλαος Κούρας
support at superhost.gr
Wed Jun 12 03:45:34 EDT 2013
On Tue, 11 Jun 2013 22:49:05 -0600, Michael Torrie wrote:
> What do each of these functions return? When you print out
> re.search('=', name) what happens?
First of all i have changed the code to the following because using a
regex
to detect a single char was an overkill.
if '=' not in name and '=' not in month and '=' not in year:
cur.execute( '''SELECT * FROM works WHERE clientsID = (SELECT id
FROM clients WHERE name = %s) and MONTH(lastvisit) = %s and YEAR
(lastvisit)
= %s ORDER BY lastvisit ASC''', (name, month, year) )
elif '=' not in month and '=' not in year:
cur.execute( '''SELECT * FROM works WHERE MONTH(lastvisit) = %s
and YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (month, year) )
elif '=' not in year:
cur.execute( '''SELECT * FROM works WHERE YEAR(lastvisit) = %s
ORDER BY lastvisit ASC''', year )
else:
print( '<h2><font color=red>Πώς να γίνει αναζήτηση αφού δεν
επέλεξες ούτε πελάτη ούτε μήνα ή τουλάχιστον το έτος?' )
print( '<meta http-equiv="REFRESH" content="5;/cgi-bin/
pelatologio.py">' )
sys.exit(0)
Here is the definements of those varibles. as you can see are all tuples
# populate names, months, years
names.add( '==========' )
months = ( '==========', 'Ιανουάριος', 'Φεβρουάριος', 'Μάρτιος',
'Απρίλιος', 'Μάϊος', 'Ιούνιος',
'Ιούλιος', 'Αύγουστος', 'Σεπτέμβριος', 'Οκτώβριος',
'Νοέμβριος',
'Δεκέμβριος' )
years = ( '==========', 2010, 2011, 2012, 2013 )
========================
i used print( name, month, year ) and noticed that all values returned as
expected when selected fro drop-down menus and submitted.
But when it comes to select '==========' form month instead of
'==========' to be submitted a zero gets submitted and i think the problem
is the way i'm filling up months into the drop down menu which is:
for i, month in enumerate(months):
print('<option value="%s"> %s </option>' % (i, month) )
the if case does not execute because of the way it checks for None entry
which is: elif '=' not in year:
but if enumerate yields 0 instead of '==========' then elif '=' not in
year of course fails.
So, i must tell:
for i, month in enumerate(months):
print('<option value="%s"> %s </option>' % (i, month) )
to somehow return '==========' instead of 0 but dont know how.
More information about the Python-list
mailing list