File tree 10 files changed +127
-25
lines changed
ch12-forms/final/pypi_org/infrastructure
starter/pypi_org/infrastructure
final/pypi_org/infrastructure
starter/pypi_org/infrastructure
final/pypi_org/infrastructure
starter/pypi_org/infrastructure
final/pypi_org/infrastructure
starter/pypi_org/infrastructure
10 files changed +127
-25
lines changed Original file line number Diff line number Diff line change 1
1
import flask
2
+ from werkzeug .datastructures import MultiDict
2
3
3
4
4
5
class RequestDictionary (dict ):
@@ -13,10 +14,21 @@ def __getattr__(self, key):
13
14
def create (default_val = None , ** route_args ) -> RequestDictionary :
14
15
request = flask .request
15
16
17
+ # Adding this retro actively. Some folks are experiencing issues where they
18
+ # are getting a list rather than plain dict. I think it's from multiple
19
+ # entries in the multidict. This should fix it.
20
+ args = request .args
21
+ if isinstance (request .args , MultiDict ):
22
+ args = request .args .to_dict ()
23
+
24
+ form = request .form
25
+ if isinstance (request .args , MultiDict ):
26
+ form = request .form .to_dict ()
27
+
16
28
data = {
17
- ** request . args , # The key/value pairs in the URL query string
29
+ ** args , # The key/value pairs in the URL query string
18
30
** request .headers , # Header values
19
- ** request . form , # The key/value pairs in the body, from a HTML post form
31
+ ** form , # The key/value pairs in the body, from a HTML post form
20
32
** route_args # And additional arguments the method access, if they want them merged.
21
33
}
22
34
Original file line number Diff line number Diff line change 10
10
sys .path .insert (0 , os .path .abspath (os .path .join (
11
11
os .path .dirname (__file__ ), ".." , ".." )))
12
12
13
+ from pypi_org .bin .load_data import try_int
13
14
import pypi_org .data .db_session as db_session
14
15
from pypi_org .data .languages import ProgrammingLanguage
15
16
from pypi_org .data .licenses import License
@@ -339,13 +340,6 @@ def make_version_num(version_text):
339
340
return major , minor , build
340
341
341
342
342
- def try_int (text ) -> int :
343
- try :
344
- return int (text )
345
- except :
346
- return 0
347
-
348
-
349
343
def init_db ():
350
344
top_folder = os .path .dirname (__file__ )
351
345
rel_file = os .path .join ('..' , 'db' , 'pypi.sqlite' )
Original file line number Diff line number Diff line change 1
1
import flask
2
+ from werkzeug .datastructures import MultiDict
2
3
3
4
4
5
class RequestDictionary (dict ):
@@ -13,10 +14,21 @@ def __getattr__(self, key):
13
14
def create (default_val = None , ** route_args ) -> RequestDictionary :
14
15
request = flask .request
15
16
17
+ # Adding this retro actively. Some folks are experiencing issues where they
18
+ # are getting a list rather than plain dict. I think it's from multiple
19
+ # entries in the multidict. This should fix it.
20
+ args = request .args
21
+ if isinstance (request .args , MultiDict ):
22
+ args = request .args .to_dict ()
23
+
24
+ form = request .form
25
+ if isinstance (request .args , MultiDict ):
26
+ form = request .form .to_dict ()
27
+
16
28
data = {
17
- ** request . args , # The key/value pairs in the URL query string
29
+ ** args , # The key/value pairs in the URL query string
18
30
** request .headers , # Header values
19
- ** request . form , # The key/value pairs in the body, from a HTML post form
31
+ ** form , # The key/value pairs in the body, from a HTML post form
20
32
** route_args # And additional arguments the method access, if they want them merged.
21
33
}
22
34
Original file line number Diff line number Diff line change 1
1
import flask
2
+ from werkzeug .datastructures import MultiDict
2
3
3
4
4
5
class RequestDictionary (dict ):
@@ -13,10 +14,21 @@ def __getattr__(self, key):
13
14
def create (default_val = None , ** route_args ) -> RequestDictionary :
14
15
request = flask .request
15
16
17
+ # Adding this retro actively. Some folks are experiencing issues where they
18
+ # are getting a list rather than plain dict. I think it's from multiple
19
+ # entries in the multidict. This should fix it.
20
+ args = request .args
21
+ if isinstance (request .args , MultiDict ):
22
+ args = request .args .to_dict ()
23
+
24
+ form = request .form
25
+ if isinstance (request .args , MultiDict ):
26
+ form = request .form .to_dict ()
27
+
16
28
data = {
17
- ** request . args , # The key/value pairs in the URL query string
29
+ ** args , # The key/value pairs in the URL query string
18
30
** request .headers , # Header values
19
- ** request . form , # The key/value pairs in the body, from a HTML post form
31
+ ** form , # The key/value pairs in the body, from a HTML post form
20
32
** route_args # And additional arguments the method access, if they want them merged.
21
33
}
22
34
Original file line number Diff line number Diff line change 1
1
import flask
2
+ from werkzeug .datastructures import MultiDict
2
3
3
4
4
5
class RequestDictionary (dict ):
@@ -13,10 +14,21 @@ def __getattr__(self, key):
13
14
def create (default_val = None , ** route_args ) -> RequestDictionary :
14
15
request = flask .request
15
16
17
+ # Adding this retro actively. Some folks are experiencing issues where they
18
+ # are getting a list rather than plain dict. I think it's from multiple
19
+ # entries in the multidict. This should fix it.
20
+ args = request .args
21
+ if isinstance (request .args , MultiDict ):
22
+ args = request .args .to_dict ()
23
+
24
+ form = request .form
25
+ if isinstance (request .args , MultiDict ):
26
+ form = request .form .to_dict ()
27
+
16
28
data = {
17
- ** request . args , # The key/value pairs in the URL query string
29
+ ** args , # The key/value pairs in the URL query string
18
30
** request .headers , # Header values
19
- ** request . form , # The key/value pairs in the body, from a HTML post form
31
+ ** form , # The key/value pairs in the body, from a HTML post form
20
32
** route_args # And additional arguments the method access, if they want them merged.
21
33
}
22
34
Original file line number Diff line number Diff line change 1
1
import flask
2
+ from werkzeug .datastructures import MultiDict
2
3
3
4
4
5
class RequestDictionary (dict ):
@@ -13,10 +14,21 @@ def __getattr__(self, key):
13
14
def create (default_val = None , ** route_args ) -> RequestDictionary :
14
15
request = flask .request
15
16
17
+ # Adding this retro actively. Some folks are experiencing issues where they
18
+ # are getting a list rather than plain dict. I think it's from multiple
19
+ # entries in the multidict. This should fix it.
20
+ args = request .args
21
+ if isinstance (request .args , MultiDict ):
22
+ args = request .args .to_dict ()
23
+
24
+ form = request .form
25
+ if isinstance (request .args , MultiDict ):
26
+ form = request .form .to_dict ()
27
+
16
28
data = {
17
- ** request . args , # The key/value pairs in the URL query string
29
+ ** args , # The key/value pairs in the URL query string
18
30
** request .headers , # Header values
19
- ** request . form , # The key/value pairs in the body, from a HTML post form
31
+ ** form , # The key/value pairs in the body, from a HTML post form
20
32
** route_args # And additional arguments the method access, if they want them merged.
21
33
}
22
34
Original file line number Diff line number Diff line change 1
1
import flask
2
+ from werkzeug .datastructures import MultiDict
2
3
3
4
4
5
class RequestDictionary (dict ):
@@ -13,10 +14,21 @@ def __getattr__(self, key):
13
14
def create (default_val = None , ** route_args ) -> RequestDictionary :
14
15
request = flask .request
15
16
17
+ # Adding this retro actively. Some folks are experiencing issues where they
18
+ # are getting a list rather than plain dict. I think it's from multiple
19
+ # entries in the multidict. This should fix it.
20
+ args = request .args
21
+ if isinstance (request .args , MultiDict ):
22
+ args = request .args .to_dict ()
23
+
24
+ form = request .form
25
+ if isinstance (request .args , MultiDict ):
26
+ form = request .form .to_dict ()
27
+
16
28
data = {
17
- ** request . args , # The key/value pairs in the URL query string
29
+ ** args , # The key/value pairs in the URL query string
18
30
** request .headers , # Header values
19
- ** request . form , # The key/value pairs in the body, from a HTML post form
31
+ ** form , # The key/value pairs in the body, from a HTML post form
20
32
** route_args # And additional arguments the method access, if they want them merged.
21
33
}
22
34
Original file line number Diff line number Diff line change 1
1
import flask
2
+ from werkzeug .datastructures import MultiDict
2
3
3
4
4
5
class RequestDictionary (dict ):
@@ -13,10 +14,21 @@ def __getattr__(self, key):
13
14
def create (default_val = None , ** route_args ) -> RequestDictionary :
14
15
request = flask .request
15
16
17
+ # Adding this retro actively. Some folks are experiencing issues where they
18
+ # are getting a list rather than plain dict. I think it's from multiple
19
+ # entries in the multidict. This should fix it.
20
+ args = request .args
21
+ if isinstance (request .args , MultiDict ):
22
+ args = request .args .to_dict ()
23
+
24
+ form = request .form
25
+ if isinstance (request .args , MultiDict ):
26
+ form = request .form .to_dict ()
27
+
16
28
data = {
17
- ** request . args , # The key/value pairs in the URL query string
29
+ ** args , # The key/value pairs in the URL query string
18
30
** request .headers , # Header values
19
- ** request . form , # The key/value pairs in the body, from a HTML post form
31
+ ** form , # The key/value pairs in the body, from a HTML post form
20
32
** route_args # And additional arguments the method access, if they want them merged.
21
33
}
22
34
Original file line number Diff line number Diff line change 1
1
import flask
2
+ from werkzeug .datastructures import MultiDict
2
3
3
4
4
5
class RequestDictionary (dict ):
@@ -13,10 +14,21 @@ def __getattr__(self, key):
13
14
def create (default_val = None , ** route_args ) -> RequestDictionary :
14
15
request = flask .request
15
16
17
+ # Adding this retro actively. Some folks are experiencing issues where they
18
+ # are getting a list rather than plain dict. I think it's from multiple
19
+ # entries in the multidict. This should fix it.
20
+ args = request .args
21
+ if isinstance (request .args , MultiDict ):
22
+ args = request .args .to_dict ()
23
+
24
+ form = request .form
25
+ if isinstance (request .args , MultiDict ):
26
+ form = request .form .to_dict ()
27
+
16
28
data = {
17
- ** request . args , # The key/value pairs in the URL query string
29
+ ** args , # The key/value pairs in the URL query string
18
30
** request .headers , # Header values
19
- ** request . form , # The key/value pairs in the body, from a HTML post form
31
+ ** form , # The key/value pairs in the body, from a HTML post form
20
32
** route_args # And additional arguments the method access, if they want them merged.
21
33
}
22
34
Original file line number Diff line number Diff line change 1
1
import flask
2
+ from werkzeug .datastructures import MultiDict
2
3
3
4
4
5
class RequestDictionary (dict ):
@@ -13,10 +14,21 @@ def __getattr__(self, key):
13
14
def create (default_val = None , ** route_args ) -> RequestDictionary :
14
15
request = flask .request
15
16
17
+ # Adding this retro actively. Some folks are experiencing issues where they
18
+ # are getting a list rather than plain dict. I think it's from multiple
19
+ # entries in the multidict. This should fix it.
20
+ args = request .args
21
+ if isinstance (request .args , MultiDict ):
22
+ args = request .args .to_dict ()
23
+
24
+ form = request .form
25
+ if isinstance (request .args , MultiDict ):
26
+ form = request .form .to_dict ()
27
+
16
28
data = {
17
- ** request . args , # The key/value pairs in the URL query string
29
+ ** args , # The key/value pairs in the URL query string
18
30
** request .headers , # Header values
19
- ** request . form , # The key/value pairs in the body, from a HTML post form
31
+ ** form , # The key/value pairs in the body, from a HTML post form
20
32
** route_args # And additional arguments the method access, if they want them merged.
21
33
}
22
34
You can’t perform that action at this time.
0 commit comments