Aaron Swartz' web.py looks pretty good, but his framework doesn't thus far seem to support SQLite (?). Furthermore, I like using the object-relational manager SQLObject (which does support SQLite). So as I was working through the web.py tutorial, I changed the code snippets to work with SQLObject and SQLite. I store my model data in a new file, model.py, the contents of which is as follows:
from sqlobject import *
import datetime
# change the location at the end for your own purposes
sqlhub.processConnection = connectionForURI("sqlite:///home/warren/todo.db")
class Todo(SQLObject):
title=StringCol()
created=DateTimeCol(default=datetime.datetime.now)
done=BoolCol(default=False)
Then the modified code.py is as follows.
import web
from model import Todo
urls = (
'/', 'view',
'/add', 'add'
)
class view:
def GET(self):
todos=Todo.select()
web.render('view.html')
class add:
def POST(self):
i = web.input()
new=Todo(title=i.title)
web.seeother('./#t'+str(new.id))
web.internalerror = web.debugerror
if __name__ == "__main__":
web.run(urls, web.reloader)
Notice how I import from model.py, and the use of SQLObject functions. For the GET function in view, I get the data by using Todo.select() rather than using web.py's querying function. Similarly a new object is created using SQLObject rather than web.py. Also absent are database parameters (web.db_parameters) mentioned in the tutorial.
The file view.html is unchanged from the tutorial but it is included here for completeness.
<ul>
#for todo in $todos
<li id="t$todo.id">$todo.title</li>
#end for
</ul>
<form method="post" action="add">
<p><input type="text" name="title" /> <input type="submit" value="Add" /></p>
</form>
This shows that web.py certainly isn't incompatible with object-relational managers. Inspection of the source to the tutorial file (as of 30 March 2006) shows that originally Aaron had something almost identical to this, in fact also using SQLObject.
My first reaction after completing this exercise is that web.py is wonderful. It's the first web framework I've used which doesn't frustrate and annoy me.
last updated 2 years ago
#
history
<a href=" http://groups.google.com/group/ar6vmzcgu/web/asian-fusion-atlanta ">asian fusion atlanta</a> [url=http://groups.google.com/group/ar6vmzcgu/web/asian-fusion-atlanta]asian fusion atlanta[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/asian-ladyboy-sites ">asian ladyboy sites</a> [url=http://groups.google.com/group/ar6vmzcgu/web/asian-ladyboy-sites]asian ladyboy sites[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/asian-lesbian-xxx-porn ">asian lesbian xxx porn</a> [url=http://groups.google.com/group/ar6vmzcgu/web/asian-lesbian-xxx-porn]asian lesbian xxx porn[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/asian-lolitas ">asian lolitas</a> [url=http://groups.google.com/group/ar6vmzcgu/web/asian-lolitas]asian lolitas[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/asian-market-cleveland ">asian market cleveland</a> [url=http://groups.google.com/group/ar6vmzcgu/web/asian-market-cleveland]asian market cleveland[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/asian-market-record-breaking ">asian market record breaking</a> [url=http://groups.google.com/group/ar6vmzcgu/web/asian-market-record-breaking]asian market record breaking[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/asian-massage-blowjob ">asian massage blowjob</a> [url=http://groups.google.com/group/ar6vmzcgu/web/asian-massage-blowjob]asian massage blowjob[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/asian-piss ">asian piss</a> [url=http://groups.google.com/group/ar6vmzcgu/web/asian-piss]asian piss[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/asianesex ">asianesex</a> [url=http://groups.google.com/group/ar6vmzcgu/web/asianesex]asianesex[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/ass-fuckers ">ass fuckers</a> [url=http://groups.google.com/group/ar6vmzcgu/web/ass-fuckers]ass fuckers[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/ass-n-thighs ">ass n thighs</a> [url=http://groups.google.com/group/ar6vmzcgu/web/ass-n-thighs]ass n thighs[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/ass-parade-porn ">ass parade porn</a> [url=http://groups.google.com/group/ar6vmzcgu/web/ass-parade-porn]ass parade porn[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/ass-thick ">ass thick</a> [url=http://groups.google.com/group/ar6vmzcgu/web/ass-thick]ass thick[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/ass2mouth-anal-sex ">ass2mouth anal sex</a> [url=http://groups.google.com/group/ar6vmzcgu/web/ass2mouth-anal-sex]ass2mouth anal sex[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/asshole-kingdom ">asshole kingdom</a> [url=http://groups.google.com/group/ar6vmzcgu/web/asshole-kingdom]asshole kingdom[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/asswatcher ">asswatcher</a> [url=http://groups.google.com/group/ar6vmzcgu/web/asswatcher]asswatcher[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/atlanta-sex ">atlanta sex</a> [url=http://groups.google.com/group/ar6vmzcgu/web/atlanta-sex]atlanta sex[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/australian-porn-star ">australian porn star</a> [url=http://groups.google.com/group/ar6vmzcgu/web/australian-porn-star]australian porn star[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/auto-starter ">auto starter</a> [url=http://groups.google.com/group/ar6vmzcgu/web/auto-starter]auto starter[/url] <a href=" http://groups.google.com/group/ar6vmzcgu/web/babe-inbody-lingerie-sex ">babe inbody lingerie sex</a> [url=http://groups.google.com/group/ar6vmzcgu/web/babe-inbody-lingerie-sex]babe inbody lingerie sex[/url]
2 months ago # reply