tweets django module

Twitter posts module.

This module has two processes:

Management commands: creating data

twitter_retweets

Background command to create Stat for twitter Posts.

Poll the Twitter post list api with the list of post ids for posts we want to update stat for.

Run with:

buzzdetect twitter_retweets

twitter_stream

Connect to twitter’s stream API and maintain database in sync.

The twitter_stream command run continuously in the background to insert new tweets, retweets, and friends.

This management command follows one twitter account per thread. Then, spawns a thread per twitter stream api message received.

Run with:

buzzdetect twitter_stream

AppConfig: Twitter specific config

AppConfig for this module.

class tweets.apps.TweetsConfig(app_name, app_module)[source]

Twitter specific global config.

account = 'twitteraccount'
account_create_url = <django.utils.functional.__proxy__ object>
loggers = (('tweets.stream', 'Post insert'), ('tweets.retweets', 'Post stat'))
name = 'tweets'
pk = 1
poster_stat_per_kind = False
poster_stat_refresh(poster)[source]

Refresh the PosterAverageStats of a given poster.

static previous_minutes(minute)[source]

Return the list of previous minutes for minute.

score_unit = 'retweet'
score_unit_plural = 'retweets'
time_unit = 'minute'
verbose_name = 'Twitter'

Models

Models for the tweets module.

The naming is a bit unfortunate, but the twitter namespace is already taken as shows the import list.

class tweets.models.TwitterAccount(*args, **kwargs)[source]

Account child for this module.

exception DoesNotExist
exception MultipleObjectsReturned
account_ptr

Accessor to the related object on the forward side of a many-to-one or one-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

account_ptr_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

consumer_key

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

consumer_secret

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_data(status_id)[source]

Get the status data from a given status id.

get_oauth()[source]

Return a cached OAth object for this Account.

get_source_data(twitter_id)[source]

Get the user data from a given twitter id.

get_twitter()[source]

Return a cached, authenticated Twitter object for this account.

objects = <django.db.models.manager.Manager object>
secret

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

token

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

Admin

class tweets.admin.TwitterAccountAdmin(model, admin_site)[source]
exclude = ('app',)
list_display = ('name', 'hub')
list_editable = ('hub',)
media