horae.subscription 1.0 Alpha 1

GPL


horae.subscription 1.0 Alpha 1

horae.subscription is a Python module that provides generic subscription functionality for the Horae resource planning system.

Usage

Objects marked with the horae.subscription.interfaces.ISubscribeable interfaces receive the functionality of being subscribed to. Which means a viewlet is displayed rendering all subscribers and a button to subscribe and unsubscribe if an adapter implementing horae.subscription.interfaces.ISubscriber and adapting the request is available.

The subscribers of an horae.subscription.interfaces.ISubscribeable may be notified by using the horae.subscription.interfaces.ISubscription adapter. First some basic implementations are required:

import grok

from horae.subscription import interfaces

class Subscriber(object):
 grok.implements(interfaces.ISubscriber)

 def __init__(self, id, name, url=None):
 self.id = id
 self.name = name
 self.url = url

 def notify(self, message, subject):
 """ Sends the message to the subscriber
 """
 print self.name + ': (' + subject + ') ' + subject

 def available(self, context):
 """ Whether this subscriber is currently available or not
 """
 return True

class Message(object):
 grok.implements(interfaces.IMessage)

 def __init__(self, subject, message):
 self._subject = subject
 self._message = message

 def subject(self):
 """ Returns the subject of the notification to be sent
 """
 return self._subject

 def message(self, html=False):
 """ Returns the notification message to be sent
 """
 return self._message

class Subscribeable(grok.Model):
 grok.implements(interfaces.ISubscribeable)

With those implementations in place some subscriptions may be made and a message may be sent to them.

First we create a subscribeable object:

>>> subscribeable = Subscribeable()

Now we create two subscribers and subscribe them to the subscribeable:

>>> subscriber1 = Subscriber('jsmith', 'John Smith')
>>> subscriber2 = Subscriber('jdoe', 'John Doe')
>>> subscription = interfaces.ISubscription(subscribeable)
>>> subscription.subscribe(subscriber1)
>>> subscription.subscribe(subscriber2)


And send out a message:

>>> message = Message('Test subject', 'Test message')
>>> sent, failed = subscription.notify(message)
John Smith: (Test subject) Test message
John Doe: (Test subject) Test message
>>> sent
2
>>> failed
0


Unsubscription is also done using the subscription adapter:

>>> subscription.unsubscribe(subscriber2.id)
>>> sent, failed = subscription.notify(message)
John Smith: (Test subject) Test message
>>> sent
1
>>> failed
0



Product's homepage

Requirements:

· Python
· horae.core
· horae.layout
· horae.ticketing
· grok

Download and use it now: horae.subscription 1.0 Alpha 1 free download

Add a review

Tell us your experience with horae.subscription 1.0 Alpha 1

Related programsOur Recommendations

FOicq 0.1

FOicq is a Oicq clone can be used under FreeBSD, Linux platform, it will be added secure transation

Download

hamsterdb 2.0.4

hamsterdb is a database engine written in ANSI C. hamsterdb supports a B+Tree index structure, uses

Download

Font Finder for Firefox 1.0

Font Finder allows you to get all CSS styles of selected text in Firefox / Thunderbird.Simply

Download

DataSheet Fire Finder 1.0.1.1

DataSheet Fire Finder is a Firefox extension that will add a new small search box, where you can

Download

Gekos Leopard Elementary 1.0

Gekos Leopard Elementary is a GTK theme powered by:- Nautilus Elementary- Aurora GTK Engine-

Download

Nikto 2.1.5

Nikto is an open source web server scanner that is able to perform extensive tests for multiple

Download

TwitPicGTK 0.1

TwitPicGTK is a simple PyGTK software what uses the python-twitpic module to submit images to

Download

Pragha 1.3.0

Pragha is an open source and lightweight music manager software that aims to be fast, bloat-free,

Download

Net::DNSServer::DBMCache 0.11

Net::DNSServer::DBMCache is a AnyDBM_File DNS cache resolver.SYNOPSIS #!/usr/bin/perl -w

Download

Visual Volume Display 1.5

Visual Volume Display (VVD) is a small app for KDE which allows you to easily change ALSA mixer

Download


Thumbnail of horae.subscription 1.0 Alpha 1

Rating:

5 stars

Price: FREE

Publisher/Developer: Simon Kaeser

Release Date: Jun 16, 2012

View Program Details

Top Downloadslast week