[GeoNode-devel] after mass data import : "KeyError: 'request'" when clicking on a document

Haertel, Michael (IITA) M.Haertel at cgiar.org
Fri May 6 01:40:37 PDT 2016


Hello Simone,

Thank you for attending to this so promptly.

This is what is added to the error.log at the time I click on a link:

[Fri May 06 03:38:41.634679 2016] [:error] [pid 2361] Internal Server Error: /documents/98
[Fri May 06 03:38:41.634741 2016] [:error] [pid 2361] Traceback (most recent call last):
[Fri May 06 03:38:41.634752 2016] [:error] [pid 2361]   File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 112, in get_response
[Fri May 06 03:38:41.634764 2016] [:error] [pid 2361]     response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Fri May 06 03:38:41.634772 2016] [:error] [pid 2361]   File "/usr/local/lib/python2.7/dist-packages/geonode/documents/views.py", line 103, in document_detail
[Fri May 06 03:38:41.634792 2016] [:error] [pid 2361]     context_dict["social_links"] = build_social_links(request, document)
[Fri May 06 03:38:41.634800 2016] [:error] [pid 2361]   File "/usr/local/lib/python2.7/dist-packages/geonode/utils.py", line 609, in build_social_links
[Fri May 06 03:38:41.634808 2016] [:error] [pid 2361]     caveats = build_caveats(resourcebase)
[Fri May 06 03:38:41.634816 2016] [:error] [pid 2361]   File "/usr/local/lib/python2.7/dist-packages/geonode/utils.py", line 589, in build_caveats
[Fri May 06 03:38:41.634824 2016] [:error] [pid 2361]     caveats.append(resourcebase.maintenance_frequency_title())
[Fri May 06 03:38:41.634831 2016] [:error] [pid 2361]   File "/usr/local/lib/python2.7/dist-packages/geonode/base/models.py", line 613, in maintenance_frequency_title
[Fri May 06 03:38:41.634839 2016] [:error] [pid 2361]     return [v for i, v in enumerate(UPDATE_FREQUENCIES) if v[0] == self.maintenance_frequency][0][1].title()
[Fri May 06 03:38:41.634859 2016] [:error] [pid 2361] IndexError: list index out of range
[Fri May 06 03:38:41.656303 2016] [:error] [pid 2361] [remote 127.0.0.1:20011] mod_wsgi (pid=2361): Exception occurred processing WSGI script '/var/www/geonode/wsgi/geonode.wsgi'.
[Fri May 06 03:38:41.656511 2016] [:error] [pid 2361] [remote 127.0.0.1:20011] Traceback (most recent call last):
[Fri May 06 03:38:41.656645 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 206, in __call__
[Fri May 06 03:38:41.656779 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     response = self.get_response(request)
[Fri May 06 03:38:41.656835 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 194, in get_response
[Fri May 06 03:38:41.656885 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Fri May 06 03:38:41.656966 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 236, in handle_uncaught_exception
[Fri May 06 03:38:41.657032 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     return callback(request, **param_dict)
[Fri May 06 03:38:41.657083 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/utils/decorators.py", line 99, in _wrapped_view
[Fri May 06 03:38:41.657310 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     response = view_func(request, *args, **kwargs)
[Fri May 06 03:38:41.657345 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/views/defaults.py", line 46, in server_error
[Fri May 06 03:38:41.657404 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     return http.HttpResponseServerError(template.render(Context({})))
[Fri May 06 03:38:41.657478 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 140, in render
[Fri May 06 03:38:41.657539 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     return self._render(context)
[Fri May 06 03:38:41.657587 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
[Fri May 06 03:38:41.657625 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     return self.nodelist.render(context)
[Fri May 06 03:38:41.657673 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 840, in render
[Fri May 06 03:38:41.657787 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     bit = self.render_node(node, context)
[Fri May 06 03:38:41.657856 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 854, in render_node
[Fri May 06 03:38:41.657897 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     return node.render(context)
[Fri May 06 03:38:41.657968 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/template/loader_tags.py", line 53, in render
[Fri May 06 03:38:41.658012 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     result = self.nodelist.render(context)
[Fri May 06 03:38:41.658061 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 840, in render
[Fri May 06 03:38:41.658100 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     bit = self.render_node(node, context)
[Fri May 06 03:38:41.658131 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 854, in render_node
[Fri May 06 03:38:41.658171 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     return node.render(context)
[Fri May 06 03:38:41.658242 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/template/loader_tags.py", line 155, in render
[Fri May 06 03:38:41.658283 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     return self.render_template(self.template, context)
[Fri May 06 03:38:41.658311 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/template/loader_tags.py", line 137, in render_template
[Fri May 06 03:38:41.658347 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     output = template.render(context)
[Fri May 06 03:38:41.658375 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 140, in render
[Fri May 06 03:38:41.658410 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     return self._render(context)
[Fri May 06 03:38:41.658438 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
[Fri May 06 03:38:41.658474 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     return self.nodelist.render(context)
[Fri May 06 03:38:41.658502 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 840, in render
[Fri May 06 03:38:41.658537 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     bit = self.render_node(node, context)
[Fri May 06 03:38:41.658563 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/template/base.py", line 854, in render_node
[Fri May 06 03:38:41.658598 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     return node.render(context)
[Fri May 06 03:38:41.658625 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/announcements/templatetags/announcements_tags.py", line 24, in render
[Fri May 06 03:38:41.658662 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     request = context["request"]
[Fri May 06 03:38:41.658890 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]   File "/usr/lib/python2.7/dist-packages/django/template/context.py", line 56, in __getitem__
[Fri May 06 03:38:41.658940 2016] [:error] [pid 2361] [remote 127.0.0.1:20011]     raise KeyError(key)
[Fri May 06 03:38:41.659002 2016] [:error] [pid 2361] [remote 127.0.0.1:20011] KeyError: 'request'

Regards,

Michael Haertel
GIS & Database Expert
International Institute of Tropical Agriculture (IITA, www.iita.org<../../../AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/FGKNP1ID/www.iita.org>)
Headquarters and West Africa Hub
PMB 5320, Oyo Road, Ibadan 200001, Oyo State, Nigeria
International Mailing Address: IITA Limited, Part 7th Floor, Grosvenor House, 125 High Street, Croydon, Surrey, CR0 9XP
Tel: +234 2 7517472  |  USA Tel: +1 201 6336094  |  Fax: +44 208 7113786
IITA is a member of the CGIAR Consortium (www.cgiar.org<../../../AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/FGKNP1ID/www.cgiar.org>)

From: Simone Dalmasso [mailto:simone.dalmasso at gmail.com]
Sent: Friday, May 06, 2016 9:36 AM
To: Haertel, Michael (IITA)
Cc: geonode-devel at lists.osgeo.org
Subject: Re: [GeoNode-devel] after mass data import : "KeyError: 'request'" when clicking on a document

Hi, could you post the full trace of the error? is in /var/logs/apache2/error.log

2016-05-06 10:22 GMT+02:00 Haertel, Michael (IITA) <M.Haertel at cgiar.org<mailto:M.Haertel at cgiar.org>>:
Dear List,

I imported many datasets from a third party application into GeoNode by populating these database tables:


1.       Base_resourcebase

2.       Documents_document

3.       Base_contactrole

4.       Taggit_tag

5.       Taggit_taggeditem

6.       Base_link

However the link behind each document doesn’t work. I get an “Internal server error”. According to the log file the error is raised in
-----
File "/usr/lib/python2.7/dist-packages/django/template/context.py", line 56, in __getitem__

Raise KeyError(key)
KeyError: ‘request’
-----
I noticed that when I click on a link to a PDF document for the first time after it has been imported, the column “doc_file” is altered and a suffix is appended to the pdf file on disk. So I also checked file permissions but “www-data” (linux)  can write all files there. It only happens for the datasets that I imported myself. Manually added documents work fine.

I also noticed that for Ids that were manually added and removed afterwards, the links (url: documents/<id>) still work and lead to a “file not found” page without any “internal server error” message. So GeoNode somehow knows which ids are valid (accessible) and which are not. Can somebody tell me how it works?

I am not yet very good in python yet and I don’t want to debug the code at this point.

Thank you very much for your assistance,

Michael Haertel
GIS & Database Expert
International Institute of Tropical Agriculture (IITA, www.iita.org<http://../../../AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/FGKNP1ID/www.iita.org>)
Headquarters and West Africa Hub
PMB 5320, Oyo Road, Ibadan 200001, Oyo State, Nigeria
International Mailing Address: IITA Limited, Part 7th Floor, Grosvenor House, 125 High Street, Croydon, Surrey, CR0 9XP
Tel: +234 2 7517472<tel:%2B234%202%207517472>  |  USA Tel: +1 201 6336094<tel:%2B1%20201%206336094>  |  Fax: +44 208 7113786<tel:%2B44%20208%207113786>
IITA is a member of the CGIAR Consortium (www.cgiar.org<http://../../../AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/AppData/Local/Microsoft/Windows/Temporary%20Internet%20Files/Content.Outlook/FGKNP1ID/www.cgiar.org>)


_______________________________________________
geonode-devel mailing list
geonode-devel at lists.osgeo.org<mailto:geonode-devel at lists.osgeo.org>
http://lists.osgeo.org/mailman/listinfo/geonode-devel



--
Simone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geonode-devel/attachments/20160506/c21824f0/attachment-0001.html>


More information about the geonode-devel mailing list