Social graph for Django>=1.6.1
Fixed edge update procedure (cache policy).
Fixed edge cleaner.
Temporarily invalidating edge lists from cache when one of its items must be excluded, until we figure out how to get it done correctly.
Added spanish translations Included management commands to be packaged along with the application
Added unique constraint to Edge model. (Until now, this constraint have been enforced by api logic, but had some issues when cache contains residual items)
Removed deprecated methods: edge_add(), edge_change(), and edge_delete(). --> BACKWARDS INCOMPATIBILITY Uses django-redis-cache as a third party package, and creates a new extended redis cache backend. General code refactoring (not loading so many stuff at init.py). Minimized module level imports. New management command clear_graph_cache
Allows only one edge per node pair, edge type and site. Deprecated old methods: edge_add(), edge_change(), and edge_delete(); introduced methods edge() and no_edge() to substitute them. (Is not recommendable to mix old deprecated method usage with new method usage, can lead to inconsistent data!) New edge_get() method to retrieve only one edge (if exists). (Is only safe to use when edge creation is handled by edge() method, not by deprecated edge_add/edge_change)
Fixes in delete_edge behaviour (handling more corner case's exceptions)
Fixes in multi-site support. CHANGED API METHODS SIGNATURES!!!!
Full site aware implementation (Note: A different cache instance SHOULD be defined for each Site)
More specific signal sender: * object_visited sender is the model class
New EdgeCleaner consistency enforcer, to erase all edges belonging to a deleted object. Improvement in EdgeCounter consistency enforcers to make it thread safe.
More specific signal senders: * object_created, object_updated and object_deleted sender is the model class * edge_created, edge_updated and edge_deleted sender is the edge type
Symmetric edges are now created with the same attributes as their original edges.
EdgeForm allows to set a list of "edge attribute" fields" from which it takes the corresponding values and builds the attributes dictionary for the edge to save.
Added the BaseEdgeForm and the SpecificTypeEdgeForm, to be inherited by all forms that intend to save and Edge object. This forms' save() operation uses the Graph api, instead of Django's ORM directly.
Added the authenticated user argument to the object_visited signal.
Api operations edge_add and edge_change now return the created/changed edge. If the edge_change operation determine that the target edge doesn't exist, it automatically calls edge_add operation.
EdgeType and EdgeTypeAssociation cache implementation, to prevent hitting the database unnecessarily to "get" an EdgeType or EdgeTypeAssociation
PENDING...
Requires the redis-py Python client library for communicating with the Redis server.
Redis writes to disk asynchronously so there is a slight chance of losing some data, but for most purposes this is acceptable.
In order to use redis.connection.HiredisParser
parser class, you need to
pip install hiredis. This is the recommended parser class.
Run
python setup.py install
to install.Modify your Django settings to use
redis_cache
for graph cache:# When using TCP connections CACHES = {
- 'graph': {
'BACKEND': 'redis_cache.RedisCache', 'LOCATION': '<host>:<port>', 'OPTIONS': {
'DB': 1, 'PASSWORD': 'yadayada', 'PARSER_CLASS': 'redis.connection.HiredisParser', 'CONNECTION_POOL_CLASS': 'redis.BlockingConnectionPool', 'CONNECTION_POOL_CLASS_KWARGS': {
'max_connections': 50, 'timeout': 20,
}
},
},
}
# When using unix domain sockets # Note:
LOCATION
needs to be the same as theunixsocket
setting # in your redis.conf CACHES = {- 'graph': {
'BACKEND': 'redis_cache.RedisCache', 'LOCATION': '/path/to/socket/file', 'OPTIONS': {
'DB': 1, 'PASSWORD': 'yadayada', 'PARSER_CLASS': 'redis.connection.HiredisParser'
},
},
}
If you want to use redis_cache not only for graph cache, but as the default cache, just configure the cache backend with the "default" alias, and the social graph will use it as well.
- Create edges types, and edge type associations; edges and start using the graph.