Demo Multiple Integrations#117
Conversation
…adjust types to match reality.
|
My first instinct was that we should only ship an extension point here when we have real world use cases from devs.
That said,
I think my instinct is the same. Specifically, it doesn't look like the Do we have a concrete example where typed
Feels like that could be a separate PR? |
|
I did some work today to integrate my tdom-svcs thing with this branch. It helped a lot, the size of my "fork" went down completely. With a little bit more work, my "fork" would be even smaller. Here's a gist writeup with:
|
Yeah it seems like we're getting closer.
Is there a reason you can't use a Also why is it not possible to just resolve the We try to "capture" the
|
|
@pauleveritt I wonder if its possible to just replicate the call to |
|
Ok, I refactored based on both of your comments and today's changes. I don't really need anything upstream from you now, so that's good news. I'm investigating ways to eliminate the module mutable globals on my side. I know you have a lot on your plate, so let me know if you want me to share with you. |
@davepeck
I think my concern is that we can't add it later and if Maybe I'll try some things out. I think most people would expect something like this or at least this is just so brain-dead easy its fun. Maybe we can wrap a def MyComp(my_state: dict[str, object]) -> Template:
...
my_result = html(my_template, app_state={"my_state": {"my_theme": "red"}})
Yes, I brought |
I don't know which mutable globals you're talking about in this area. Is that in your original gist? Do you know if you're able to use a Something like this: SvcsContainerCtx = ContextVar[svcs.Container|None]('SvcsContainerCtx', default=None)
# setup container and setup template processor with custom component processor to use container via
# container_object_or_none = SvcsContainerCtx.get()
# html() call would look something like this
def your_html(template: Template) -> str:
with SvcsContainerCtx.set(svcs_container_object):
return template_processor.process(template, assume_ctx=ProcessContext()) |
|
Closing this for now as we merged #118. |
This has 4 examples in the
processor_integration_test.pymodule:ContextVarto dynamically resolve component callables AND provide extra component kwargsapp_state, the defaultdict[str, object], to provide extra component kwargsapp_state, defined with adataclass, to provide extra component kwargsformat_specthat uses aContextVarto dynamically inject an attribute value into a componentThis doesn't have any implementation of "layering" the app state or context vars where a component in the middle of the tree could change the value. My old example used
ContextVars which I think is more sane probably. There is a place for that to get added but I think we'd do it later which we already discussed.Adding a
app_statetohtml()was really putting things over the edge so I tried to simpifyhtml()as well.