jrief / django-websocket-redis

Websockets for Django applications using Redis as message queue
http://django-websocket-redis.awesto.com/
MIT License
895 stars 222 forks source link

basestring is not defined #182

Open nikksbagul opened 8 years ago

nikksbagul commented 8 years ago

I am using python 3.4, django 1.9 and I got 'basestring is not defined' error. So I replaced basestring word with str into '_get_message_channels' method of 'redis store' class in 'redis store' file, now it's working fine. Please make appropiate changes into these package.

Thank You.

Dharmik8478 commented 8 years ago

I also got same issue and I replaced 'basestring' with 'str' to solve problem.

ticalcster commented 8 years ago

A coworker had the same issue on Python 3.4 and Django 1.9. Looks like setting users or groups to a string is deprecated. You should be passing in a list or tuple of user or group names.

if isinstance(groups, (list, tuple)):
    # message is delivered to all listed groups
    . . .
elif isinstance(groups, basestring):
    # message is delivered to the named group
    warnings.warn('Wrap a single group into a list or tuple', DeprecationWarning)
    channels.append('{prefix}group:{0}:{facility}'.format(groups, prefix=prefix, facility=facility))

redis_store.py:128

nanuxbe commented 6 years ago

There is also an issue when passing in a lazy object (like a queryset) or a generator (as it's not a list of tuple).

I'll try to upload a fix in the next few days

venkatpython commented 3 years ago

Got the same issue, basestring is not found and I'm using the Python 3.7 and Django 3.0. Now I'm sending the users as a list or tuple to avoid this issue now. it would be great, if we can use the six module to make this compatible since we are in early stage of python 2 to 3 transition or use the proper exceptional handling.

from six import string_types elif isinstance(users, string_types):

or

try:
      basestring
  except:
      basestring = str
jrief commented 3 years ago

I know, I should remove the Python-2 compatibility layer 🤔