Django Actable
NOTE: Presently only supports Python 3.5+ and Django 1.9+ (see issue #1)
Activity stream for Python Django. Unlike other activity streams, it is much more flexible, with every event designed to supporting an arbitrary number of associated objects. It also is designed to be unobtrusive: Any of your models can be registered as an activity generator, all you need to do is generate a data structure for context, or an HTML fragment.
Features
Very easily / magically integrated into an existing system, with signals being auto-generated based on principle objects
Arbitrary number of objects can be associated with every event
Fast look ups with denormalized events (no joins)
Looking up streams for particular actors or objects
Decent test coverage
Handy Paginator helper class to page through stream
Example project
Not yet implemented: Follow
Quick start
Overview:
Install actable and put in requirements file
Add to INSTALLED_APPS
3. Pick several important models to implement the actable interface so that every save or update generates an event
Add those models to ACTABLE_MODELS
Use helper classes to add a streams to your views
Install:
pip install actable
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'actable.apps.ActableConfig',
...
)
Pick one or more models to be your actable models. Whenever these models are updated or created, it will generate events. These events can involve any number of other objects.
You must implement at least 2 methods on your actable models. The first method is get_actable_relations which must return a dictionary where all the values are model instances that are related to this action. Instead of limiting yourself to “Actor, Verb, Object”, this allows you to have any number of relations. Each one of these model instances will receive a copy of this event to its activity stream.
Example:
class ProjectBlogPost:
def get_actable_relations(self, event):
return {
'subject': self.user,
'object': self,
'project': self.project,
}
Now you must choose one of 2 other methods to implement. These constitute the data to cache for each event.
The most versatile of the two is one that returns a dictionary containing entirely simple (serializable) data types. This will be stored in serialized form in your database.
Example:
class ProjectBlogPost:
def get_actable_json(self, event):
verb = 'posted' if event.is_creation else 'updated'
return {
'subject': self.user.username,
'subject_url': self.user.get_absolute_url(),
'object': self.title,
'object_url': self.get_absolute_url(),
'project': self.project.title,
'verb': verb,
}
The other option is caching an HTML snippet (string) that can be generated any way you see fit.
Example:
class ProjectBlogPost:
def get_actable_html(self, event):
return '<a href="%s">%s</a> wrote %s' % (
self.user.get_absolute_url(),
self.user.username,
self.title
)
Finally, you should list your newly improved as an ACTABLE_MODEL, as such:
ACTABLE_MODELS = [
'myapp.ProjectBlogPost',
]
Credits
Tools used in creating this package:
History
0.1.0 (2017-11-10)
First release on PyPI.
Metadata
Release files for actable 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| actable-0.1.2.tar.gz | 9.6 kB | Without provenance | Details for actable-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| actable-0.1.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for actable-0.1.2-py2.py3-none-any.whl |
Total release size: 21.3 kB
Release files / actable-0.1.2.tar.gz
| Download URL | actable-0.1.2.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9069b1e19e42f3d3f18ec01f07b4979292309ba60444655a766579f4de244fc7
|
|
BLAKE2b-256 checksum How to use checksums |
69c990460b8ec3a0f737cf0af41909340e8d89eb2f270245e907a59204742c4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / actable-0.1.2-py2.py3-none-any.whl
| Download URL | actable-0.1.2-py2.py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
39b4d32084be4f53094ac4c6b5495e736ede71d04ec70a5b95930cf04a20e530
|
|
BLAKE2b-256 checksum How to use checksums |
1daa7d3e020be458070670dc389f55650e9b9234910d638abcd614916bf28943
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for actable 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.