{"action":"created","comment":{"url":"https://api.github.com/repos/foundertherapy/django-redis-secure/pulls/comments/75114742","id":75114742,"diff_hunk":"@@ -0,0 +1,159 @@\n+from __future__ import (absolute_import, division, print_function,\n+                        unicode_literals)\n+from functools import wraps\n+from collections import defaultdict\n+import logging\n+import datetime\n+\n+from django.conf import settings as global_settings\n+import rq.utils\n+from rq.compat import string_types\n+import django_rq\n+from django_rq.queues import get_queue\n+from rq.defaults import DEFAULT_RESULT_TTL\n+from rq.queue import Queue\n+from . import settings\n+\n+logger = logging.getLogger(__name__)\n+\n+\n+_serializer = None\n+\n+\n+def get_serializer():\n+    global _serializer\n+    if not _serializer:\n+        from . import serializer\n+        _serializer = serializer.SecureSerializer(settings.get_secure_cache_opts())\n+    return _serializer\n+\n+\n+def execute(method_name, *args, **kwargs):\n+    return rq.utils.import_attribute(method_name)(*args, **kwargs)\n+\n+\n+def secure_job_proxy(*args, **kwargs):\n+    args2 = list(args)\n+    f_name = get_serializer().loads(args2.pop(0))\n+    args = list(get_serializer().loads(args2.pop(0)))\n+    kwargs = get_serializer().loads(args2.pop())\n+    return execute(f_name, *args, **kwargs)\n+\n+\n+def rq_job(func_or_queue, connection=None, *args, **kwargs):\n+    class _rq_job(object):\n+        def __init__(self, queue, connection=None, timeout=None,\n+                     result_ttl=DEFAULT_RESULT_TTL, ttl=None):\n+            \"\"\"A decorator that adds a ``delay`` method to the decorated function,\n+            which in turn creates a RQ job when called. Accepts a required\n+            ``queue`` argument that can be either a ``Queue`` instance or a string\n+            denoting the queue name.  For example:\n+\n+                @job(queue='default')\n+                def simple_add(x, y):\n+                    return x + y\n+\n+                simple_add.delay(1, 2) # Puts simple_add function into queue\n+            \"\"\"\n+            self.queue = queue\n+            self.connection = connection\n+            self.timeout = timeout\n+            self.result_ttl = result_ttl\n+            self.ttl = ttl\n+\n+        def __call__(self, f):\n+            @wraps(f)\n+            def delay(*args, **kwargs):\n+                if isinstance(self.queue, string_types):\n+                    queue = Queue(name=self.queue, connection=self.connection)\n+                else:\n+                    queue = self.queue\n+                depends_on = kwargs.pop('depends_on', None)\n+                f_name = '{}.{}'.format(f.__module__, f.__name__)\n+                args2 = [get_serializer().dumps(f_name)]\n+                args2 += [get_serializer().dumps(args)]\n+\n+                args2 += [get_serializer().dumps(kwargs)]\n+                return queue.enqueue_call(secure_job_proxy, args=args2, kwargs={},\n+                                          timeout=self.timeout, result_ttl=self.result_ttl,\n+                                          ttl=self.ttl, depends_on=depends_on)\n+\n+            @wraps(f)\n+            def enqueue_at(target_date, scheduler_name='default', *args, **kwargs):\n+                f_name = '{0}.{1}'.format(f.__module__, f.__name__)","path":"secure_redis/decorators.py","position":83,"original_position":83,"commit_id":"ec66501f587fb59265cfaff5ae652d2d774a6035","original_commit_id":"ec66501f587fb59265cfaff5ae652d2d774a6035","user":{"login":"waseem-omar","id":8616348,"avatar_url":"https://avatars.githubusercontent.com/u/8616348?v=3","gravatar_id":"","url":"https://api.github.com/users/waseem-omar","html_url":"https://github.com/waseem-omar","followers_url":"https://api.github.com/users/waseem-omar/followers","following_url":"https://api.github.com/users/waseem-omar/following{/other_user}","gists_url":"https://api.github.com/users/waseem-omar/gists{/gist_id}","starred_url":"https://api.github.com/users/waseem-omar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waseem-omar/subscriptions","organizations_url":"https://api.github.com/users/waseem-omar/orgs","repos_url":"https://api.github.com/users/waseem-omar/repos","events_url":"https://api.github.com/users/waseem-omar/events{/privacy}","received_events_url":"https://api.github.com/users/waseem-omar/received_events","type":"User","site_admin":false},"body":"@GhalebKhaled Please rename this to `function_name`","created_at":"2016-08-17T12:45:05Z","updated_at":"2016-08-17T12:45:05Z","html_url":"https://github.com/foundertherapy/django-redis-secure/pull/2#discussion_r75114742","pull_request_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/foundertherapy/django-redis-secure/pulls/comments/75114742"},"html":{"href":"https://github.com/foundertherapy/django-redis-secure/pull/2#discussion_r75114742"},"pull_request":{"href":"https://api.github.com/repos/foundertherapy/django-redis-secure/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/foundertherapy/django-redis-secure/pulls/2","id":81340325,"html_url":"https://github.com/foundertherapy/django-redis-secure/pull/2","diff_url":"https://github.com/foundertherapy/django-redis-secure/pull/2.diff","patch_url":"https://github.com/foundertherapy/django-redis-secure/pull/2.patch","issue_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/issues/2","number":2,"state":"open","locked":false,"title":"inital support for secure rq","user":{"login":"GhalebKhaled","id":2292180,"avatar_url":"https://avatars.githubusercontent.com/u/2292180?v=3","gravatar_id":"","url":"https://api.github.com/users/GhalebKhaled","html_url":"https://github.com/GhalebKhaled","followers_url":"https://api.github.com/users/GhalebKhaled/followers","following_url":"https://api.github.com/users/GhalebKhaled/following{/other_user}","gists_url":"https://api.github.com/users/GhalebKhaled/gists{/gist_id}","starred_url":"https://api.github.com/users/GhalebKhaled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GhalebKhaled/subscriptions","organizations_url":"https://api.github.com/users/GhalebKhaled/orgs","repos_url":"https://api.github.com/users/GhalebKhaled/repos","events_url":"https://api.github.com/users/GhalebKhaled/events{/privacy}","received_events_url":"https://api.github.com/users/GhalebKhaled/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-15T16:54:06Z","updated_at":"2016-08-17T12:45:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"68368253296b31b0bec0520122e35d9f2a9c1af1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/pulls/2/commits","review_comments_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/pulls/2/comments","review_comment_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/pulls/comments{/number}","comments_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/issues/2/comments","statuses_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/statuses/ec66501f587fb59265cfaff5ae652d2d774a6035","head":{"label":"foundertherapy:1139_secure_rq","ref":"1139_secure_rq","sha":"ec66501f587fb59265cfaff5ae652d2d774a6035","user":{"login":"foundertherapy","id":8397367,"avatar_url":"https://avatars.githubusercontent.com/u/8397367?v=3","gravatar_id":"","url":"https://api.github.com/users/foundertherapy","html_url":"https://github.com/foundertherapy","followers_url":"https://api.github.com/users/foundertherapy/followers","following_url":"https://api.github.com/users/foundertherapy/following{/other_user}","gists_url":"https://api.github.com/users/foundertherapy/gists{/gist_id}","starred_url":"https://api.github.com/users/foundertherapy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foundertherapy/subscriptions","organizations_url":"https://api.github.com/users/foundertherapy/orgs","repos_url":"https://api.github.com/users/foundertherapy/repos","events_url":"https://api.github.com/users/foundertherapy/events{/privacy}","received_events_url":"https://api.github.com/users/foundertherapy/received_events","type":"Organization","site_admin":false},"repo":{"id":63341118,"name":"django-redis-secure","full_name":"foundertherapy/django-redis-secure","owner":{"login":"foundertherapy","id":8397367,"avatar_url":"https://avatars.githubusercontent.com/u/8397367?v=3","gravatar_id":"","url":"https://api.github.com/users/foundertherapy","html_url":"https://github.com/foundertherapy","followers_url":"https://api.github.com/users/foundertherapy/followers","following_url":"https://api.github.com/users/foundertherapy/following{/other_user}","gists_url":"https://api.github.com/users/foundertherapy/gists{/gist_id}","starred_url":"https://api.github.com/users/foundertherapy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foundertherapy/subscriptions","organizations_url":"https://api.github.com/users/foundertherapy/orgs","repos_url":"https://api.github.com/users/foundertherapy/repos","events_url":"https://api.github.com/users/foundertherapy/events{/privacy}","received_events_url":"https://api.github.com/users/foundertherapy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/foundertherapy/django-redis-secure","description":"This is a Django library that is used to encrypt data stored to Redis, and decrypt it when getting it.","fork":false,"url":"https://api.github.com/repos/foundertherapy/django-redis-secure","forks_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/forks","keys_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/keys{/key_id}","collaborators_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/teams","hooks_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/hooks","issue_events_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/issues/events{/number}","events_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/events","assignees_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/assignees{/user}","branches_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/branches{/branch}","tags_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/tags","blobs_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/git/refs{/sha}","trees_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/git/trees{/sha}","statuses_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/statuses/{sha}","languages_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/languages","stargazers_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/stargazers","contributors_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/contributors","subscribers_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/subscribers","subscription_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/subscription","commits_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/commits{/sha}","git_commits_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/git/commits{/sha}","comments_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/comments{/number}","issue_comment_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/issues/comments{/number}","contents_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/contents/{+path}","compare_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/compare/{base}...{head}","merges_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/merges","archive_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/downloads","issues_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/issues{/number}","pulls_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/pulls{/number}","milestones_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/milestones{/number}","notifications_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/labels{/name}","releases_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/releases{/id}","deployments_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/deployments","created_at":"2016-07-14T13:57:43Z","updated_at":"2016-08-07T12:12:15Z","pushed_at":"2016-08-16T17:14:57Z","git_url":"git://github.com/foundertherapy/django-redis-secure.git","ssh_url":"git@github.com:foundertherapy/django-redis-secure.git","clone_url":"https://github.com/foundertherapy/django-redis-secure.git","svn_url":"https://github.com/foundertherapy/django-redis-secure","homepage":null,"size":24,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"foundertherapy:master","ref":"master","sha":"090888917f98a94e73c33571e26aed17ed279b21","user":{"login":"foundertherapy","id":8397367,"avatar_url":"https://avatars.githubusercontent.com/u/8397367?v=3","gravatar_id":"","url":"https://api.github.com/users/foundertherapy","html_url":"https://github.com/foundertherapy","followers_url":"https://api.github.com/users/foundertherapy/followers","following_url":"https://api.github.com/users/foundertherapy/following{/other_user}","gists_url":"https://api.github.com/users/foundertherapy/gists{/gist_id}","starred_url":"https://api.github.com/users/foundertherapy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foundertherapy/subscriptions","organizations_url":"https://api.github.com/users/foundertherapy/orgs","repos_url":"https://api.github.com/users/foundertherapy/repos","events_url":"https://api.github.com/users/foundertherapy/events{/privacy}","received_events_url":"https://api.github.com/users/foundertherapy/received_events","type":"Organization","site_admin":false},"repo":{"id":63341118,"name":"django-redis-secure","full_name":"foundertherapy/django-redis-secure","owner":{"login":"foundertherapy","id":8397367,"avatar_url":"https://avatars.githubusercontent.com/u/8397367?v=3","gravatar_id":"","url":"https://api.github.com/users/foundertherapy","html_url":"https://github.com/foundertherapy","followers_url":"https://api.github.com/users/foundertherapy/followers","following_url":"https://api.github.com/users/foundertherapy/following{/other_user}","gists_url":"https://api.github.com/users/foundertherapy/gists{/gist_id}","starred_url":"https://api.github.com/users/foundertherapy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/foundertherapy/subscriptions","organizations_url":"https://api.github.com/users/foundertherapy/orgs","repos_url":"https://api.github.com/users/foundertherapy/repos","events_url":"https://api.github.com/users/foundertherapy/events{/privacy}","received_events_url":"https://api.github.com/users/foundertherapy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/foundertherapy/django-redis-secure","description":"This is a Django library that is used to encrypt data stored to Redis, and decrypt it when getting it.","fork":false,"url":"https://api.github.com/repos/foundertherapy/django-redis-secure","forks_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/forks","keys_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/keys{/key_id}","collaborators_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/teams","hooks_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/hooks","issue_events_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/issues/events{/number}","events_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/events","assignees_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/assignees{/user}","branches_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/branches{/branch}","tags_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/tags","blobs_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/git/refs{/sha}","trees_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/git/trees{/sha}","statuses_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/statuses/{sha}","languages_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/languages","stargazers_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/stargazers","contributors_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/contributors","subscribers_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/subscribers","subscription_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/subscription","commits_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/commits{/sha}","git_commits_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/git/commits{/sha}","comments_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/comments{/number}","issue_comment_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/issues/comments{/number}","contents_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/contents/{+path}","compare_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/compare/{base}...{head}","merges_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/merges","archive_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/downloads","issues_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/issues{/number}","pulls_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/pulls{/number}","milestones_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/milestones{/number}","notifications_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/labels{/name}","releases_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/releases{/id}","deployments_url":"https://api.github.com/repos/foundertherapy/django-redis-secure/deployments","created_at":"2016-07-14T13:57:43Z","updated_at":"2016-08-07T12:12:15Z","pushed_at":"2016-08-16T17:14:57Z","git_url":"git://github.com/foundertherapy/django-redis-secure.git","ssh_url":"git@github.com:foundertherapy/django-redis-secure.git","clone_url":"https://github.com/foundertherapy/django-redis-secure.git","svn_url":"https://github.com/foundertherapy/django-redis-secure","homepage":null,"size":24,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/foundertherapy/django-redis-secure/pulls/2"},"html":{"href":"https://github.com/foundertherapy/django-redis-secure/pull/2"},"issue":{"href":"https://api.github.com/repos/foundertherapy/django-redis-secure/issues/2"},"comments":{"href":"https://api.github.com/repos/foundertherapy/django-redis-secure/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/foundertherapy/django-redis-secure/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/foundertherapy/django-redis-secure/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/foundertherapy/django-redis-secure/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/foundertherapy/django-redis-secure/statuses/ec66501f587fb59265cfaff5ae652d2d774a6035"}}}}
{"actor":{"display_login":"waseem-omar"}}