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

globals().get('user') ceases to exist after creating another database #513

Open
kevinkosterr opened this issue May 4, 2021 · 3 comments
Labels

Comments

@kevinkosterr
Copy link
Contributor

kevinkosterr commented May 4, 2021

I have looked at Issue #121. Someone provides creating a decorator as a solution, this seems inconvenient as i'm trying to use globals().get('user') in the layout. I get that that works, but I still find it weird that it stops existing.

Literally right after I create another database, globals().get('user') ceases to exist within views and controllers. However, globals().get('auth') does exist, but only within the controller.

This is for globals().get('auth') within the index() controller:

ic| globals().get("auth").get_user(): {'email': '[email protected]',
                                       'first_name': 'John',
                                       'id': 1,
                                       'last_name': 'Doe',
                                       'username': 'johndoe'}

and this is for globals().get('user') within the index() controller.

ic| globals().get('user'): None

calling either globals().get("auth") or globals().get('user') in a view, just returns None.

@nicozanf nicozanf added the auth label Sep 22, 2021
@mdipierro
Copy link
Contributor

Do not understand what you mean by "stop existing". I suspect this has to do with the order of validators. auth and auth.user fixtures should inject the user in template. template must appear first in the list of fixtures. If problem persists, can you provide an example app?

@mdipierro
Copy link
Contributor

Sorry for the delay. Is this issue current? Can you provide an example of how you create another database?

@kevinkosterr
Copy link
Contributor Author

As it's been quite some time since I touched py4web, I'll see if I have time tonight to try and reproduce the issue in the most recent version. Keep you posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants