soc.2012.www-statscollector: 4342784e: Handle POST request of the form key=valu...
sanket at soc.pidgin.im
sanket at soc.pidgin.im
Wed May 30 23:55:55 EDT 2012
----------------------------------------------------------------------
Revision: 4342784e1c27d4ebfa207abc5967ea8e30e7db33
Parent: 32c5118af135840f5c99cc264cb9f90e4fe669ae
Author: sanket at soc.pidgin.im
Date: 05/31/12 00:47:08
Branch: im.pidgin.soc.2012.www-statscollector
URL: http://d.pidgin.im/viewmtn/revision/info/4342784e1c27d4ebfa207abc5967ea8e30e7db33
Changelog:
Handle POST request of the form key=value;key=value
Currently POST request *just* handled POST data as a raw XML file. But
in future we might need better handling in the form of key-value store.
Each client generates a one-time off MD5 key to indentify any further reports
that it might send to the server. It's saved in the DB
Changes against parent 32c5118af135840f5c99cc264cb9f90e4fe669ae
patched pidgin_stats_collector/statscollector/views.py
-------------- next part --------------
============================================================
--- pidgin_stats_collector/statscollector/views.py a174f2624db78991639a3cd7a3f365bcc80b511a
+++ pidgin_stats_collector/statscollector/views.py d5f68a5f7c4eb6dfc98c6a1964aa5bd482daf60d
@@ -15,12 +15,22 @@ def handle_post(request):
def handle_post(request):
- # Get the XML file as raw_post_data
- stats_xml = request.raw_post_data
+ stats_id=""
+ stats_xml=""
+ try:
+ # Get the id of the sender
+ stats_id = request.POST['id']
+
+ # Get the XML file as raw_post_data
+ stats_xml = request.POST['xml']
+ except:
+ return HttpResponse('Broken POST request :=(\n')
+
# Parse the XML file
try:
+ print stats_xml
stats_dom = parseString(stats_xml)
# Create a file object from this data
@@ -29,8 +39,9 @@ def handle_post(request):
temp.flush()
raw_sub = RawXML()
- raw_sub.hash_id = hex(random.getrandbits(128))[2:-1]
- raw_sub.stats_xml.save(raw_sub.hash_id, File(temp))
+ raw_sub.hash_id = stats_id
+ raw_sub.file_id = hex(random.getrandbits(128))[2:-1]
+ raw_sub.stats_xml.save(raw_sub.file_id, File(temp))
raw_sub.save()
print stats_dom.toxml()
More information about the Commits
mailing list