{"action":"created","comment":{"url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/pulls/comments/36856486","id":36856486,"diff_hunk":"@@ -0,0 +1,76 @@\n+from Acquisition import aq_chain\n+from ftw.theming.interfaces import ISCSSResourceFactory\n+from ftw.theming.resource import SCSSResource\n+from plonetheme.onegovbear.browser.forms import TIMESTAMP_ANNOTATION_KEY\n+from plonetheme.onegovbear.browser.forms import VARIABLES_ANNOTATION_KEY\n+from plonetheme.onegovbear.interfaces import ICustomDesignVariablesSchema\n+from zope.annotation import IAnnotations\n+from zope.component import queryMultiAdapter\n+from zope.interface import implements\n+from zope.schema import getFields, getFieldNamesInOrder\n+\n+\n+class CustomDesignVariablesSCSSResource(SCSSResource):\n+\n+    def get_source(self, context, request):\n+        ancestor_variables = self._get_ancestor_variables(context)\n+\n+        source = '\\n'.join(\n+            '{0}: {1};'.format(name, value)\n+            for name, value in ancestor_variables\n+        )\n+        return source\n+\n+    def get_cachekey(self, context, request):\n+        timestamps = [self._get_timestamp(ancestor) for ancestor\n+                      in self._get_ancestors(context)]\n+        timestamps = filter(None, timestamps)\n+        timestamps = map(str, timestamps)\n+        return '-'.join(timestamps)\n+\n+    def _get_ancestors(self, obj):\n+        return reversed(aq_chain(obj))\n+\n+    def _get_ancestor_variables(self, obj):\n+        for variables in map(self._get_scss_variables,\n+                             self._get_ancestors(obj)):\n+            for name, value in variables:\n+                if not value:\n+                    continue\n+                yield value['variable_name'], value['value']\n+\n+    def _get_scss_variables(self, obj):\n+        schema = queryMultiAdapter((obj, obj.REQUEST),\n+                                   ICustomDesignVariablesSchema)\n+        if not schema:\n+            return\n+\n+        annotations = IAnnotations(obj, None)\n+        if not annotations:\n+            return\n+        variables = annotations.get(VARIABLES_ANNOTATION_KEY) or {}\n+\n+        form_fields = getFields(schema)\n+        for field_name in getFieldNamesInOrder(schema):\n+            yield (form_fields[field_name].variable_name,\n+                   variables.get(field_name))\n+\n+    def _get_timestamp(self, obj):\n+        annotations = IAnnotations(obj, None)\n+        if not annotations:\n+            return None\n+        return annotations.get(TIMESTAMP_ANNOTATION_KEY, None)\n+\n+\n+class CustomDesignVariablesResourceFactory(object):\n+    implements(ISCSSResourceFactory)\n+    annotations_key = VARIABLES_ANNOTATION_KEY\n+\n+    def __call__(self, context, request):\n+        self.context = context\n+        self.request = request\n+        return CustomDesignVariablesSCSSResource(\n+            name='plonetheme.onegovbear.custom_design_variables.scss',\n+            slot='variables')\n+\n+factory = CustomDesignVariablesResourceFactory()","path":"plonetheme/onegovbear/browser/dynamic_scss_resources.py","position":76,"original_position":76,"commit_id":"1789bc55ac177437031d7095f8ab5ad5667b2a33","original_commit_id":"1789bc55ac177437031d7095f8ab5ad5667b2a33","user":{"login":"mbaechtold","id":28220,"avatar_url":"https://avatars.githubusercontent.com/u/28220?v=3","gravatar_id":"","url":"https://api.github.com/users/mbaechtold","html_url":"https://github.com/mbaechtold","followers_url":"https://api.github.com/users/mbaechtold/followers","following_url":"https://api.github.com/users/mbaechtold/following{/other_user}","gists_url":"https://api.github.com/users/mbaechtold/gists{/gist_id}","starred_url":"https://api.github.com/users/mbaechtold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbaechtold/subscriptions","organizations_url":"https://api.github.com/users/mbaechtold/orgs","repos_url":"https://api.github.com/users/mbaechtold/repos","events_url":"https://api.github.com/users/mbaechtold/events{/privacy}","received_events_url":"https://api.github.com/users/mbaechtold/received_events","type":"User","site_admin":false},"body":"But since we no longer have the need for allowing the subclassing of the factory in the police package I will transform this back into a function.","created_at":"2015-08-12T13:04:52Z","updated_at":"2015-08-12T13:04:52Z","html_url":"https://github.com/OneGov/plonetheme.onegovbear/pull/27#discussion_r36856486","pull_request_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/pulls/27","_links":{"self":{"href":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/pulls/comments/36856486"},"html":{"href":"https://github.com/OneGov/plonetheme.onegovbear/pull/27#discussion_r36856486"},"pull_request":{"href":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/pulls/27","id":41802510,"html_url":"https://github.com/OneGov/plonetheme.onegovbear/pull/27","diff_url":"https://github.com/OneGov/plonetheme.onegovbear/pull/27.diff","patch_url":"https://github.com/OneGov/plonetheme.onegovbear/pull/27.patch","issue_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/issues/27","number":27,"state":"open","locked":false,"title":"Customize selected SCSS variables through the web.","user":{"login":"mbaechtold","id":28220,"avatar_url":"https://avatars.githubusercontent.com/u/28220?v=3","gravatar_id":"","url":"https://api.github.com/users/mbaechtold","html_url":"https://github.com/mbaechtold","followers_url":"https://api.github.com/users/mbaechtold/followers","following_url":"https://api.github.com/users/mbaechtold/following{/other_user}","gists_url":"https://api.github.com/users/mbaechtold/gists{/gist_id}","starred_url":"https://api.github.com/users/mbaechtold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbaechtold/subscriptions","organizations_url":"https://api.github.com/users/mbaechtold/orgs","repos_url":"https://api.github.com/users/mbaechtold/repos","events_url":"https://api.github.com/users/mbaechtold/events{/privacy}","received_events_url":"https://api.github.com/users/mbaechtold/received_events","type":"User","site_admin":false},"body":"Closes 4teamwork/bern.web#320","created_at":"2015-08-06T15:41:58Z","updated_at":"2015-08-12T13:04:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7577ef048ccb58abb6988b556bc09d7e643b68cf","assignee":{"login":"jone","id":7469,"avatar_url":"https://avatars.githubusercontent.com/u/7469?v=3","gravatar_id":"","url":"https://api.github.com/users/jone","html_url":"https://github.com/jone","followers_url":"https://api.github.com/users/jone/followers","following_url":"https://api.github.com/users/jone/following{/other_user}","gists_url":"https://api.github.com/users/jone/gists{/gist_id}","starred_url":"https://api.github.com/users/jone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jone/subscriptions","organizations_url":"https://api.github.com/users/jone/orgs","repos_url":"https://api.github.com/users/jone/repos","events_url":"https://api.github.com/users/jone/events{/privacy}","received_events_url":"https://api.github.com/users/jone/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/pulls/27/commits","review_comments_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/pulls/27/comments","review_comment_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/issues/27/comments","statuses_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/statuses/1789bc55ac177437031d7095f8ab5ad5667b2a33","head":{"label":"OneGov:mba/override-scss-variables","ref":"mba/override-scss-variables","sha":"1789bc55ac177437031d7095f8ab5ad5667b2a33","user":{"login":"OneGov","id":3265608,"avatar_url":"https://avatars.githubusercontent.com/u/3265608?v=3","gravatar_id":"","url":"https://api.github.com/users/OneGov","html_url":"https://github.com/OneGov","followers_url":"https://api.github.com/users/OneGov/followers","following_url":"https://api.github.com/users/OneGov/following{/other_user}","gists_url":"https://api.github.com/users/OneGov/gists{/gist_id}","starred_url":"https://api.github.com/users/OneGov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OneGov/subscriptions","organizations_url":"https://api.github.com/users/OneGov/orgs","repos_url":"https://api.github.com/users/OneGov/repos","events_url":"https://api.github.com/users/OneGov/events{/privacy}","received_events_url":"https://api.github.com/users/OneGov/received_events","type":"Organization","site_admin":false},"repo":{"id":37249029,"name":"plonetheme.onegovbear","full_name":"OneGov/plonetheme.onegovbear","owner":{"login":"OneGov","id":3265608,"avatar_url":"https://avatars.githubusercontent.com/u/3265608?v=3","gravatar_id":"","url":"https://api.github.com/users/OneGov","html_url":"https://github.com/OneGov","followers_url":"https://api.github.com/users/OneGov/followers","following_url":"https://api.github.com/users/OneGov/following{/other_user}","gists_url":"https://api.github.com/users/OneGov/gists{/gist_id}","starred_url":"https://api.github.com/users/OneGov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OneGov/subscriptions","organizations_url":"https://api.github.com/users/OneGov/orgs","repos_url":"https://api.github.com/users/OneGov/repos","events_url":"https://api.github.com/users/OneGov/events{/privacy}","received_events_url":"https://api.github.com/users/OneGov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OneGov/plonetheme.onegovbear","description":"OneGov Plone theme sponsored by the city of Bern.","fork":false,"url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear","forks_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/forks","keys_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/teams","hooks_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/hooks","issue_events_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/issues/events{/number}","events_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/events","assignees_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/assignees{/user}","branches_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/branches{/branch}","tags_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/tags","blobs_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/git/refs{/sha}","trees_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/statuses/{sha}","languages_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/languages","stargazers_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/stargazers","contributors_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/contributors","subscribers_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/subscribers","subscription_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/subscription","commits_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/commits{/sha}","git_commits_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/git/commits{/sha}","comments_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/comments{/number}","issue_comment_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/issues/comments{/number}","contents_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/contents/{+path}","compare_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/merges","archive_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/downloads","issues_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/issues{/number}","pulls_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/pulls{/number}","milestones_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/milestones{/number}","notifications_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/labels{/name}","releases_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/releases{/id}","created_at":"2015-06-11T08:30:35Z","updated_at":"2015-06-20T05:37:45Z","pushed_at":"2015-08-12T12:58:44Z","git_url":"git://github.com/OneGov/plonetheme.onegovbear.git","ssh_url":"git@github.com:OneGov/plonetheme.onegovbear.git","clone_url":"https://github.com/OneGov/plonetheme.onegovbear.git","svn_url":"https://github.com/OneGov/plonetheme.onegovbear","homepage":"","size":712,"stargazers_count":1,"watchers_count":1,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"OneGov:master","ref":"master","sha":"331aed0a1fc0644a1921898c29707c0d53d3c034","user":{"login":"OneGov","id":3265608,"avatar_url":"https://avatars.githubusercontent.com/u/3265608?v=3","gravatar_id":"","url":"https://api.github.com/users/OneGov","html_url":"https://github.com/OneGov","followers_url":"https://api.github.com/users/OneGov/followers","following_url":"https://api.github.com/users/OneGov/following{/other_user}","gists_url":"https://api.github.com/users/OneGov/gists{/gist_id}","starred_url":"https://api.github.com/users/OneGov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OneGov/subscriptions","organizations_url":"https://api.github.com/users/OneGov/orgs","repos_url":"https://api.github.com/users/OneGov/repos","events_url":"https://api.github.com/users/OneGov/events{/privacy}","received_events_url":"https://api.github.com/users/OneGov/received_events","type":"Organization","site_admin":false},"repo":{"id":37249029,"name":"plonetheme.onegovbear","full_name":"OneGov/plonetheme.onegovbear","owner":{"login":"OneGov","id":3265608,"avatar_url":"https://avatars.githubusercontent.com/u/3265608?v=3","gravatar_id":"","url":"https://api.github.com/users/OneGov","html_url":"https://github.com/OneGov","followers_url":"https://api.github.com/users/OneGov/followers","following_url":"https://api.github.com/users/OneGov/following{/other_user}","gists_url":"https://api.github.com/users/OneGov/gists{/gist_id}","starred_url":"https://api.github.com/users/OneGov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OneGov/subscriptions","organizations_url":"https://api.github.com/users/OneGov/orgs","repos_url":"https://api.github.com/users/OneGov/repos","events_url":"https://api.github.com/users/OneGov/events{/privacy}","received_events_url":"https://api.github.com/users/OneGov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OneGov/plonetheme.onegovbear","description":"OneGov Plone theme sponsored by the city of Bern.","fork":false,"url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear","forks_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/forks","keys_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/teams","hooks_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/hooks","issue_events_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/issues/events{/number}","events_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/events","assignees_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/assignees{/user}","branches_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/branches{/branch}","tags_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/tags","blobs_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/git/refs{/sha}","trees_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/statuses/{sha}","languages_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/languages","stargazers_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/stargazers","contributors_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/contributors","subscribers_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/subscribers","subscription_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/subscription","commits_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/commits{/sha}","git_commits_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/git/commits{/sha}","comments_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/comments{/number}","issue_comment_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/issues/comments{/number}","contents_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/contents/{+path}","compare_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/merges","archive_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/downloads","issues_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/issues{/number}","pulls_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/pulls{/number}","milestones_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/milestones{/number}","notifications_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/labels{/name}","releases_url":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/releases{/id}","created_at":"2015-06-11T08:30:35Z","updated_at":"2015-06-20T05:37:45Z","pushed_at":"2015-08-12T12:58:44Z","git_url":"git://github.com/OneGov/plonetheme.onegovbear.git","ssh_url":"git@github.com:OneGov/plonetheme.onegovbear.git","clone_url":"https://github.com/OneGov/plonetheme.onegovbear.git","svn_url":"https://github.com/OneGov/plonetheme.onegovbear","homepage":"","size":712,"stargazers_count":1,"watchers_count":1,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/pulls/27"},"html":{"href":"https://github.com/OneGov/plonetheme.onegovbear/pull/27"},"issue":{"href":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/issues/27"},"comments":{"href":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/OneGov/plonetheme.onegovbear/statuses/1789bc55ac177437031d7095f8ab5ad5667b2a33"}}}}