GoogleCloudPlatform / webapp2

webapp2 is a framework for Google App Engine
https://webapp2.readthedocs.org
Other
142 stars 64 forks source link

Update webapp2 auth for standard GAE Python3 #137

Open fili opened 6 years ago

fili commented 6 years ago

The new standard GAE uses Python3, but does not use:

Memcache

Prefers Firestore over Datastore

Does not support Users API

It is still possible to use webapp2 with the new standard GAE Python3, as an example can be found here: https://bitbucket.org/fili/gae-standard-python37-webapp2-example/src

But the overall integration with GAE services are gone and unlikely to ever come back. It would be best to update the code base to be more independent from GAE old services, or support at least all the different Google Cloud database solutions.

theacodes commented 6 years ago

Hi, thanks for filing this issue.

Just a heads up - webapp2 is a community-supported project. Someone in the community will need to volunteer to do this. I am happy to review and merge any pull requests.

AniX commented 6 years ago

In other words, everything in webapp2_extras/appengine/ can't be used anymore? I believe the same is true for the flexible environment.

Are these modifications supposed to be part of webapp2 3.0.0?

fili commented 6 years ago

Well the difference is that it depends on the database solution you choose. When you create a new project, you get the question if you want the future Firestore as a database solution OR Cloud Datastore, with the latter it may still be possible to create a workable solution with minimal code changes but NDB is not supported in flex.

Once you pick a database solution, you can not use the other solution anymore within the same project. And as Firestore is likely to replace Cloud Datastore - based on the documentation I have read so far it is probably best to either upgrade webapp2 to include the Firestore option OR to make the code database solution independent so any database solution (including for example Cloud SQL) would work using adapters or something alike.

kits-ragh commented 5 years ago

I have used webapp2 in my application, Now I am migrating my application in python3, but it gets fail.

Is there any timeline to get the python3 compatible with webapp2 framework.

fili commented 5 years ago

The latest version of webapp2 runs on python3. See also https://bitbucket.org/fili/gae-standard-python37-webapp2-example

fili commented 5 years ago

The problem is that webapp2 has a lot of legacy code for connecting with ndb etc, which is now outdated.

gerardsimons commented 4 years ago

What happened to the repo on bitbucket? I would like to run webapp 2 in Python 3.7. Python 2 is sunsetting in less than a month... https://pythonclock.org/

fili commented 4 years ago

Webapp2 already works on python 3. I moved my repo from bitbucket to github here: https://github.com/fili/webapp2-gae-python37

gerardsimons commented 4 years ago

Ok, my bad, thanks! 🙏

montao commented 4 years ago

I am going to use Flask instead and created a completely new app in appengine. The User entities which were created with webapp2 User model can be migrated to Firestore in Datastore mode and ndb is supported in the Python3 runtime. The Uniqueness property did not work though, but I can check for uniqueness myself. This was the error in python3 runtime when trying to create a User with the create_user function taking the claims from the Firebase authentication object:

User.create_user(claims.get("email")) File "/srv/auth/models.py", line 409, in create_user ok, existing = cls.unique_model.create_multi(k for k, v in uniques) File "/srv/auth/models.py", line 107, in create_multi created = [model.transaction(lambda: func(e)) for e in entities] File "/srv/auth/models.py", line 107, in <listcomp> created = [model.transaction(lambda: func(e)) for e in entities] AttributeError: module 'google.cloud.ndb.model' has no attribute 'transaction'

I am going to retire my old app (which was created in April 2008). I created a new app with Firestore in Datastore mode, connected it with Firebase authentication, migrated all my User entities (which were created with the webapp2 User model) and can connect a Firebase claims object with a User entity.

wescpy commented 1 year ago

For those coming to this late, FYI the App Engine team has added back most of the legacy APIs (now called "bundled services") back to App Engine (2nd-gen platform), meaning Python3 (plus Java 11 & 17, Go 1.12+, PHP 7/8+). However, while webapp2 and the Search API aren't part of this (re)release, the majority of the others are. For more, see the announcement post.

For those who choose to undergo migrating away from the bundled services to Cloud standalone replacements (and webapp2 to Flask), I've been producing migration content (code samples, codelabs [hands-on tutorials], videos) to help you beyond the migration guides provided in the official documentation. Everything is offlinked from this content's open source repo. This is all Python—I have a colleague producing similar content for Java.