Permalink
Browse files

Properly handle multi-valued hooks.

  • Loading branch information...
1 parent 8f67011 commit d8b6636b2d961b8b1ea2b29cb41ed81dfc58d438 @dustin dustin committed Jul 4, 2009
Showing with 11 additions and 6 deletions.
  1. +4 −4 bin.py
  2. +5 −1 models.py
  3. +2 −1 templates/bin.html
View
8 bin.py
@@ -21,13 +21,13 @@ def post(self):
post.headers = dict(self.request.headers)
post.body = self.request.body
post.query_string = self.request.query_string
- post.form_data = dict(self.request.POST)
+ post.form_data = [[k,v] for k,v in self.request.POST.items()]
post.put()
if 'http://' in self.request.query_string:
- urlfetch.fetch(url=self.request.query_string.replace('http://', 'http://hookah.webhooks.org/'),
- payload=urllib.urlencode(dict(self.request.POST)), method='POST')
+ urlfetch.fetch(url=self.request.query_string.replace('http://', 'http://hookah.webhooks.org/'),
+ payload=urllib.urlencode(self.request.POST.items()), method='POST')
self.redirect('/%s' % bin.name)
-
+
def _get_bin(self):
name = self.request.path.replace('/', '')
bin = Bin.all().filter('name =', name).get()
View
@@ -49,7 +49,11 @@ def id(self):
def __iter__(self):
out = []
if self.form_data:
- for k,v in self.form_data.items():
+ if hasattr(self.form_data, 'items'):
+ items = self.form_data.items()
+ else:
+ items = self.form_data
+ for k,v in items:
try:
outval = simplejson.dumps(simplejson.loads(v), sort_keys=True, indent=2)
except ValueError:
View
@@ -28,7 +28,8 @@
<form action="?test" method="post">
<input type="hidden" name="foo" value="bar" />
<input type="hidden" name="bar" value="baz" />
+ <input type="hidden" name="bar" value="baz two" />
<input type="submit" value="Test Post" />
</form>
<a href="/">Back Home</a>
-{% endblock %}
+{% endblock %}

0 comments on commit d8b6636

Please sign in to comment.