Tweepy and streaming - django

im playing with django and tweepy, and im really don't know how i can use this example about Streaming with django
how i can pass the streaming data to my context?

I would suggest that you investigate using websockets for this type of thing, run the linked tweet streaming script as a separate service using django-websocket (or something similar) and push the content back to the open html5 websocket.

Related

Website using Python Oracle and Javascript

I have a HTA tool that connects to oracle database. It's created using HTML,Javascript and oracle as backend.
Javascript connects to oracle database using OLEDB drive. It pulls data and create dynamic rows.
Tool is working but now am planning to convert it as Web Application.
Being a DBA , am not that much familiar with Java and i thought i will explore options in Python.
I have recently done a automation using Python and Selenium. So yes , i know bit of Python. But i have no idea about website using python.
I also don't want to change lot of code. I want javascript to do all the dynamic front-end stuffs.
All i need is interface that can connect to oracle database and pull the information and pass it to javascript function.
Can someone please guide to how to start with.
Thanks.
I don't know Python but if you don't want to change a lot of code, you may consider PHP. It's made to generate HTML code dynamicaly.
It is dangerous to connect to your DB directly by using javascript. Every user can read the JS code in the page and event modify it(sending every value they want).
PHP is executed on the server, it mean that you can check and validate the received value before risking to corupt your DB.
That's why a PHP page between the JS and the DB is better. Python should be secure too but I think it's easier to use PHP because it's open source and well documented.
I wish you a good continuation!

Live notification/chat in django

I am making a website with django now and I want to implement a live notification feature like the one on facebook or SE.
I did some research and it seems although there's two options: ajax long polling and websockets, the latter is the way to go.
However, as you know the go to plugin for websocket 'socket.io' turns out to be a node.js plugin and the django port only seems to support python 2 and the project seems pretty much dead. I am using python 2.7 as my project interpreter but I want to future proof myself so that if I upgrade to python3 later, I don't find myself not being able to use this functionality.
So my question is this:
Is there a straight forward and future ready way to implement websocket which will be used to send live notifications and chats in django env?
Django itself is build in blocking manner, i.e. with synchronous approach. So, you cannot open persistent websocket with django app, as it will block entire django thread.
If you want to enable notification/chat within django project environment, i would recommend to use centrifuge. It is written in python, but async (non-blocking) framework is used: tornado.
But, you don't need to even know how it works, as it provides simple REST api to communicate with it.
Simplified workflow, check docs for more details:
Start centrifuge at same server, as your django project (or on another but with low latency between them)
Your front-end will open websocket with centrifuge, not with django project.
When you need to send notification, send it to centrifuge from django via REST api, and centrifuge will deliver it to needed clients!
I've already tried it and it works!
Django doesn't provide what you're looking for out of the box. You'll have to use a third party library. One that works across frameworks is Pusher.
I think you must go for Firebase it gives you awesome synchronization and any how you are going to use chat on frontend so its does not have to do anything with django environment so you can update you backend asynchron in callback with firbase. Also firebase with AngularJS provides you really really awesome three way binding.

Getting node.js and Django on same domain

For a brief overview/desciption, I am using Django as the bread and butter for a webapp. I want to add a bunch of "real-time" features to the app. More so then I can do with stuff like Torndao or django-socketio. So what I would like to do is take the full dive and use Django with node.js. Basically, Django will get all the data and and handle all the accounts. Then when a piece of data changes, it will send a message using AMQP which will route the message to node.js. Node.js will then use socket.io to get the fresh data to the browser.
My question is how to get the two to play together. Specifically, how can I get both on the same domain so that when the client connects to
var socket = io.connect('http://thedomain.com');
it will be dealt with by node.js and all the other requests will go to Django? Also, I would ideally like to have the Django app running on Heroku as a standalone app and have the node.js also running on Heorku on the standalone app, if possible. Any tips or pointers would be greatly appreciated! Thanks!

ColdFusion and Streaming APIs... (i.e. Twitter)

Has anyone had any luck using ColdFusion as a way to collect data via streaming APIs?
i.e. - https://dev.twitter.com/docs/streaming-api
I know the best option is to use an app that literally sits on the server monitoring these portals. Just curious if anyone has done anything using CF yet.
Aaron Longnion built refynr.com using CF9. It's a service that collects users' Twitter streams based on supplied criteria. I imagine he's down something like you describe.
However, I'd look into the new web socket functionality built into ColdFusion 10 and see if that makes consuming streaming APIs any easier.
http://labs.adobe.com/technologies/coldfusion10/
If you know a bit of Java, it may not be too difficult to use Twitter4J, and build an event gateway for your CF app to consume the stream.
If you want to go the web socket route, see: Twitter + HTML5 webSocket API

data push using django

I'm interested in doing data-push from django to flex, can this be done using pyamf (tutorials or examples are highly appreciated)?
I would like to do it in such a way that when something is changed in the database, the client are notified of that change.
I haven't done it, and it looks difficult.
What does BlazeDS Livecycle Data Services do, that something like PyAMF or RubyAMF not do?
PyAMF gives you the tools to send and receive AMF messages in Python.
But Django isn't suited to push, as normally for push you'd use socket connections rather than HTTP.
Which probably means having a Twisted server as well. You could still use Django... you'd maybe have signals code in your models telling the Twisted server to send a message back to the Flex client.
You'd still have to write all the data-binding type code yourself on the Flex side, though PyAMF provide example client code to get you started.
Apparently the Java frameworks for Flex do code generation for both sides, making it all much easier.