Skip to content

Conversation

@asldevi
Copy link

@asldevi asldevi commented Jul 29, 2015

add_url_rules takes the primary key name and its type and passes on to Flask
add as_view in FlaskResource, which is required for creating custom end points dynamically

asldevi added 2 commits July 29, 2015 12:34
… end points

without this, using `FlaskResource.as_view` results in
"TypeError: _wrapper() takes at least 1 argument (0 given)"
@seocam
Copy link
Collaborator

seocam commented May 22, 2017

Hey @asldevi! Could you please provide some tests in order to avoid regression?
Thanks!

@madsmtm
Copy link

madsmtm commented Nov 15, 2018

Hi @asldevi, I love this feature, but I'd like to suggest something a little different. Maybe instead of specifying pk and pk_type in add_url_rules, I think we should specify instance_rule at the class level, so that it can be overwritten by a subclass with e.g.:

class MyResource(FlaskResource):
    instance_rule = r'<int:my_primary_key>/'
    def detail(self, my_primary_key):
        pass

Since the format of the parameters are tightly bound to the implementing class, and not to the Flask URL setup. Ideally, though, I'd like to be able to say:

class MyResource(XXXResource):
    def detail(self, my_primary_key: int):
        pass

And have that independent of the specific Resource implementation.

EDIT: Okay, I realise that this is an OLD issue, so if nobody has any complaints, I might go ahead and implement it myself? ;)

@Marcelo-Theodoro
Copy link
Contributor

@madsmtm If you are avaiable, I think would be really nice!

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

Successfully merging this pull request may close these issues.

4 participants