def POST(self, id): form = Post_Create.form() post = model.post(int(id)) if not form.validates(): return render.edit(post, form) model.post_update(int(id), form.d.title, form.d.content) raise web.seeother('/')
def query_friends(self): from urllib import urlopen session = model.Session() users = session.query(model.user).all() for user in users: for friend in user.friends: if friend.lastupdated != 0: url = friend.url + "/json/since/" + str(friend.lastupdated) else: url = friend.url + "/json/last/100" file = urlopen(url) dicts = json.load(file) for p in dicts: # hacketihack try: tmp = model.post( post_id=p['post_id'], timestamp=p['timestamp'], origin=p['origin'], content_type=p['content_type'], content_string=p['content_string'], source=p['source'], description=p['description'], tags=[] # reference=p['reference'], # signature=p['signature'], ) tmp.owner = user # check if tag already exists, if not create it. for t in p['tags']: res = session.query(model.tag).filter(model.tag.tag == t).all() if res: tmp.tags.append(res[0]) else: new_tag = model.tag(t) session.add(new_tag) tmp.tags.append(new_tag) session.add(tmp) except KeyError, e: raise e friend.lastupdated = int(time.time())
import cgi import base import model form = cgi.FieldStorage() p_data = form.getvalue("post_data") post_pic = form['pic_post'] email = form.getvalue('email') model.post(p_data, post_pic, email) print(""" <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <title>Hello, world!</title> <link rel="stylesheet" href="styles.css"> </head> <body> """) base.header(email)
def GET(self, id): """ View single post """ post = model.post(int(id)) return render.post(post)
def GET(self, id): post = model.post(int(id)) form = Post_Create.form() form.fill(post) return render.post_update(post, form)