Subversion Repositories SmartDukaan

Rev

Rev 16817 | Rev 16819 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16817 Rev 16818
Line 13... Line 13...
13
import os.path
13
import os.path
14
import re
14
import re
15
import traceback
15
import traceback
16
import urlparse
16
import urlparse
17
import xlrd
17
import xlrd
-
 
18
import cgi
18
class StoreOrder():
19
class StoreOrder():
19
    def on_post(self, req, resp):
20
    def on_post(self, req, resp):
20
        
21
        
21
        try:
22
        try:
22
            string1 = req.stream.read()
23
            string1 = req.stream.read()
Line 162... Line 163...
162
                'Could not decode the request body. The '
163
                'Could not decode the request body. The '
163
                'JSON was incorrect.')
164
                'JSON was incorrect.')
164
            
165
            
165
            
166
            
166
    def on_post(self, request, resp):
167
    def on_post(self, request, resp):
-
 
168
        
167
        try:
169
        try:
168
            boundary = request.content_type.split(";")[1].strip().split("=")[1]
170
            boundary = request.content_type.split(";")[1].strip().split("=")[1]
169
            print boundary
171
            pdict = {'boundary':boundary}
170
            chunks = []
172
            chunks = []
171
            filepath = "/tmp/rejectfile"
173
            filepath = "/tmp/rejectfile"
172
            with open(filepath, 'wb') as image_file:
174
            with open(filepath, 'wb') as image_file:
173
                while True:
175
                while True:
174
                    chunk = request.stream.read(4096)
176
                    chunk = request.stream.read(4096)
Line 177... Line 179...
177
                    chunks.append(chunk) 
179
                    chunks.append(chunk) 
178
                
180
                
179
                chunk = "".join(chunks)
181
                chunk = "".join(chunks)
180
                print "Chunk1"
182
                print "Chunk1"
181
                print chunk
183
                print chunk
182
                chunk = utils.find_between(chunk, boundary, boundary)
-
 
183
                print "Chunk2 after boundary removed"
-
 
184
                print chunk
-
 
185
                chunk = chunk.split("\n\n")[1]    
-
 
186
                image_file.write(chunk)
-
 
187
                print "Final chunk"
-
 
188
                print chunk
-
 
189
 
184
 
-
 
185
            cgi.parse_multipart(self.request.body_file, pdict)
190
            #rejectCount = process_rejects(filepath) #this function is not yet implemented
186
            #rejectCount = process_rejects(filepath) #this function is not yet implemented
191
            rejectCount = 1
187
            rejectCount = 1
192
            resp.content_type = 'text/html'
188
            resp.content_type = 'text/html'
193
            resp.body = """
189
            resp.body = """
194
                <html><head><title>Upload Rejects</title></head><body>
190
                <html><head><title>Upload Rejects</title></head><body>