aiidalab / aiidalab/aiidalab-qe

Improve code setup

Aperta
#724 1 commento 1 reazione 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Python
Stelle
33
Fork
25
Merge medio
6h 7m
PR unite (30g)
8

Descrizione

We're now having discussions about this in three different places, so creating issue just for this.

I think this [comment from Seb](https://github.com/aiidalab/aiidalab-widgets-base/pull/543#issuecomment-1891422892) and subsequent discussion is critical:

> > > @sphuber would you mind taking a look if the changes here make sense? I am not super familiar in how aiida-core handles User instances.
>
> I had a look but I don't understand what the changes to fetching the default user should do. First of, `User.objects` is deprecated, and `User.collection` should be used instead. So the PR changes to use the deprecated version. The current use is correct. To get the default user, `User.collection.get_default()` is correct. The only tricky part here is that this default is cached on the `StorageBackend`. So if the default user is changed, this needs to be reset through `StorageBackend.reset_default_user`. This is done automatically through `Manager.set_default_user_email` but not if you go directly through `Profile.set_default_user_email`.
>
> If you want to manually query for a user given an email, I would recommend `User.collection.get(email='email')`. It is concise and closest in syntax to `User.colelction.get_default()`

Is seems to me that using `StorageBackend.reset_default_user` could be used to get rid of the cached User instance, before setting up the codes.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.