Opened 18 years ago
Closed 18 years ago
#6746 closed (fixed)
`GoogleMap` does not use `mark_safe`.
| Reported by: | Owned by: | jbronn | |
|---|---|---|---|
| Component: | GIS | Version: | gis |
| Severity: | Keywords: | gis google GoogleMap | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Working with the example in contrib/gis/maps/google/init.py.
HTML does not render correctly, for example:
<script>
renders as:
<script>
Using mark_safe in the view:
from django.utils.safestring import mark_safe
from django.contrib.gis.maps.google import *
from django.contrib.gis.shortcuts import *
def test(request):
return mark_safe(render_to_response('base.html', {'google' : GoogleMap(key="blah")}))
produces a traceback:
Traceback (most recent call last):
File "/opt/local/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 277, in run
self.result = application(self.environ, self.start_response)
File "/opt/local/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 631, in __call__
return self.application(environ, start_response)
File "/opt/local/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 209, in __call__
response = middleware_method(request, response)
File "/opt/local/lib/python2.5/site-packages/django/middleware/common.py", line 90, in process_response
if response.status_code == 404:
AttributeError: 'SafeString' object has no attribute 'status_code'
Change History (5)
comment:1 by , 18 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
comment:2 by , 18 years ago
| Keywords: | gis google GoogleMap added |
|---|---|
| Resolution: | invalid |
| Status: | closed → reopened |
| Triage Stage: | Unreviewed → Accepted |
While the submitter's syntax is incorrect with respect to returning a HttpResponse object, there is an underlying problem -- HTML code produced by the GoogleMaps object is not marked as safe. Thus, when used in templates it is escaped (and thus the GoogleMaps XHTML and JavaScript will not work). Confirmed as a bug, and working on a fix.
comment:3 by , 18 years ago
| Owner: | changed from to |
|---|---|
| Status: | reopened → new |
comment:4 by , 18 years ago
| Status: | new → assigned |
|---|---|
| Summary: | mark_safe produces traceback with GoogleMap object → `GoogleMap` does not use `mark_safe`. |
comment:5 by , 18 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
(In [7213]) gis: Fixed #6746 by marking safe GoogleMap internal XHTML/JavaScript; added support for GPolygon and GPolyline overlays via the polygons and polylines keywords; the zoom keyword may now take a geometry for automatic zoom level determination; *.pyc files are now ignored in django.contrib.gis modules.
Hi,
the traceback is generated by django-core because you're returning a string (SafeString) instead of a
HttpResponse-object.Just add a
HttpResponsearoundmark_safeand you should be fine.Closing this as invalid.