webapp2

Is there a way to map GAE user object and Google+ userid

旧街凉风 提交于 2019-12-11 00:55:07
问题 As mentioned here, for default authentication using python users API an object will be returned based on user's email. When user_id() is called over the object a unique id is returned, which is of course not a Google+ user id. import webapp2 from google.appengine.api import users class MainPage(webapp2.RequestHandler): def get(self): user = users.get_current_user() if user: if users.is_current_user_admin(): utype = "Admin" else: utype = "Normal" self.response.headers['Content-Type'] = 'text

Google App Engine: Python: WebOb: How to get POST data in JSON format?

China☆狼群 提交于 2019-12-10 22:41:45
问题 I am building a web app on the Google App Engine platform, which uses webapp2, which uses WebOb. I would like to POST some data in JSON format, including nested arrays and dictionaries. E.g.: $.post('/addvendor', {'vendor': {'name': 'test', 'description': 'a good company', 'tags':['foo', 'bar']}}, function(data){console.log(data)}, 'application/json') However, on the server side, the data comes in as a flat "MultiDict" object, not anything like the original nested JSON object that I POST ed.

How do I integrate filepicker.io with google app engine (blobstore)?

半腔热情 提交于 2019-12-10 15:27:20
问题 So I'm trying to use filepicker.io with a GAE application. The filepicker widget returns the URL of the file that a user uploaded. How do I then use this url to upload the file to GAE's blobstore? The blobstore only supports "file uploading through a form", so the real question is how to fake a form POST containing the URL of a file. 回答1: Faking a form post is possible, but it's much simpler to use the Files API Edit: To use the File API with urlfetch you would write something like this: from

how to organise files with python27 app engine webapp2 framework

半世苍凉 提交于 2019-12-10 13:39:38
问题 I've gone through the getting started tut for python27 and app engine: https://developers.google.com/appengine/docs/python/gettingstartedpython27/ By the end of the tut, all the the classes are in the same file (helloworld.py) and you and you configure the router to point a url path to a class at the bottom of the file: app = webapp2.WSGIApplication([('/', MainPage), ('/sign', Guestbook)], debug=True) What the tut did not cover is how do I orginise my classes / files as my app grows. For

getting TypeError, “not indexable” upon execution of if self.request.POST['file'] inside post method of webapp2.RequestHandler

倖福魔咒の 提交于 2019-12-10 09:24:03
问题 I am trying to upload a file using this code: <form id="form1" action="convert" enctype="multipart/form-data" method="post"> <input type="file" name="file"/> <div><input id="submit_button" type="submit" value="Upload"/></div> </form> class Convert(RequestHandler): @login_required def post(self): session = Session(writer="cookie", session_expire_time = 3600, set_cookie_expires = True) if session['id']: file = self.request.POST['file'] if file and file.type and file.value: but I keep on getting

webapp2 with python3

試著忘記壹切 提交于 2019-12-10 02:34:46
问题 I use webapp2 with python 2.7 with or without googleAppEngine. I'm now trying to use it with Python 3.3 I've used PIP to install webapp2 Install run with success but when I try to import webapp2 from IDLE gaves me the folowing error: File "<pyshell#0>", line 1, in <module> import webapp2 File "C:\Python3\lib\webapp2.py", line 571 except Exception, e: ^ I suspect it's a thing that must be updated in order to work with Python3... ?anybody done this already or should I wait for an updated

Google App Engine HTTP header Content-Type not correct once application is deployed

一笑奈何 提交于 2019-12-09 13:29:59
问题 I am writing an app on GAE and I have a URL that will always return XML and set the Content-Type to "text/xml; charset=utf-8" . I am using the built in webapp framework and using the following code to set content type and return XML in the web handler: self.response.headers.add_header('Content-Type',"text/xml; charset=utf-8") self.response.out.write(template.render("my_xml",{"key1":"val1"})) This works fine on the local development environment but once I deploy to the Google servers the

Python - What is a lazy property?

元气小坏坏 提交于 2019-12-08 19:26:58
问题 While looking through the webapp2 documentation online, I found information on the decorator webapp2.cached_property (which can be found at https://webapp-improved.appspot.com/api/webapp2.html#webapp2.cached_property). In the documentation, it says: A decorator that converts a function into a lazy property. My question is: What is a lazy property? Thanks! 回答1: It is a property decorator that gets out of the way after the first call. It allows you to auto-cache a computed value. The standard

Set up multiple session handlers on python webapp2

大城市里の小女人 提交于 2019-12-08 12:03:55
问题 I'm writing a simple web application in google appengine and python. In this application I need to handle two types of sessions: the "long term session" that stores information about users, current page ecc, with long max_age parameter and the "short term session" with max_age about 20 minutes that keep an access token for the autentication via API. I have implemented the following BaseHandler: import webapp2 from webapp2_extras import sessions class BaseHandler(webapp2.RequestHandler): def

Error in deployed GAE RequestHandler using Webapp2

女生的网名这么多〃 提交于 2019-12-08 09:56:31
问题 I am using the webapp2 framework on Google App Engine, and I'm getting a basic error in one of my Request Handlers. The app is running ok in the local instance, but causes the following traceback on the deployed version of Google App Engine: Here's the code: import os from google.appengine.ext.webapp import template import webapp2 import logging class MainHandler(webapp2.RequestHandler): def get(self): logging.info('hi there 34') template_values = {} self.response.out.write('hello world 4')