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

method support in function_key_generator / function_multi_key_generator #95

Open
sqlalchemy-bot opened this issue Mar 11, 2016 · 9 comments
Labels
bug Something isn't working

Comments

@sqlalchemy-bot
Copy link

Migrated issue, originally created by Wolfgang Schnerring (wosc)

It would be nice if function_key_generator would support methods in addition to plain functions.

An example implementation is here: https://github.com/ZeitOnline/pyramid_dogpile_cache2/blob/1.0.1/src/pyramid_dogpile_cache2/cache.py#L26

I haven't found a way to do this other than computing the namespace during each function call (instead of only once and storing it in the closure), since at definition time I think you don't have enough information about the function etc. available.

@sqlalchemy-bot
Copy link
Author

Michael Bayer (zzzeek) wrote:

classmethods or instancemethods? the former is very hard. look through the PRs for various handwringing over this. this is why the function is pluggable.

@sqlalchemy-bot
Copy link
Author

Wolfgang Schnerring (wosc) wrote:

I was thinking of instancemethods. But you're right, individual usecases probably vary a lot, so it's a good thing it's pluggable.

@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (zzzeek):

  • edited description

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (zzzeek):

  • changed title from "method support in function_key_generator" to "method support in function_key_generator / https:/"

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (zzzeek):

  • changed title from "method support in function_key_generator / https:/" to "method support in function_key_generator / functio"

@sqlalchemy-bot
Copy link
Author

Michael Bayer (zzzeek) wrote:

Issue #133 was marked as a duplicate of this issue.

@sqlalchemy-bot
Copy link
Author

Krishna Vudata (kvudata) wrote:

It would be ideal to at least raise an error rather than try to incorrectly handle class methods in function_multi_key_generator - right now it will just silently give you back wrong results.

@sqlalchemy-bot
Copy link
Author

Michael Bayer (zzzeek) wrote:

Can you propose a patch which makes this possible? IIRC the issue is we don't know that this callable is a classmethod or not and we have no way to know what this argument is or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant