I want to use django-websocket-redis for more than one type of app. I touched on this the other day, but didn't really collect my thoughts enough and thus removed the issue.
I think in the simplest form, I want to have different subscribers for different facilities. Much like Django's urls.py in how a regex points to a view. For example, we could define WS4REDIS_SUBSCRIBERS like below, where the key is a regex matched with the request's facility string. Then the WsgiServer would map the request to the correct Subscriber class (perhaps returning a 404 if there are no matches).
WS4REDIS_SUBSCRIBERS = {
'someapp': 'mysite.subscribers.SomeAppSubscriber',
'chat-(.*?)': 'mysite.subscribers.ChatSubscriber',
...
}
# The current behavior (allowing anything) could be achieved with the following..
WS4REDIS_SUBSCRIBERS = {
'.*': 'ws4redis.subscriber.RedisSubscriber',
}
Here is a working prototype showing how this could work which falls back to the current behavior. If this were accepted, a few more things need to be thought out first:
WS4REDIS_ALLOWED_CHANNELS may need to be split as well, perhaps a class-method on the subscriber class (and remove the setting all together, just override it like the other methods described in the documentation). Patch also added, is simplifies a bunch of code in the wsgi_server as well.
Remove fallback WS4REDIS_SUBSCRIBERS to WS4REDIS_SUBSCRIBER?
I want to use django-websocket-redis for more than one type of app. I touched on this the other day, but didn't really collect my thoughts enough and thus removed the issue.
I think in the simplest form, I want to have different subscribers for different facilities. Much like Django's urls.py in how a regex points to a view. For example, we could define
WS4REDIS_SUBSCRIBERS
like below, where the key is a regex matched with the request's facility string. Then the WsgiServer would map the request to the correct Subscriber class (perhaps returning a 404 if there are no matches).