Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add google datastore as backend #109

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

ghost
Copy link

@ghost ghost commented Nov 5, 2019

No description provided.

@kiptoomm
Copy link

kiptoomm commented Jan 6, 2020

hey @fengsp, any chance to merge this any time soon?

@ghost
Copy link
Author

ghost commented Jan 9, 2020

Hi @kiptoomm,
We are waiting too for this approval, you can use our own flask-session fork instead.

You will need to set the following settings into the Flask application in order to use our fork:

'SESSION_TYPE' = 'datastore'
'GCLOUD_APP_PROJECT_ID': '<your_app_project_id>'

Best regards.

@kiptoomm
Copy link

Hi @kiptoomm,
We are waiting too for this approval, you can use our own flask-session fork instead.

You will need to set the following settings into the Flask application in order to use our fork:

'SESSION_TYPE' = 'datastore'
'GCLOUD_APP_PROJECT_ID': '<your_app_project_id>'

Best regards.

Thanks @alvarogf-vt, nice solution. With this implementation, how are the session objects stored? For example, with a mongodb backend, they're stored in a database called flask_session and collection sessions. We can access the objects thru mongo shell (command line). That is, I'm wondering what the datastore equivalents to the above are, if any.

@kiptoomm
Copy link

kiptoomm commented Jan 16, 2020

Hey @alvarogf-vt, I also noticed/had a couple of issues/questions arising from jinfantes@2162ca0:

  • Did you mean to hard code your project id ('virustotal-***'), or shouldn't it be read in from the config variable GCLOUD_APP_PROJECT_ID?

  • I had to set GOOGLE_APPLICATION_CREDENTIALS env var to avoid google auth problems similar this SO post

  • How should this be used locally? Based on the commit linked above, I guess that we need to set a DATASTORE_EMULATOR_HOST env variable. As exemplified in the official docs, I went ahead and set mine to something like:

export DATASTORE_EMULATOR_HOST=localhost:8432

However, it somehow interfered with my other calls to a remote instance of data store that I use for storing other values (that is, it looks like I cannot fetch my cloud datastore entities while using the datastore emulator) :(

Any advice on how to use your implementation locally would be greatly helpful.

@ghost
Copy link
Author

ghost commented Jan 17, 2020

Hi @kiptoomm

I meant you need to configure the Flask application as above:

import flask

app = flask.Flask(__name__)
app.config['GCLOUD_APP_PROJECT_ID'] = os.getenv('GCLOUD_APP_PROJECT_ID')

so you can pass GCLOUD_APP_PROJECT_ID as an os environment variable, this variable is needed in order to connect with your datastore instance once it has been deployed on Google cloud platform.

You can run your application with the google datastore emulator by executing dev_appserver.py from the google cloud SDK with the datastore options

GOOGLE_APPLICATION_CREDENTIALS needs to be set in order to execute dev_appserver.py locally, but the google internals tools know how to get project ID from this file, it could be interseting to investigate the way they have to do that in order not to require GCLOUD_APP_PROJECT_ID.

christopherpickering added a commit to christopherpickering/flask-session2 that referenced this pull request Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants