def post_to_dropbox(req): user = users.get_current_user() note = req.get('note') url = req.get('url') try: (mime_type,data,title) = get_data(url) except: req.res.body = 'sorry, could not ingest '+url return dbox = Dropbox( url=url,note=note,owner=user.user_id(),mime_type=mime_type,data=data,title=title) dbox.put() return req.redirect(req.uri.server_uri()+'/dropbox')
def get_dropbox_item(req): user = users.get_current_user() if not user: return req.redirect(users.create_login_url(req.uri.application_uri())) id = int(req.get('id')) dropbox_item = Dropbox.get_by_id(id) req.res.headers['Content-Type'] = dropbox_item.mime_type req.res.body = dropbox_item.data
def get_dropbox(req): user = users.get_current_user() if not user: return req.redirect(users.create_login_url(req.uri.application_uri())) t = Template(req,'dropbox.html',TEMPLATE_PATH) t.assign('title','SimpleRepository: Dropbox') t.assign('dropbox_items',Dropbox.get_list_by_user(user)) req.res.body = t.fetch()