basxsoftwareassociation / bread

Engine to create database applications based on Django and the IBM Carbon Design System
BSD 3-Clause "New" or "Revised" License
19 stars 2 forks source link

extract a function from ObjectFieldValue #96

Closed wipascal closed 2 years ago

wipascal commented 2 years ago

I have a usecase for this in an upcoming PR. (edit: this is the PR https://github.com/basxsoftwareassociation/ponds_next/pull/2)

saemideluxe commented 2 years ago

Hmmm... I see why you need something like this. But I would prefer if we could keep the API to a single class or function for rendering values. We could solve this by makeing the ObjectFieldValue slightly more generic.

object = hg.resolve_lazy(super().resolve(context))

Then we can pass in any lazy value.

wipascal commented 2 years ago

I don't fully understand what you mean. Would ObjectFieldValue then extend Lazy instead of ContextFunction?

saemideluxe commented 2 years ago

Not necessarily but I guess it would make sense in order keep the code easier to understand.

In that case you would not call super(), but still need to run the code that is inside ContextValue.resolve. (I think violating the DYI principle is justified here).

Actually ObjectFieldValue started as a simple "extension" of ContextValue but now it is evolving into a more generic value-formatting tool. Which is better than having a range of options to format values.

saemideluxe commented 2 years ago

Das wäre etwa, was ich vorschlagen würde (parameter-name und doc-string muss ich noch anpassen).

wipascal commented 2 years ago

Das wäre etwa, was ich vorschlagen würde (parameter-name und doc-string muss ich noch anpassen).

passt, ist definitiv besser als so wie ich gedacht hatte dass du es möchtest.

saemideluxe commented 2 years ago

Okay, great (ups, switched to german before :D)