Open ctengiz opened 9 years ago
This is by design:
Additionally to the normal dict-like item access methods (which return unmodified data as native strings), this container also supports attribute-like access to its values. Attributes are automatically de- or recoded to match :attr:
input_encoding
(default: 'utf8'). Missing attributes default to an empty string.
Try comparing type(request.GET.aparam)
with type(request.GET['aparam'])
Note that .query
and .forms
seem to be the more canonical way of spelling .GET
and .POST
, respectively
We should probably change the behavior of item-lookup at some point. This inconsistency was introduced to keep backwards-compatibility but the re-encoding behavior makes much more sense and should be the default. Unfortunately it is not easy to find an upgrade path for this kind of behavior changes.
Also encountered this bug, thanks for the info! https://gist.github.com/onny/c7ca3509e223493cb684
If anyone has time, please take a look at my PR which attempts to fix this issue. Thank you!
Suppose we got a parameter submitted which has the value of 'ğüşiöç':
aparam = 'ğüşiöç'
If request.method is 'GET':
request.GET.aparam returns : 'ğüşiöç'
--> okrequest.GET['aparam'] returns : 'ÄüÅiöç'
--> ??If request method is 'POST':
request.POST.aparam returns : ''
--> ??request.POST['aparam'] returns : 'ğüşiöç
--> okThis behaviour interrupts clean and consistent coding style. When I need to access request form parameters I need to remember correct way to access them rather than simply writing request.POST.aparam.
Is this behaaviour is intended way or is this a bug or am I missing sth?
PS: Tested with Python 3.4, Python 3.2, and latest bottle github clone code
TIA