Skip to content

Conversation

@delijati
Copy link
Collaborator

Define dependencies class wide :) Sorry for the formatting changes.

Example:

@controller.resource()
class User:
    dependencies = [Depends(user_exists)]

    @controller.route.get("/users/{user_id}", dependencies=[Depends(user_is_id)])
    def read_users(self, user_id: int):
        return {"user_id": user_id}

@KiraPC
Copy link
Owner

KiraPC commented Apr 12, 2021

@delijati

Good feature, but, can you add some documentation that explain it? Maybe in the readme?

I prefer single quote (') instead of double (")

Could you use them?

@delijati
Copy link
Collaborator Author

@delijati

Good feature, but, can you add some documentation that explain it? Maybe in the readme?

Will do.

I prefer single quote (') instead of double (")
Could you use them?

I would rather not ecpecially not for doc strings -> https://www.python.org/dev/peps/pep-0008/#id25 And almost every tool uses double qoutes. I'm just a lazy bastard and use automation for formatting ;) See #17

@KiraPC
Copy link
Owner

KiraPC commented Apr 12, 2021

@delijati

Ok, let's use double.

I started with single because I came from JS :)

Anyway, I will think for automation formatting.

Copy link
Owner

@KiraPC KiraPC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@delijati Please add docs, also in class doc string, before merging it

# add class dependencies
if dependencies:
for depends in dependencies[::-1]:
route.dependencies.insert(0, depends)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@delijati Does route.dependencies always exists?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@delijati I will move it at line 106, just to keep it separated from rewrite sign

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KiraPC KiraPC changed the base branch from master to dev April 12, 2021 15:04
@KiraPC KiraPC added the enhancement New feature or request label Apr 12, 2021
@delijati
Copy link
Collaborator Author

delijati commented Apr 13, 2021

Added some docs. I made the example on the frontpage copy pastable ;)

@KiraPC KiraPC merged commit 77096fb into KiraPC:dev Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants