django-tweet-saved 0.8.1

Tweet Django's saved objects
django-tweet-saved is a Django app that will create a tweet if a model has been saved. Useful to announce news, blogposts, etc.

How does it work?

 * notification via django service
 * shortens url with googl (via python-googl)
 * uses package twitter to tweet the notification
 * remember that an instance has been tweeted (via djangos contentype/generic foreign keys), so notifications are only sent once

How to use it
:

 1. Install, add tweet to your INSTALLED_APPS.
 2. get the oauth token/secret and add it to your settings.py:

 ./manage.py tweet_oauth
 Hi there! We're gonna get you all set up to use tweet_saved.

 In the web browser window that opens please choose to Allow
 access. Copy the PIN number that appears on the next page and paste or
 type it here:


 Please enter the PIN: 1234567
 Please add
 TWEET_SAVED_OAUTH_TOKEN = 'xxxxxxxxx'
 TWEET_SAVED_OAUTH_TOKEN_SECRET = 'xxxx'
 to your settings.py


 3. Register your model

 ...
 from tweet import tweeter

 class MyModel(models.model):
 ...

 tweeter.register(MyModel)


 4. if not present, add a method get_absolute_url to your model.
 5. recommended steps (but not required): Add a property twitter_message to your model to define the message to tweet. This message will automatically shrinked to fit into the 140 character limit.

 If this method is not defined, the object is simply converted to string.

 This is the twitter_message of my object, augmented with hashtags (using the tags from django-tagging):

 @property
 def twitter_message(self):
 reo = re.compile('(%s)' % '|'.join([x.name for x in self.tag_objects]), flags=re.IGNORECASE)
 return 'Blog: ' + re.sub(reo, '#\g< 1 >', self.headline)


 Add a method may_tweet returning a bool, if you want to delay the tweet, i.e. wait until the object is marked as public.

 Example:

 def may_tweet(self):
 return self.published is not None and self.published.date() < datetime.date.today()

 6. If you want to keep track of the shortened urls, get a Google/Googl key, and add it to your settings.py

 GOOGL_KEY = 'xxxx'

last updated on:
February 19th, 2011, 0:48 GMT
price:
FREE!
developed by:
Elmar Athmer
homepage:
github.com
license type:
BSD License 
category:
ROOT \ Internet \ HTTP (WWW)

FREE!

In a hurry? Add it to your Download Basket!

user rating

UNRATED
0.0/5
 

0/5

Rate it!

Add your review!

SUBMIT