def _log_to_recent_project_actions(p, user_id, action_time, message): """Log actions that refer to projects to a queue of most recent actions. We use redis' list for that. We skip actions that refer to private projects. """ from transifex.projects.models import Project if p.private: return private_slugs = Project.objects.filter( private=True ).values_list('slug', flat=True) for slug in private_slugs: if ('/projects/p/%s/' % slug) in message: return key = 'event_feed' data = { 'name': force_unicode(p)[:200], 'user_id': user_id, 'action_time': action_time, 'message': message } try: r = TxRedisMapper() r.lpush(key, data=data) r.ltrim(key, 0, 11) except ConnectionError, e: logger.critical("Cannot connect to redis: %s" % e, exc_info=True) raise