Hi there,

I'd like to add a few real-time features to an existing pyramid app. 
Notifications when queued tasks are complete and some real-time dashboards, 
and chat.

I'm thinking of an implementation that doesn't seem like it would be super 
invasive, but I though I would check here and see if some of you more 
experienced used see any obvious major problems first.

Basically, I want to farm out the realtime elements to a websocket api 
server. FastAPI seems like a good framework to do this. But I'd like to be 
able to use the traversal machinery in pyramid to hit those endpoints in my 
mako templates. So my javascript for opening the websocket can use 
the request.resource_url() pattern and I don't have to do a ton of work to 
figure out where in the external API I should be connecting.

So for example if in my web app I'm at mywebsite.com/users/123456, then I 
can have my websocket enpoint constructed by calling ${ 
request.resource_url(request.api, 'users', '123456') } and it would 
generate a URL as api.mywebsite.com/api/v1/users/123456 where 
"api.mywebsite.com/api/v1" is configured in the .ini file.

To make that work I'd create a resource factory that adds the api property 
to the Root object with the value set in the .ini file.

The pyramid view would continue to provide the current values from a db 
query, so there's a sane default to fall back on in case the websocket 
can't connect. For authentication and authorization, I'd server the redis 
instance I'm already using for server side sessions and just have the 
FastAPI server check that session for whether or not the user is 
authenticated/authorized or not.

I think it should be relatively easy to share the SQLAlchemy models between 
the two frameworks as well.

Is this totally insane? Is there a better way to do this? Am I setting 
myself for a world of pain that I'm not able to see right now? Just 
wondering if anyone can offer any guidance before I buckle down and 
implement this?

I realize some of this is totally out of scope for this mailing list, and 
I"m not asking anyone to comment on whether this is a good idea from the 
FastAPI end of things. Just pretend that all just works. I'm really just 
curious about the Pyramid implementation.

thanks!

-andrew


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/2dc83f7e-a319-45c3-be03-c808a15a62af%40googlegroups.com.

Reply via email to