{"action":"created","issue":{"url":"https://api.github.com/repos/geopython/pycsw/issues/339","labels_url":"https://api.github.com/repos/geopython/pycsw/issues/339/labels{/name}","comments_url":"https://api.github.com/repos/geopython/pycsw/issues/339/comments","events_url":"https://api.github.com/repos/geopython/pycsw/issues/339/events","html_url":"https://github.com/geopython/pycsw/issues/339","id":86850410,"number":339,"title":"OAIPMH dc:subject is not being populated with keywords","user":{"login":"kevinpdavies","id":6722965,"avatar_url":"https://avatars.githubusercontent.com/u/6722965?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinpdavies","html_url":"https://github.com/kevinpdavies","followers_url":"https://api.github.com/users/kevinpdavies/followers","following_url":"https://api.github.com/users/kevinpdavies/following{/other_user}","gists_url":"https://api.github.com/users/kevinpdavies/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinpdavies/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinpdavies/subscriptions","organizations_url":"https://api.github.com/users/kevinpdavies/orgs","repos_url":"https://api.github.com/users/kevinpdavies/repos","events_url":"https://api.github.com/users/kevinpdavies/events{/privacy}","received_events_url":"https://api.github.com/users/kevinpdavies/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-06-10T05:52:42Z","updated_at":"2015-06-20T01:16:34Z","closed_at":null,"body":"The dc:subject returned in an OAIPMH ListRecords request is always empty. \r\n\r\nThis field is mapped to keywords_csv in Geonode in file:\r\n\r\n    geonode/catalogue/backends/pycsw_local_mappings.py\r\n\r\nWhen a keyword is added to a layer, a new tag is created for that keyword and linked to the base record. There is also a django 'content type' stored with this relationship, and it is set to 'layer' (id = 41).\r\n\r\nHowever, when the pycsw/server.py retrieves the keywords using:\r\n\r\n    keywords = util.getqattr(recobj, queryables['dc:subject']['dbcol'])\r\n\r\nThe log file (with DEBUG level) shows the following two queries:\r\n\r\n    Wed, 10 Jun 2015 00:30:29] [DEBUG] file=/usr/lib/python2.7/dist-packages/django/db/backends/util.py line=79 module=util function=execute (0.000) SELECT \"django_content_type\".\"id\", \"django_content_type\".\"name\", \"django_content_type\".\"app_label\", \"django_content_type\".\"model\" FROM \"django_content_type\" WHERE (\"django_content_type\".\"model\" = 'resourcebase'  AND \"django_content_type\".\"app_label\" = 'base' ); args=('resourcebase', u'base')\r\n    Wed, 10 Jun 2015 00:30:29] [DEBUG] file=/usr/lib/python2.7/dist-packages/django/db/backends/util.py line=79 module=util function=execute (0.001) SELECT DISTINCT \"taggit_tag\".\"id\", \"taggit_tag\".\"name\", \"taggit_tag\".\"slug\" FROM \"taggit_tag\" INNER JOIN \"taggit_taggeditem\" ON ( \"taggit_tag\".\"id\" = \"taggit_taggeditem\".\"tag_id\" ) WHERE (\"taggit_taggeditem\".\"object_id\" = 1  AND \"taggit_taggeditem\".\"content_type_id\" = 38 ) LIMIT 21; args=(1, 38)\r\n\r\nThe first query seems to be looking for the content_type_id for 'resourcebase' rather than 'layer'. The second query is then retrieving keywords (tags) with a content type ID of '38'.\r\n\r\nI can confirm this by changing the 'content type' of the record/tag relationship from 'layer' to 'resource base' through the geonode admin screen. The dc:subject field is then populated as expected.\r\n\r\nSo changing the 'content type' of the record/tag relationship to 'resource base' fixes the empty dc:subject problem, however, the keywords are no longer visible on the layer page in geonode. \r\n\r\n"},"comment":{"url":"https://api.github.com/repos/geopython/pycsw/issues/comments/113690615","html_url":"https://github.com/geopython/pycsw/issues/339#issuecomment-113690615","issue_url":"https://api.github.com/repos/geopython/pycsw/issues/339","id":113690615,"user":{"login":"tomkralidis","id":910430,"avatar_url":"https://avatars.githubusercontent.com/u/910430?v=3","gravatar_id":"","url":"https://api.github.com/users/tomkralidis","html_url":"https://github.com/tomkralidis","followers_url":"https://api.github.com/users/tomkralidis/followers","following_url":"https://api.github.com/users/tomkralidis/following{/other_user}","gists_url":"https://api.github.com/users/tomkralidis/gists{/gist_id}","starred_url":"https://api.github.com/users/tomkralidis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomkralidis/subscriptions","organizations_url":"https://api.github.com/users/tomkralidis/orgs","repos_url":"https://api.github.com/users/tomkralidis/repos","events_url":"https://api.github.com/users/tomkralidis/events{/privacy}","received_events_url":"https://api.github.com/users/tomkralidis/received_events","type":"User","site_admin":false},"created_at":"2015-06-20T01:16:34Z","updated_at":"2015-06-20T01:16:34Z","body":"@capooti @simod I found the below alternatives work:\r\n\r\n```python\r\n# instead of this\r\nkeywords_qs = self.keywords.all()\r\n# this works\r\nkeywords_qs = self.get_real_concrete_instance_class().keywords.all()\r\n# this works too\r\nkeywords_qs = self.get_real_instance().keywords.all()\r\n# this works too\r\nkeywords_qs = self.get_real_instance_class().keywords.all()\r\n```\r\nAny comments?  Is there a preferred method to use?"}}