[Tutor] python for web developing

2006-09-13 Thread federico ramirez
Hello! I have heard that python is very good for web development, but you need frameworks, like django or turbogears.I know that you dont really need them, you can just write cgi scripts with python...butIm a php programmer, and i want to make another dinamic site with sql, in python, but i need sql object or other sql...
And i cant get a host with it, a free host just to test it.Any recomendations?-- Best Regards.fedekiller
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] show all dbm data

2006-09-14 Thread federico ramirez
Hi, im have just started programming python with cgi and i will try to use dbm as a db to practiseBut i cant figure out how to diplay all the data from it..this is the code im using/#!/usr/bin/python
print "Content-Type: text/html\n\n"import cgi, dbmdef startpage(title):    print '''
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">    http://www.w3.org/1999/xhtml">        
    ''',title,'''        '''    def endpage():    print """    """def main():
    form = cgi.FieldStorage()    if(form.has_key("name") and form["name"].value != ""):        try:            db = dbm.open("dbm", "c")            db["name"] = form["name"].value
            db.close()            print "Info saved. Now, read it?"        except:            print cgi.print_exceptions()    elif(form.has_key("read") and form["read"].value == "true"):
        try:            db = dbm.open("dbm", "r")            for key in db.keys():                print key        except:            print cgi.print_exceptions()    else:
        print """                
        """startpage("Test Page")main()endpage()/Thanks in advance-- Best Regards.fedekiller
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] arrays

2006-09-14 Thread federico ramirez
Hi all! Im started with python some days ago, im trying to make a basic
cgi script, with dbm, and dbm returns a dictionary witout order, so i
put it in an array to order the keys and then display it in order
but..python orders the array like this

['_1', '_10', '_11', '_12', '_13', '_2', '_3', '_4', '_5', '_6', '_7', '_8', '_9']

and i want

['_1', '_2', '_3', '_4', '_5', '_6', '_7', '_8', '_9','_10', '_11', '_12', '_13']

here its the code i use

///

#!/usr/bin/python

print "Content-Type: text/html\n\n"

import cgi, dbm

def startpage(title):
    print '''http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    http://www.w3.org/1999/xhtml">
    
    
    ''',title,'''
    
    '''
    
def endpage():
    print """
    """

def main():
    form = cgi.FieldStorage()
    if(form.has_key("name") and form["name"].value != ""):
        db = dbm.open("dbm", "c")
        db.close()
        dbread = dbm.open("dbm", "r")
        leng = len(dbread)+1
        dbread.close()
        db = dbm.open("dbm", "c")
        name = "_"+str(leng)
        db[name] = form["name"].value
        db.close()
        print "Info saved. Now, read it?"
    elif(form.has_key("read") and form["read"].value == "true"):
        db = dbm.open("dbm", "r")
        arr = []
        for key in db.keys():
            arr += [key]
        arr.sort()
        arr.reverse()
        for i in range(len(db)):
            print db[arr[i]],''
        db.close()
    else:
        print """
        
        
        """

startpage("Test Page")
main()
endpage()

//

Thanks in advanced-- Best Regards.fedekiller
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Cookie help

2006-09-16 Thread federico ramirez
Hey, im working on a cgi script, just a simple news system.And im stucked with the login system.GOD! I hate being a noob!Well, this is the login page#!/usr/bin/python
import cgi, dbm, string, Cookieimport configrequest = cgi.FieldStorage()def loginform():    print '''    
        Username                Password
                 
            '''def main():    C = Cookie.SimpleCookie()    if(C.has_key("admin_user") and C.has_key("admin_pass")):        admin = 
config.getadmin()        if(C["admin_user"].value == admin[0] and C["admin_pass"].value == admin[1]):            config.makepage("You are already logged!")        else:            
config.makepage("Wrong cookies...")    elif(request.has_key("Submit")):        admin = config.getadmin()        username = config.clean(request["user"].value)        password = 
config.clean(request["pass"].value)        if(username == admin[0] and password == admin[1]):                C["admin_user"] = username                C["admin_pass"] = password
                print C                print "Content-Type: text/html\n\n"                config.startpage()                print "Bienvenido",username,'!'                config.endpage
()        else:            print "Content-Type: text/html\n\n"            config.startpage()            print "Incorrect username and password combination"            config.endpage
()    else:        print "Content-Type: text/html\n\n"        config.startpage()        loginform()        config.endpage()main()That seems to work..but i cant get the cookies, i tried making this to get them but i have a 500 error -.- i hate it so much
##!/usr/bin/pythontry:    import Cookie    print "Content-Type: text/html\n\n"    C = Cookie.SimpleCookie()    print C.["admin_user"].value
except:    cgi.print_exception()###i tried that in different ways but i cant get it to workHelp please :(-- Best Regards.fedekiller
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] i just cant do it

2006-09-17 Thread federico ramirez
well, im very angry :(I cant get this to workWhen i try this it works#!/usr/bin/pythonimport CookieC = Cookie.SimpleCookie()C['adminuser'] = 'fedekiller'C['adminuser']['max-age'] = 60*60*24*7
print Cprint "Content-Type: text/html\n\n"print "Bienvenido",C['adminuser'].value,'!'but when i try this it doesnt#!/usr/bin/pythonimport Cookieprint "Content-Type: text/html\n\n"
print "Bienvenido",C['adminuser'].value,'!'I dont know why... i know the cookie exists because firefox display it where all the cookies of that domains are.So, i need help with this please :(
I know im a noob sorry U-U-- Best Regards.fedekiller
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] pygame rpg

2006-11-09 Thread federico ramirez
Hi! im trying to make a rpg game with pygame, of ocurse i will first to try make simpler games, anyways, i could not find any good tutorial, example, article, not anything about making a rpg with pygame and the documentations is pretty poor... only some tutorials
Well, i was wondering is someone can give me a link or something to get started with pygame rpgs-- Best Regards.fedekiller
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor