• Stars
    star
    202
  • Rank 192,553 (Top 4 %)
  • Language
    JavaScript
  • Created almost 11 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Telegraphy provides real time events for WSGI Python applications

Disclaimer

Telegraphy (master) is based on WAMP 1.0. We're rewritting it to use a more advanced broker called crossbar.io for asynchronous operations.

Currentrly development is being made in crossbario branch.

Telegraphy

Telegraphy provides real time events for WSGI Python applications with additional features such as event filtering, subscription persistence and authorization/authentication.

It's initially intended for Django but you can extend it to any WSGI framework.

WebSocket pub/sub and RPC is based on AutobahnPython implementation of WAMP protocol

Getting It

You can get Telegraphy by using pip:

$ pip install telegraphy

You will need to have pip installed on your system. On linux install the python-pip package, on windows follow this. Also, if you are on linux and not working with a virtualenv, remember to use sudo for both commands (sudo pip install telegraphy).

If you want to install it from source, grab the git repository from GitHub and run setup.py:

$ git clone git://github.com/machinalis/telegraphy.git
$ cd telegraphy
$ python setup.py install

Installing the Django app

Telegraphy's Django app is installed with the standard procedure: in your projects settings.py file add telegraphy.contrib.django_telegraphy to the INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'telegraphy.contrib.django_telegraphy',
    ...
)

Using It

The django_telegraphy app allows you to easily extend your models so that they generate events on creation, update or delete. Those events will reach your front end in real time.

Simply install the django_telegraphy app in your Django project. Then run the following command in parallel to your web-server:

$ python manage.py run_telegraph

Extend your models so that they automatically generate events: create an events.py file next to your models.py

from models import MyModel
from telegraphy.contrib.django_telegraphy.events import BaseEventModel


class MyEventsModel(BaseEventModel):
    model = MyModel

Finally, prepare some template to receive and show the events:

{% load telegraphy_tags %}
{% load static %}
<html>
    <head>
        <title>Simple Telegraphy API Example</title>
        <script src='{% static "your_app/js/jquery-1.10.2.js" %}'></script>
        {% telegraphy_scripts %}
    </head>
    <body>
        <h1>Catching model events!</h1>
        <ul id="event_catcher"> </ul>
        <script>
            (function (){
                var $event_catcher = $('#event_catcher');
                Telegraphy.register('your_app.MyModel',
                    function (tEvent){
                        console.log("Event", tEvent);
                        var new_line = $('<li/>').text("New instance");
                        $event_catcher.append(new_line);
                    });
            })();
        </script>
    </body>
</html>

And that's it! Every time you create, update or delete an instance of your model, an event will reach your template.

You can find more examples in the documentation.

More detailed documentation

You can read the docs online here. Or for offline access, you can clone the project code repository and read them from the docs folder.

Help and discussion

For help, suggestions and discussions please refer to http://groups.google.com/group/telegraphy

To guide the development efforts, or if you find any bugs, please use GitHub's issue tracker.

Authors

Machinalis also works on some other very interesting projects, like SimpleAI, Quepy and more.

More Repositories

1

quepy

A python framework to transform natural language questions to queries in a database query language.
Python
1,254
star
2

iepy

Information Extraction in Python
Python
905
star
3

featureforge

A set of tools for creating and testing machine learning features, with a scikit-learn compatible API
Python
381
star
4

mypy-django

PEP-484 type hints bindings for the Django web framework
Python
223
star
5

refo

Regular expressions for objects
Python
143
star
6

yalign

A sentence aligner for comparable corpora
Python
127
star
7

satimg

Satellite data processing experiments
Jupyter Notebook
117
star
8

mypy-data

mypy typesheds for the Python data stack
Python
86
star
9

bidderd

RTBKIT Agent using Go and the HTTPInterface
Go
45
star
10

django-i18n-helper

Python
35
star
11

django-fasttest

A variant on django.test.TestCase optimized for postgres
Python
21
star
12

slides

Public talks by Machinalis
TeX
18
star
13

django-template-previewer

A Django app to allow developers preview templates
Python
17
star
14

mypy-django-example

A usage example for mypy-django
Python
15
star
15

django-test-autocomplete

Python
12
star
16

eff

Time tracking and report generation
Python
9
star
17

ninja-django-plugin

Django plugin for Ninja-IDE
Python
4
star
18

inventor

Inventor a very simple django based inventory system.
HTML
3
star
19

protobuf-python3

Google protobuf port to python3
C++
2
star
20

jquery_simple_progressbar

2
star
21

django-migration-tools

Scripts for helping with routine tasks while migration from 0.96 django versions to 1.x
Python
2
star
22

code_time_tracker

Python
1
star
23

ninja_ipython_console

An IPython console plugin for Ninja
Python
1
star
24

machinalis-movie-reviews

Python
1
star
25

alfajor

A site to collect shopping orders for packages of items, designed for an alfajor seller
Python
1
star