-
Notifications
You must be signed in to change notification settings - Fork 234
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
Make StringProperty choices parameter callable to enable dynamic lookups #291
Comments
The ultimate purpose of It could well be that these choices are dynamic. But where would this leave batch operations? Would this mean triggering one additional query for every db operation to ensure that the attribute takes the (currently) valid value? I wonder if this is something that can be addressed with a change in the model. That is, turn the attribute into an entity and attempt to establish a relationship with one of the existing nodes. If I am way off the mark here, please provide a longer description so that we can see if we could turn this into a feature (?). |
I think that providing a callable instead of a list of tuples gives a lot of flexibility. What the callable does to return its values is up to the programmer. Of course if one puts queries or other expensive calls in the callable that might impact performance negatively. Of course the negative effects could be mitigated by caching of some sort. But again, that is the responsibility of the user. |
@mjmare Alright, I would mark this as an "enhancement" at the moment but I think that it would be best if ause-case scenario was provided for this to see where it fits within the bigger picture. What do you think? |
Hi @aanastasiou, I wouldn't know what to add beyond what I've written above. |
@mjmare I am sorry I am picking this up so late. I see what you mean. This has been added to the Wiki already. |
No prob, I appreciate your efforts! |
Currently the choices parameter accepts a static list of tuples. It would be nice if one could specify a function that provides a list of tuples. This enables dynamically looking up the list of allowed values. For example the function could do a query in the database to get the allowed values.
The text was updated successfully, but these errors were encountered: