Best way to manage reference to RedisPublisher for browser-persistent session...?
Firstly, thanks for DWR, it's awesome and is exactly what I needed :)
I'm looking for a hint which will hopefully clarify the docs and examples a bit. I have a "landing page" view in my Django app, where users are taken after successful login. This "PortalView" displays the users' available objects (where the objects are arbitrary custom Python models), and is obviously where I want to start my RedisPublisher (for subscribe-user). The use of DWR here is to provide updates to the states of each object in the client portal when changes take place to them.
Effectively what I want is something like this:
example views.py:
class PortalView(View):
def post(self, request):
login_user(request.user)
rp = new RedisPublisher(facility='foo', users=[SELF])
return render(template.html)
def someView(request):
update_state_somehow(object)
rp.publish_message('object': 'objectid', 'state': 'nustate')
def otherView(request):
update_state_differently(object)
rp.publish_message('object': 'objectid', 'state': 'otherstate')
Though obviously the reference "rp" is not in scope for either someView() or otherView().
So my question is: what's the best way to ensure the availability of the RedisPublisher reference? How do people do this? Is it best to serialize the reference and save it as session data? Perhaps pickled as described here: https://docs.djangoproject.com/en/1.8/topics/http/sessions/#django.contrib.sessions.serializers.PickleSerializer
Any opinions or suggestions warmly received! Cheers, Dan
I notice at the bottom of https://github.com/jrief/django-websocket-redis/blob/master/docs/installation.rst it says:
Never store session data in the database in combination with Websockets for Redis!
Should I infer from this that storing a PickleSerialized reference to a RedisPublisher object is a bad idea?