forked from caffeinehit/yell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9452244
commit c879132
Showing
8 changed files
with
137 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,50 +9,63 @@ Pluggable notifications for your Python apps. | |
The full documentation is available `here <http://yell.readthedocs.org/en/latest/index.html>`_. | ||
|
||
|
||
Using yelling decorators | ||
------------------------ | ||
Using notification decorators | ||
----------------------------- | ||
|
||
:: | ||
|
||
from yell.decorators import yelling | ||
from yell import notify | ||
from yell.decorators import notification | ||
@yelling(name = 'buffalo') | ||
@notification(name = 'buffalo') | ||
def buffalo_printer(message): | ||
print message | ||
@yelling(name = 'buffalo') | ||
@notification(name = 'buffalo') | ||
def buffalo_saver(message): | ||
save(message) | ||
yell("buffalo", _("Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo")) | ||
notify("buffalo", _("Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo")) | ||
|
||
|
||
Using yelling classes | ||
--------------------- | ||
Using notification classes | ||
-------------------------- | ||
|
||
:: | ||
:: | ||
|
||
from yell import Yell, yell | ||
from yell import Notification, notify | ||
|
||
class Buffalo(Yell): | ||
class Buffalo(Notification): | ||
name = "buffalo" | ||
message = _("Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo") | ||
def yell(self, *args, **kwargs): | ||
def notify(self, *args, **kwargs): | ||
print self.message | ||
class BuffaloEmail(Buffalo): | ||
def yell(self, *args, **kwargs): | ||
def notify(self, *args, **kwargs): | ||
send_mail("Buffalo", self.message, '[email protected]', [kwargs.get('user').email]) | ||
|
||
class BuffaloDatabase(Buffalo): | ||
def yell(self, *args, **kwargs): | ||
def notify(self, *args, **kwargs): | ||
BuffaloModel.objects.create(user = kwargs.get('user')) | ||
|
||
# The default behaviour is to use every notification backend with the same | ||
# name | ||
yell("buffalo", user = User.objects.get(id=1)) | ||
notify("buffalo", user = User.objects.get(id=1)) | ||
|
||
# Only send emails | ||
yell("buffalo", user = User.objects.get(id=1), backends = [BuffaloEmail]) | ||
notify("buffalo", user = User.objects.get(id=1), backends = [BuffaloEmail]) | ||
|
||
|
||
Changelog | ||
--------- | ||
|
||
**v0.2** | ||
|
||
* Made the API saner to use (*backwards incompatible*): | ||
- ``yell.Yell`` became ``yell.Notification`` | ||
- ``yell.yell`` became ``yell.notify`` | ||
- ``yell.decorators.yelling`` became ``yell.decorators.notification`` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,65 +4,56 @@ yell | |
|
||
Pluggable notifications for your Python apps. | ||
|
||
`yell` is not a notification storage or delivery backend but a set of APIs that make it easy to add your own delivery mechanisms. | ||
`yell` is not a notification storage or delivery backend but a set of APIs that make it easy to add your own delivery mechanisms. | ||
|
||
The full documentation is available `here <http://yell.readthedocs.org/en/latest/index.html>`_. | ||
|
||
Using yelling decorators | ||
------------------------ | ||
|
||
Using notification decorators | ||
----------------------------- | ||
|
||
:: | ||
|
||
from yell.decorators import yelling | ||
from yell import notify | ||
from yell.decorators import notification | ||
@yelling(name = 'buffalo') | ||
@notification(name = 'buffalo') | ||
def buffalo_printer(message): | ||
print message | ||
@yelling(name = 'buffalo') | ||
@notification(name = 'buffalo') | ||
def buffalo_saver(message): | ||
save(message) | ||
yell("buffalo", _("Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo")) | ||
notify("buffalo", _("Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo")) | ||
|
||
|
||
Using yelling classes | ||
--------------------- | ||
Using notification classes | ||
-------------------------- | ||
|
||
:: | ||
:: | ||
|
||
from yell import Yell, yell | ||
from yell import Notification, notify | ||
|
||
class Buffalo(Yell): | ||
class Buffalo(Notification): | ||
name = "buffalo" | ||
message = _("Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo") | ||
def yell(self, *args, **kwargs): | ||
def notify(self, *args, **kwargs): | ||
print self.message | ||
class BuffaloEmail(Buffalo): | ||
def yell(self, *args, **kwargs): | ||
def notify(self, *args, **kwargs): | ||
send_mail("Buffalo", self.message, '[email protected]', [kwargs.get('user').email]) | ||
|
||
class BuffaloDatabase(Buffalo): | ||
def yell(self, *args, **kwargs): | ||
def notify(self, *args, **kwargs): | ||
BuffaloModel.objects.create(user = kwargs.get('user')) | ||
|
||
# The default behaviour is to use every notification backend with the same | ||
# name | ||
yell("buffalo", user = User.objects.get(id=1)) | ||
notify("buffalo", user = User.objects.get(id=1)) | ||
|
||
# Only send emails | ||
yell("buffalo", user = User.objects.get(id=1), backends = [BuffaloEmail]) | ||
|
||
|
||
|
||
API | ||
=== | ||
|
||
.. toctree:: | ||
:maxdepth: 5 | ||
|
||
yell | ||
yell.backends | ||
|
||
notify("buffalo", user = User.objects.get(id=1), backends = [BuffaloEmail]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.