webapp2

What's the best way to get data back from a Task in GAE to form a loop of Task Queues?

╄→гoц情女王★ 提交于 2019-12-24 17:58:52
问题 I have a long-running process in a task queue that is causing a DeadlineExceededError because the task can take longer than 10 minutes. As I described in this question, the long-running process has a for loop that sequentially calculates new values in large dictionaries that are used to create kml files. The task currently looks like this: class longprocess_handler(webapp2.RequestHandler): def post(self): #This is currently one task that recursively uses data in dictionaries to #produce kml

Google App Engine Python Webapp2 301 redirect from www to non-www domain

僤鯓⒐⒋嵵緔 提交于 2019-12-23 03:40:16
问题 I have an application built on gae. I use python with webapp2 framework. I need to make 301 redirect from www.my-crazy-domain.com to my-crazy.domain.com so to eliminate www and not-www doubles in search results. Does anybody have ready-to-use solution? Thanks for any help! 回答1: I'v made the trick. class BaseController(webapp2.RequestHandler): """ Base controller, all contollers in my cms extends it """ def initialize(self, request, response): super(BaseController, self).initialize(request,

Using GAE remote api for debugging from localhost - Connecting too late?

≯℡__Kan透↙ 提交于 2019-12-23 02:38:12
问题 Trying to use Google App Engine's remote_api so that we can do line-by-line debugging through the IDE. The remote api works great at first. The application is able to successfully retrieve information from the database. The error occurs when wepapp responds to the client browser. The Code: It is very similar to the example given in app engine's documentation: from model import My_Entity from google.appengine.ext.remote_api import remote_api_stub # Test database calls def get(w_self): remote

webapp2 Route to match all other paths

╄→尐↘猪︶ㄣ 提交于 2019-12-22 08:27:22
问题 I've the following code in my main app. I expect all paths other than the first two to be caught by the last route (/.*). But I get 404 error. What am I missing? import webapp2 from webapp2 import WSGIApplication, Route # ---- main handler class MainPage(webapp2.RequestHandler): def get(self): ret = jinja2render.DoRender(self) return ret routes = [ Route (r'/rpc', handler = 'rpc.RPCHandler'), Route (r'/secured/somesecuredpage', handler = 'secured.securedPageHandler'), Route (r'/.*', handler =

How to create a query for matching keys?

左心房为你撑大大i 提交于 2019-12-22 05:07:26
问题 I use the key of another User, the sponsor, to indicate who is the sponsor of a User and it creates a link in the datastore for those Users that have a sponsor and it can be at most one but a sponsor can sponsor many users like in this case ID 2002 who sponsored three other users: In this case this query does what I want: SELECT * FROM User where sponsor =KEY('agtzfmJuYW5vLXd3d3ILCxIEVXNlchjSDww') but I don't know how to program that with python, I can only use it to the datastore. How can I

How to create a query for matching keys?

与世无争的帅哥 提交于 2019-12-22 05:07:08
问题 I use the key of another User, the sponsor, to indicate who is the sponsor of a User and it creates a link in the datastore for those Users that have a sponsor and it can be at most one but a sponsor can sponsor many users like in this case ID 2002 who sponsored three other users: In this case this query does what I want: SELECT * FROM User where sponsor =KEY('agtzfmJuYW5vLXd3d3ILCxIEVXNlchjSDww') but I don't know how to program that with python, I can only use it to the datastore. How can I

How to handle uploaded files in webapp2

流过昼夜 提交于 2019-12-22 04:32:22
问题 Google appengine's webapp2 has a very cryptic documentation regarding the handling of uploaded files. Uploaded files are available as cgi.FieldStorage (see the cgi module) instances directly in request.POST. I have a form which makes a POST request of JSON files which I want to store in an NDB.JsonProperty. Can anyone offer a short example of how do I read the file from the request object? 回答1: You can use enctype="multipart/form-data" in your form, and then get file content by using in your

How to handle uploaded files in webapp2

╄→尐↘猪︶ㄣ 提交于 2019-12-22 04:32:02
问题 Google appengine's webapp2 has a very cryptic documentation regarding the handling of uploaded files. Uploaded files are available as cgi.FieldStorage (see the cgi module) instances directly in request.POST. I have a form which makes a POST request of JSON files which I want to store in an NDB.JsonProperty. Can anyone offer a short example of how do I read the file from the request object? 回答1: You can use enctype="multipart/form-data" in your form, and then get file content by using in your

webapp2, Jinja2: how to cut large html file into multiple html files

若如初见. 提交于 2019-12-21 22:00:52
问题 When I blog, I like to separate each blog-post into its own .html file (is that ok?) This prevents the file getting too big, and makes it easy to go back and edit a previously written blog post if need be. Occasionally the blog post will contain css/js/ajax/template variables. But on my website, I like all the blog posts on one page (so I can scroll through them all, instead of going to a separate page for each post) Here is an html file that contains two blog posts: {% extends "base.html" %}

Python webapp2: redirect back

梦想的初衷 提交于 2019-12-21 20:48:52
问题 I'm using the google app engine for a basic app. The scenario is simple: i click Logout and I want my Logout handler to redirect me back to the page from where I came from. How do I achieve this? thnx 回答1: When creating logout url you can pass in the url you want user to be redirected to, in your case his current url. Something like this (I'm not Python dev, so ...): users.create_logout_url(self.request.url) 来源: https://stackoverflow.com/questions/10889236/python-webapp2-redirect-back