У меня есть приложение, которое отлично работает. Я пытаюсь заставить один из сценариев работать, только если пользователь является администратором (я). Логин администратора работает нормально, но затем меня перенаправляют на страницу / геокод, и ничего не происходит. Я вижу HTTP-ответ 200.
Есть предложения?
Спасибо
РЕДАКТИРОВАТЬ 2: Добавить полный код по запросу.
app.yaml:
application: theapp
version: 1
runtime: python
api_version: 1
handlers:
- url: /geocode
script: geocode.py
login: admin
- url: /admin/.*
script: $PYTHON_LIB/google/appengine/ext/admin
login: admin
- url: /favicon\.ico
static_files: static/images/favicon.ico
upload: static/images/favicon\.ico
- url: /static
static_dir: static
- url: /.*
script: first.py
secure: never
builtins:
- appstats: on
inbound_services:
- warmup
first.py:
import os
from beer import Beer
from desktop import Desktop
from geocode import Geocode
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
application = webapp.WSGIApplication(
[('/', Desktop),
('/beer', Beer),
('/geocode', Geocode)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
geocode.py:
import pubs
import os
import time
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp import util
from google.appengine.api import urlfetch
import urllib
import urllib2
import simplejson
class Geocode(webapp.RequestHandler):
'''Class for ./geocode
A couple of methods to take the address' from the Pubs.pub_address array
and turn them into usefull Latitudes & Longitudes.
'''
def get_lat_long(self, location):
place = urllib.quote_plus(location)
print location
url = "http://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=true®ion=no" % (place)
print url
out = urllib.urlopen(url)
jsonResponse = simplejson.load(out)
pub_location = jsonResponse.get('results')[0].get('geometry').get('location')
lat = pub_location.get('lat')
lng = pub_location.get('lng')
return lat, lng
def get(self):
pub_address = []
pub_bounce = []
self.response.headers['Content-Type'] = 'text/html; charset=utf-8'
path = os.path.join(os.path.dirname(__file__), 'templates')
path = os.path.join(path, 'geocode.html')
for i, element in enumerate(pubs.pub_list):
pub_bounce.append(pubs.pub_list[i].pub_bounce)
for i, element in enumerate(pubs.pub_list):
pub_address.append(pubs.pub_list[i].pub_address.encode('utf-8'))
for i, element in enumerate(pub_address):
pubs.pub_list[i].pub_lat, pubs.pub_list[i].pub_lng = self.get_lat_long(pub_address[i])
print pubs.pub_list[i].pub_lat, pubs.pub_list[i].pub_lng
time.sleep(.2)
template_values = {"pub_address": pub_address, "pub_bounce": pub_bounce}
self.response.out.write(template.render(path, template_values))