Skip to main content

Provides a means of creating streams of content

Usage

You can use the tt_streams to collect different models from different apps into a unified stream of models. Streams are made up of a series of StreamItem subclasses that you write that are specific to each app that they are used in.

To skip straight ahead to simple (bordering on naive) implementation examples, check out the project/example/models.py file.

Each Django app that wants to expose its models to streams should do two things:

  • Create a specific *Item model. For example, StoryItem should subclass the StreamItem model and provide a connection via a ForeignKey to the model that is opting in,``Story`` in this case.

  • Create a way to get associate those models with a Stream. This is most commonly done via an inline interface to the StreamItem sub-class.

Beyond these requirements, everything else you do with your subclass of StreamItem is up to you. It’s common to use your StreamItem class as a cache table so you don’t have to send another query to the database.

For example, the StoryItem automatically stores the title of its related Story model when it is saved, and a receiver is hooked up to the post_save signal for Story to ensure that all of its stream_items are resaved each time it is saved.

There are a couple of things to note:

  • You can name your subclass of StreamItem whatever you would like

  • You can name your related field whatever you like

  • It automatically has a pub_date that you can use for ordering, but they are not ordered by default

Installation & Configuration

You can install the latest release of tt_streams using pip:

pip install tt_streams

Make sure to add tt_streams to your INSTALLED_APPS. You can add this however you like. This works as a copy-and-paste solution:

INSTALLED_APPS += ["tt_streams", ]

Once installed, you have to run either syncdb, or migrate if you are using South.

Contributing

  • Create something awesome – make the code better, add some functionality, whatever (this is the hardest part).

  • Fork it

  • Create a topic branch to house your changes

  • Get all of your commits in the new topic branch

  • Submit a pull request

License

Copyright 2013 Texas Tribune

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Metadata

Release files for tt_streams 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tt_streams 0.2.0
File Size Uploaded
tt_streams-0.2.0.tar.gz 7.6 kB Details

Release files / tt_streams-0.2.0.tar.gz

Download URL tt_streams-0.2.0.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cf34844efd37d486036c190e9bb57e6fe38adeae47c96d76c5bd0f31d130ace7
BLAKE2b-256 checksum
How to use checksums
56da4fad69de9b6beda8803e7f9fd7add2e2c87f6a8c7e5a795be6ad3d3a68d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page