Code Monkey home page Code Monkey logo

django-announce's People

Contributors

ozkatz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

django-announce's Issues

Having to use redis store for persistent data

I want to use announce.js for an already written project in django and using mysql. I am using announce.js for the notifications. As I can see current implementation would require auth data to be in redis store. I was thinking as an enhancement to be able to use auth data from other db's and use redis store for notifications only. Would that make sense. I am not sure but I almost have some code written for this

request.user.is_authenticated

inside AnnounceCookieMiddleware.process_response(), I saw a line calling

response.user.is_authenticated which calls

from django.contrib.auth import get_user
request._cached_user = get_user(request)

->

104 -> def get_user(request):
105 from django.contrib.auth.models import AnonymousUser
106 try:
107 user_id = request.session[SESSION_KEY]
108 backend_path = request.session[BACKEND_SESSION_KEY]
109 backend = load_backend(backend_path)
110 user = backend.get_user(user_id) or AnonymousUser()

"backend" here is 'django.contrib.auth.backends.ModelBackend'. Thus, "backend.get_user(user_id)" calls
->

61 def get_user(self, user_id):
62 try:
63 return User.objects.get(pk=user_id)
64 except User.DoesNotExist:
65 return None

which seems like a blocking call to mysqldb.

Is there a setting / backend that I am missing? I thought using node.js (which is async server) requires ( if we want to use async features..) non-blocking db calls...

Please tell me I'm wrong... I think this app is amazing except those lines, and I really want to use this in my project.

Now I am thinking of writing a session sharing middleware (or just use django-redis-sessions) to let node.js read session info from redis.

Kindly upgrade your app for django 1.8

There is no simplejson after 1.6 or 1.5

Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/home/coldfusion/skworkspace/virtual_notification/local/lib/python2.7/site-packages/django/core/management/init.py", line 338, in execute_from_command_line
utility.execute()
File "/home/coldfusion/skworkspace/virtual_notification/local/lib/python2.7/site-packages/django/core/management/init.py", line 312, in execute
django.setup()
File "/home/coldfusion/skworkspace/virtual_notification/local/lib/python2.7/site-packages/django/init.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/coldfusion/skworkspace/virtual_notification/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/coldfusion/skworkspace/virtual_notification/local/lib/python2.7/site-packages/django/apps/config.py", line 86, in create
module = import_module(entry)
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/home/coldfusion/skworkspace/virtual_notification/local/lib/python2.7/site-packages/announce/init.py", line 4, in
from django.utils import simplejson as json
ImportError: cannot import name simplejson

Announce seems not to work

Hi, I write this issue, because I followed what the README told about how to configure Announce, but it seems not to work.
I paste here my base.html head:

{% load announcetags %}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    {% announce_js %}
    <script src="/apps/site/bower_components/lodash/dist/lodash.js"></script>
    <script src="/apps/site/bower_components/angular/angular.js"></script>
    <script src="/apps/site/bower_components/restangular/dist/restangular.js"></script>
    <script src="/apps/site/bower_components/angular-ui-router/release/angular-ui-router.js"></script>

    <script src="/apps/site/js/app.js"></script>
    <script src="/apps/site/js/controllers.js"></script>

    <script type="text/javascript">
        // use .on() to add a listener. you can add as many listeners as you want.
        announce.on('notifications', function(data){
            alert("Notification received");
            console.log("Notification received");
        }).init();
        // .init() will authenticate against the announce.js server, and open the WebSocket connection.
        console.log("Announce.js inited");
    </script>
</head>

here my viewset in Django:

class WordViewSet(viewsets.ModelViewSet):
    queryset = Word.objects.all()
    serializer_class = WordSerializer

    def post_save(self, obj, created=False):
        if created:
            print 'OBJECT CREATED'
            announce_client.broadcast('notifications', data={'msg': obj.word})

and here my settings.py (the interesting part):

MIDDLEWARE_CLASSES = (
    'announce.middleware.AnnounceCookieMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ANNOUNCE_CLIENT_ADDR = 'localhost:5500'
ANNOUNCE_API_ADDR = 'localhost:6600'
ANNOUNCE_HTTPS = False

I also added a settings.json file to use the local memory instead of redis:

{
    "storage": "mem"
}

And that's it.
I tun the server with node server.js --config=settings.json

I expect an alert when i POST a new word, but nothing happens.
Thank you in advance

Announce Client Address?

In your documentation you have:

ANNOUNCE_CLIENT_ADDR - defaults to 'localhost:5500'. should probably be changed for production.

What should this be changed to for production?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.