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

__acl__ was never awaited #5

Open
Tears opened this issue Nov 21, 2020 · 4 comments
Open

__acl__ was never awaited #5

Tears opened this issue Nov 21, 2020 · 4 comments

Comments

@Tears
Copy link

Tears commented Nov 21, 2020

Hi,

First of all, thanks for making this library. I'm on my first FastAPI project right now and we're really liking the library so far.

However, we do run into a little problem when using dynamically generated ACL's. Our app is connected via Tortoise ORM to a PostgreSQL-database, from which we are generating the ACL's in the models. We are required to approach the database async, so we need to make the ACL-function in the model async as well. Like this:

async def __acl__(self) -> List:

    acl = []

    # Do stuff with the database here, and append them as rules in the ACL
    # Example:
    async for attendee in self.parent_activity.get_attendees():
        acl.append((Allow, f"user:{attendee.user.id}", "view"))
   

    return acl

However, when checking the object this ACL is attached to via the Permission-function, we are greeted with the following error:

RuntimeWarning: coroutine 'Activity.__acl__' was never awaited

(Activity is the model name)

Could you maybe implement an await for the ACL's? Like I said, this is my first project with FastAPI so maybe I'm using it all wrong, but we are stuck with this now. Thanks in advance!

@holgi
Copy link
Owner

holgi commented Nov 25, 2020

Hi,

probably you did nothing wrong. I never used an async db access for this - so it's seems to be a case I haven't considered.

I have an idea on how to solve this, I "just" need some time to get to this and I'd like to ask you for some patience.

@Tears
Copy link
Author

Tears commented Nov 28, 2020

Hi, thanks for your reply. Could you describe your idea on how to solve this? Maybe I could take a look then and submit a PR.

@jsenecal
Copy link

jsenecal commented Mar 7, 2022

Is there any progress that was made @holgi ? I too, am hitting this bug with motor/beanie

@Gadgetguycj
Copy link

Running into the same issue as well, will post any protentional solutions I find

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

No branches or pull requests

4 participants