Texas Tribune: tt_streams
Project description
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).
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
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file tt_streams-0.2.0.tar.gz
.
File metadata
- Download URL: tt_streams-0.2.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf34844efd37d486036c190e9bb57e6fe38adeae47c96d76c5bd0f31d130ace7 |
|
MD5 | 21bfed1dbceb8d2ca5ce4c6680715109 |
|
BLAKE2b-256 | 56da4fad69de9b6beda8803e7f9fd7add2e2c87f6a8c7e5a795be6ad3d3a68d4 |