I cannot retrieve the value of the variable "g_place" in the following
python script back from "add_place.html". "g_place" is effectively
sent to "add_place.html" in the "def get(self)" section of class
AddPlace, but "g_place" is not returned to the python script in the
"def post(self)" section of class AddPlace. "g_place" is sent to
"add_place.html" and placed in the var "iwform" with the phrase
{{place|escape}}.
(I hope I have provided enough information. I am reluctant to upload
this buggy version to GAE, so I cannot just provide a link. Please
advise if there is another protocol/procedure I should be using to
provide the code as a link.)
Thanks,
Brian in Atlanta
*******************relevant python code below******************
class MainPage(webapp.RequestHandler):
def get(self):
place_id = self.request.get("place", None)
place= Group(key_name=place_id)
place.place = place_id
place.user = user
place.put()
key = db.Key.from_path("Group", place_id)
path = os.path.join(os.path.dirname(__file__),
'add_place.html')
template_values = dict(place_id=place.key(),
place=place.place)
self.response.out.write(template.render(path,
template_values))
class AddPlace(webapp.RequestHandler):
#creates blank template_values
def get(self):
g_place = self.request.get('place')
user = users.get_current_user()
param = 'add_place.html'
path = os.path.join(os.path.dirname(__file__), param)
template_values = dict(place=g_place)
self.response.out.write(template.render(path,
template_values))
#creates initial group attribute values
def post(self):
g_place = self.request.get('place')
group= Group(key_name=g_place)
group.place = g_place
group.center_lat = float(self.request.get('center_lat'))
group.center_lng = float(self.request.get('center_lng'))
group.zoom = int(self.request.get('zoom'))
group.put()
self.redirect("/?place=%s" % g_place)
application = webapp.WSGIApplication(
[('/', MainPage),
('/details.txt', Details),
('/add_place', AddPlace)],
debug=True)
*******************relevant python code above******************
*******************relevant html code below******************
var lastmarker;
var myEventListener;
var iwform = 'Enter your group\'s information:<br>'
+ '<form method="POST" onsubmit="return process(this)"
action="add_place">'
+ 'Group Name or Initials: '
+ '<br />'
+ '<strong>{{place|escape}}</strong>'
+ '<br />'
+ ' <input type="hidden" name="place" value="{{place|
addslashes}}"/>'
+ ' <input type="hidden" name="center_lat"/>'
+ ' <input type="hidden" name="center_lng"/>'
+ ' <input type="hidden" name="zoom"/>'
+ ' <input type="submit" value="Submit" />'
+ '<\/form>';
function process(form) {
// == populate map data
form.center_lat.value = String(map.getCenter().lat());
form.center_lng.value = String(map.getCenter().lng());
form.zoom.value = String(map.getZoom());
lastmarker.closeInfoWindow();
GEvent.removeListener(myEventListener);
return true;
}
*******************relevant html code above******************
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---