[Commits] python.it commit r254 -
code/pythonisti/trunk/pythonisti/geo
commit a svn.python.it
commit a svn.python.it
Mar 9 Gen 2007 23:16:38 CET
Author: rhymes
Date: Tue Jan 9 23:16:35 2007
New Revision: 254
Modified:
code/pythonisti/trunk/pythonisti/geo/urls.py
code/pythonisti/trunk/pythonisti/geo/views.py
Log:
revert last commit on urls.py and views.py
Modified: code/pythonisti/trunk/pythonisti/geo/urls.py
==============================================================================
--- code/pythonisti/trunk/pythonisti/geo/urls.py (original)
+++ code/pythonisti/trunk/pythonisti/geo/urls.py Tue Jan 9 23:16:35 2007
@@ -4,6 +4,6 @@
urlpatterns = patterns('',
- (r'^json/', views.json),
- (r'^map/', views.map)
+ (r'^db/', views.db_view),
+ (r'^map/', views.map_view)
)
Modified: code/pythonisti/trunk/pythonisti/geo/views.py
==============================================================================
--- code/pythonisti/trunk/pythonisti/geo/views.py (original)
+++ code/pythonisti/trunk/pythonisti/geo/views.py Tue Jan 9 23:16:35 2007
@@ -1,30 +1,37 @@
+# Create your views here.
from django.template import Context, loader
from django.http import HttpResponse
from django.shortcuts import render_to_response
-from django.utils import simplejson
+from django.utils.simplejson import dumps, loads
from django.conf import settings
from pythonisti.geo import models
-def json(request):
+
+
+def db_view(request):
locations = models.GeoLocation.objects.all()
-
content = []
+
for item in locations:
content.append({
'info': item.username.username,
- 'location': simplejson.loads(item.geolocation)
+ 'location': loads(item.geolocation)
+ })
+
+ t = loader.get_template('geo/db.js')
+ c = Context({
+ 'locations': dumps(content)
})
- json_locations = simplejson.dumps(content)
- return HttpResponse(json_locations, mimetype='application/json')
+ return HttpResponse(t.render(c), mimetype='text/javascript')
-def map(request):
+def map_view(request):
context = {
'key': settings.GOOGLE_API_KEY,
'center': settings.MAP_CENTER,
'zoom': settings.MAP_ZOOM
- }
+ }
return render_to_response('geo/map.xhtml', context)
Maggiori informazioni sulla lista
Commits