def post(self): shout = Shout(message=self.request.get('message')) avatar = self.request.get("img") #avatar = images.resize(self.request.get("img"), 100, 100) shout.avatar = db.Blob(str(avatar)) if users.get_current_user(): shout.author = users.get_current_user() shout.put() mail.send_mail(sender="*****@*****.**", to="马理军 <*****@*****.**>", subject="appspot 的信息", body=self.request.get('message').encode('utf-8')) self.redirect('/')
def post(self): text = cgi.escape(self.request.get('text')) name = cgi.escape(self.request.get('name')) s = Shout(text=text, name=name) s.put() # FIXME apendix = ' #iranelection' chars = 140 - len(apendix) from secretsettings import twitter_password, twitter_username payload= {'status' : text[:chars] + apendix, 'source' : "iranbreakingnews"} payload= urllib.urlencode(payload) base64string = base64.encodestring('%s:%s' % (twitter_username, twitter_password))[:-1] headers = {'Authorization': "Basic %s" % base64string} url = "http://twitter.com/statuses/update.xml" result = urlfetch.fetch(url, payload=payload, method=urlfetch.POST, headers=headers) self.redirect('/shoutbox/')