FAQ Database Discussion Community


Redirect old website urls in new GAE/Python/webapp2 website

python,regex,google-app-engine,url-redirection,webapp2
To maintain search engine rankings, I am redirecting the URL paths from the old website (static html) to specified paths in the newly designed website. For example: if the old website contains /contact-us.html, the new website should redirect that path to /contact-us My approach involves creating a handler which simply...

app engine update all sessions for user

google-app-engine,webapp2,gae-sessions
In my gae application, a user can do an action (buy something). I need that information stored persistently and available imediately on all requests from all sessions of this user on multiple devices/browsers. I'm using webapp2_extras sessions. The way I'm thinking of doing this is either: 1) adding the action_happened...

RBAC in webapp2 with ACL from tipfy

google-app-engine,webapp2,rbac,tipfy
I'm trying to implement an RBAC in webapp2. I find out some code of the framework project called tipfy that do this with ACL (access control list). This is the code of the ACL module: https://github.com/moraes/tipfy/blob/master/tipfy/appengine/acl.py But I don't see how to use this code inside a handler in webapp2....

Google App Engine: store uploaded file in Google Cloud Storage

python,google-app-engine,webapp2
I have managed to create a file in GCS in the post method of a webapp2 handler of a Google App Engine application. I can't see how to copy the content of a posted file in the file created in GCS. Here is my code inFile = self.request.POST.multi['file'].file gcs_file =...

GAE Python unable to write file properly to Cloud Storage

python,google-app-engine,google-cloud-storage,webapp2
I am unable to figure out what I am doing wrong while uploading file using web form (python, webapp2, gae) and writing to cloud storage (GCS) jinja2 template <form action="/upload_data" method="post"> <input type="file" name="add_scanned_data_file" enctype="multipart/form-data"> <input type="image" src="stylesheets/add_data.png" alt="submit" align="left"></form> webapp2 code fx = self.request.body_file fx_name = "some_name" gcs_file =...

How to do SEO Url changes and Redirects for google AppEngine Webapp2 Urls?

python,google-app-engine,webapp2
I am moving my company website to google app engine, Its mostly static content with small sections like dates to be generated using python. I have setup everything correctly and its working fine on app engine . Now i want to make few seo related url changes. this is the...

Using App Engine Cloud Endpoints to access ndb datastore

python,google-app-engine,google-cloud-endpoints,webapp2,google-datastore
I'm sorry if this question is redundant or not well-conceived, but I am new to App Engine, and I'm not sure about the best practices for what I'm attempting to do. I have an iOS app, and I want to use http GET and POST requests to put and query...

Python Google App Engine. GET Request sent twice

python,google-app-engine,jinja2,blobstore,webapp2
A GET Request is being sent twice when a User clicks a link in a Google App Engine, Python App. The App uses webapp2 and jinja2. This only happens if a Blobstore image is missing from the Datastore Model, "Event". If the image is present in "Event", there is only...

How to construct and store the geopoint

google-app-engine,twitter-bootstrap-3,geolocation,webapp2,geopoints
Am working on GAE with python. How to construct and store the latitude and longitude using GeoPoint? This is my DB class Customer(db.Model): name = db.StringProperty() address= db.PostalAddressProperty() geopoint= db.GeoPtProperty() My code class AddCustomerHandler(BaseHandler): input_fullname=self.request.get('fullname') input_cusaddress=self.request.get('cusaddress') input_latitude=self.request.get('latitude') input_longitude=self.request.get('longitude') input_geopoint= GeoPoint(input_latitude, input_longitude)...

How to serve a pdf as a download programmatically in GAE and Webapp2?

google-app-engine,pdf,webapp2
I am a newbie at using GAE and am at my wits end. I have a webpage displaying a form which when submitted (using angularjs $http) is supposed to result in the user being offered a pdf to download. The pdf is in the root directory of the folder I...

GAE/webapp2: Serving Excel file created by script using xlwt

python,google-app-engine,webapp2,xlwt
I am trying to use google app engine, webapp2 and a script based on xlwt that calls its save method to create a specific excel file in situ and let it be downloaded by the user. Now I have tried several different approaches according to various websites, but none so...

How do I pass multiple variables from one handler to another in GAE?

python-2.7,google-app-engine,jinja2,webapp2
I want to redirect users to a confirmation page that will display both subject and content (if there is any) if they enter a valid subject, but stay on the same page and display an error if the subject is either blank or over three hundred characters. Here is my...

Export js file for users

javascript,json,laravel,amazon-s3,webapp2
Semi-new to the backend world. In the process of creating a small web app for my work place. I just want to find out what the best method will be to give the end user a script that they put on their site. i.e. how google give their analytics script....

Google app engine: fetching a lot of urls and data processing

python,google-app-engine,python-2.7,webapp2
In my app I fetch a large number of urls and parse information. I am trying to use deferred library and task queues. I split fetching of every single page into separate task with following processing. Below is an example of deferred task: def deftask(somevalue, pagenumber): fetch url parse with...

GAE webapp2 delete all UserTokens (drop all sessios) for specific user

python,google-app-engine,webapp2
I want to drop all user sessions when user resets his password, but I can't find a way to do that. My idea was to get all UserTokens of the specific user and delete them, but it seems impossible, because of user = model.StringProperty(required=True, indexed=False) in UserToken model Any ideas...

Webapp2 Redirect Method

python,google-app-engine,webapp2
I am trying to redirect a POST request from an Google App Engine Python Handler to another URL. The Problem is that it seems the method is changed to GET. Is there any way to set the POST method when redirecting?

Comma in json string causes json.loads to fail with “Unterminated string starting at:”

python,json,google-app-engine,python-2.7,webapp2
This is my test command: curl -v -A 'TEST/1.0' -X POST -d 'events=[{"event":"reset", "test":"reset;123"}]' 'http://127.0.0.1:8080/_api' This is my RequestHandler class MyWebhookHandler(webapp2.RequestHandler): def post(self): events_json = self.request.get('events') event_datum = json.loads(events_json) # exception here Whenever I reach the json.loads line, I got this exception: event_datum = json.loads(events_json) File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in...

How should I store an entity key in a webapp2 session?

google-app-engine,session,webapp2
I've been trying to use webapp2 to store user data in session. I tried to store the Key of the parent object in session data: self.session['client'] = client.key But I keep getting a: TypeError: Key('Client', 6401356696911872) is not JSON serializable How should I store an entity key in a session?...

Using Google App Engine Property's verbose_name in jinja2

python,google-app-engine,jinja2,webapp2
I am developing a simple web application with Google App Engine and I'd like to understand how to use the verbose_name option on Properties correctly. I have a simple model: from google.appengine.ext import ndb class Person(ndb.Model): name = ndb.StringProperty(required=True, verbose_name='my_name') surname = ndb.StringProperty(required=True, verbose_name='my_surname') Then I have a very simple...