Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: sitescripts/reports/web/updateReport.py

Issue 5717434384252928: Issue 2267 - Unify form handling by reusing form_handler() and encode_email_address() (Closed)
Left Patch Set: Created April 2, 2015, 2:24 p.m.
Right Patch Set: Addressed comment Created April 28, 2015, 8:42 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sitescripts/formmail/web/formmail.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details. 13 # GNU General Public License for more details.
14 # 14 #
15 # You should have received a copy of the GNU General Public License 15 # You should have received a copy of the GNU General Public License
16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
17 17
18 import re, os, sys, random 18 import re, os, sys, random
19 from sitescripts.utils import get_config, get_template, setupStderr 19 from sitescripts.utils import get_config, get_template
20 from sitescripts.web import url_handler, form_handler 20 from sitescripts.web import url_handler, form_handler
21 from sitescripts.reports.utils import calculateReportSecret, calculateReportSecr et_compat, getReport, saveReport, sendUpdateNotification, getUserId, updateUserU sefulness 21 from sitescripts.reports.utils import calculateReportSecret, calculateReportSecr et_compat, getReport, saveReport, sendUpdateNotification, getUserId, updateUserU sefulness
22 22
23 @url_handler('/updateReport') 23 @url_handler('/updateReport')
24 @form_handler 24 @form_handler
25 def handleRequest(environ, start_response, params): 25 def handleRequest(environ, start_response, params):
26 setupStderr(environ['wsgi.errors'])
27
28 guid = params.get('guid', '').lower() 26 guid = params.get('guid', '').lower()
29 if not re.match(r'^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$', guid): 27 if not re.match(r'^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$', guid):
30 return showError('Invalid or missing report GUID', start_response) 28 return showError('Invalid or missing report GUID', start_response)
31 29
32 reportData = getReport(guid) 30 reportData = getReport(guid)
33 31
34 if reportData == None: 32 if reportData == None:
35 return showError('Report does not exist', start_response) 33 return showError('Report does not exist', start_response)
36 34
37 secret = calculateReportSecret(guid) 35 secret = calculateReportSecret(guid)
(...skipping 25 matching lines...) Expand all
63 newURL = get_config().get('reports', 'urlRoot') + guid 61 newURL = get_config().get('reports', 'urlRoot') + guid
64 newURL += '?updated=' + str(int(random.uniform(0, 10000))) 62 newURL += '?updated=' + str(int(random.uniform(0, 10000)))
65 newURL += '#secret=' + secret 63 newURL += '#secret=' + secret
66 start_response('302 Found', [('Location', newURL.encode('utf-8'))]) 64 start_response('302 Found', [('Location', newURL.encode('utf-8'))])
67 return [] 65 return []
68 66
69 def showError(message, start_response): 67 def showError(message, start_response):
70 template = get_template(get_config().get('reports', 'errorTemplate')) 68 template = get_template(get_config().get('reports', 'errorTemplate'))
71 start_response('400 Processing Error', [('Content-Type', 'application/xhtml+xm l; charset=utf-8')]) 69 start_response('400 Processing Error', [('Content-Type', 'application/xhtml+xm l; charset=utf-8')])
72 return [template.render({'message': message}).encode('utf-8')] 70 return [template.render({'message': message}).encode('utf-8')]
LEFTRIGHT

Powered by Google App Engine
This is Rietveld