scrapyd.webservice: use twisted.web multipart data parsing, to simplify code. closes #324

This commit is contained in:
Pablo Hoffman 2011-06-08 14:17:04 -03:00
parent 7643f14c88
commit 07df0edf74
1 changed files with 3 additions and 7 deletions

View File

@ -1,4 +1,3 @@
import cgi
import traceback
import uuid
from cStringIO import StringIO
@ -36,12 +35,9 @@ class Schedule(WsResource):
class AddVersion(WsResource):
def render_POST(self, txrequest):
ct = txrequest.requestHeaders.getRawHeaders('Content-Type')[0]
boundary = ct.split('boundary=', 1)[1]
d = cgi.parse_multipart(txrequest.content, {'boundary': boundary})
project = d['project'][0]
version = d['version'][0]
eggf = StringIO(d['egg'][0])
project = txrequest.args['project'][0]
version = txrequest.args['version'][0]
eggf = StringIO(txrequest.args['egg'][0])
self.root.eggstorage.put(eggf, project, version)
spiders = get_spider_list(project)
self.root.update_projects()