Subversion Repositories SmartDukaan

Rev

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

Rev 16831 Rev 16834
Line 165... Line 165...
165
                'JSON was incorrect.')
165
                'JSON was incorrect.')
166
            
166
            
167
            
167
            
168
    def on_post(self, request, resp):
168
    def on_post(self, request, resp):
169
        res = None
169
        res = None
-
 
170
        rejectCount = 0
170
        try:
171
        try:
171
            boundary = request.content_type.split(";")[1].strip().split("=")[1]
172
            boundary = request.content_type.split(";")[1].strip().split("=")[1]
172
            pdict= {'boundary':boundary}
173
            pdict= {'boundary':boundary}
173
            chunks = []
-
 
174
            filepath = "/tmp/rejectfile"
174
            filepath = "/tmp/rejectfile"
175
            with open(filepath, 'wb') as image_file:
175
            with open(filepath, 'wb') as image_file:
176
                while True:
176
                while True:
177
                    chunk = request.stream.read(4096)
177
                    chunk = request.stream.read(4096)
178
                    if not chunk:
178
                    if not chunk:
Line 181... Line 181...
181
            with open(filepath, 'r') as image_file:
181
            with open(filepath, 'r') as image_file:
182
                res = cgi.parse_multipart(image_file, pdict)['rejects'][0]
182
                res = cgi.parse_multipart(image_file, pdict)['rejects'][0]
183
            if res:
183
            if res:
184
                with open(filepath, 'wb') as image_file:
184
                with open(filepath, 'wb') as image_file:
185
                    image_file.write(res)
185
                    image_file.write(res)
186
                rejectCount = process_rejects(filepath) #this function is not yet implemented
186
                rejectCount += process_rejects(filepath)
187
                resp.content_type = 'text/html'
187
                resp.content_type = 'text/html'
188
                resp.body = """
188
                resp.body = """
189
                    <html><head><title>Upload Rejects</title></head><body>
189
                    <html><head><title>Upload Rejects</title></head><body>
190
                <h1>Reject Successful</h1>
190
                <h1>Reject Successful</h1>
191
                <h2> %d orders rejected</h2>
191
                <h2> %d orders rejected</h2>