Stream Framework API Docs¶
stream_framework Package¶
activity Module¶
-
class
stream_framework.activity.Activity(actor, verb, object, target=None, time=None, extra_context=None)[source]¶ Bases:
stream_framework.activity.BaseActivityWrapper class for storing activities Note
actor_id target_id and object_id are always present
actor, target and object are lazy by default
-
serialization_id¶ serialization_id is used to keep items locally sorted and unique (eg. used redis sorted sets’ score or cassandra column names)
serialization_id is also used to select random activities from the feed (eg. remove activities from feeds must be fast operation) for this reason the serialization_id should be unique and not change over time
eg: activity.serialization_id = 1373266755000000000042008 1373266755000 activity creation time as epoch with millisecond resolution 0000000000042 activity left padded object_id (10 digits) 008 left padded activity verb id (3 digits)
Returns: int –the serialization id
-
-
class
stream_framework.activity.AggregatedActivity(group, activities=None, created_at=None, updated_at=None)[source]¶ Bases:
stream_framework.activity.BaseActivityObject to store aggregated activities
-
activity_count¶ Returns the number of activities
-
activity_ids¶ Returns a list of activity ids
-
actor_count¶ Returns a count of the number of actors When dealing with large lists only approximate the number of actors
-
actor_ids¶
-
get_hydrated(activities)[source]¶ expects activities to be a dict like this {‘activity_id’: Activity}
-
last_activities¶
-
last_activity¶
-
max_aggregated_activities_length= 15¶
-
object_ids¶
-
other_actor_count¶
-
serialization_id¶ serialization_id is used to keep items locally sorted and unique (eg. used redis sorted sets’ score or cassandra column names)
serialization_id is also used to select random activities from the feed (eg. remove activities from feeds must be fast operation) for this reason the serialization_id should be unique and not change over time
eg: activity.serialization_id = 1373266755000000000042008 1373266755000 activity creation time as epoch with millisecond resolution 0000000000042 activity left padded object_id (10 digits) 008 left padded activity verb id (3 digits)
Returns: int –the serialization id
-
verb¶
-
verbs¶
-
-
class
stream_framework.activity.BaseActivity[source]¶ Bases:
objectCommon parent class for Activity and Aggregated Activity Check for this if you want to see if something is an activity
-
class
stream_framework.activity.DehydratedActivity(serialization_id)[source]¶ Bases:
stream_framework.activity.BaseActivityThe dehydrated verions of an
Activity. the only data stored is serialization_id of the originalSerializers can store this instead of the full activity Feed classes
default_settings Module¶
exceptions Module¶
-
exception
stream_framework.exceptions.ActivityNotFound[source]¶ Bases:
exceptions.ExceptionRaised when the activity is not present in the aggregated Activity
settings Module¶
-
stream_framework.settings.import_global_module(module, current_locals, current_globals, exceptions=None)[source]¶ Import the requested module into the global scope Warning! This will import your module into the global scope
- Example:
- from django.conf import settings import_global_module(settings, locals(), globals())
Parameters: - module – the module which to import into global scope
- current_locals – the local globals
- current_globals – the current globals
- exceptions – the exceptions which to ignore while importing
tasks Module¶
utils Module¶
-
stream_framework.utils.datetime_to_epoch(dt)[source]¶ Convert datetime object to epoch with millisecond accuracy
-
stream_framework.utils.get_class_from_string(path, default=None)[source]¶ Return the class specified by the string.
-
stream_framework.utils.get_metrics_instance()[source]¶ Returns an instance of the metric class as defined in stream_framework settings.
-
stream_framework.utils.make_list_unique(sequence, marker_function=None)[source]¶ Makes items in a list unique Performance based on this blog post: http://www.peterbe.com/plog/uniqifiers-benchmark