Commit graph

2729 commits

Author SHA1 Message Date
David Lord
790b8ad2a1 Merge pull request #2249 from davidism/provide-automatic-options
Continue #1489: Add kwarg to disable auto OPTIONS on add_url_rule
2017-04-21 08:31:11 -07:00
David Lord
3f10dd52c6 update changelog
move test next to existing test, rename
reword / reflow param doc
2017-04-21 07:26:30 -07:00
David Lord
3d22b81edf Merge branch 'master' into jrmccarthy-master 2017-04-21 07:03:46 -07:00
David Lord
d3dc1c7446 Merge pull request #2017 from rocambolesque/patch-1
Add scheme to url_build error handler parameters
2017-04-20 09:10:27 -07:00
David Lord
a2acabcc3f add test for build error special values 2017-04-20 08:52:37 -07:00
rocambolesque
e111d8dbf3 Add scheme to url_build error handler parameters 2017-04-20 08:30:07 -07:00
Sobolev Nikita
cce1d62fcf Fix typo in app.py (#2248) 2017-04-19 07:46:33 +02:00
David Lord
ffa31f1ee4 Merge pull request #1886 from dawran6/test_bp_endpoint_dec
Enhance code coverage for Blueprint.endpoint
2017-04-14 09:22:12 -07:00
David Lord
a0006dd8c9 Merge pull request #2117 from accraze/testing-docs-fix
Added missing testing config
2017-04-13 16:45:24 -07:00
David Lord
0f514cea8f use app.testing property instead of config 2017-04-13 16:32:44 -07:00
accraze
f3f4aa325b Added missing testing config
fixes #1302
2017-04-13 16:27:58 -07:00
David Lord
5126b95d33 Merge pull request #2242 from davidism/utcfromtimestamp
get mtime in utc
2017-04-13 15:14:26 -07:00
David Lord
c6bb311175 get mtime in utc 2017-04-13 14:55:56 -07:00
David Lord
0d9852e2ad Merge pull request #2238 from davidism/bugfix/latin1-filename
filename can be latin-1, not just ascii
2017-04-12 10:12:30 -07:00
David Lord
50851d6a60 filename can be latin-1, not just ascii
only normalize basic name when utf-8 header is needed
ref #2223
2017-04-12 09:59:25 -07:00
ka7
5a76bbe7c7 Fix typo in docs (#2237) 2017-04-11 21:44:32 +02:00
David Lord
d13febda57 add changelog for #2223 2017-04-08 11:08:08 -07:00
David Lord
8f993422f0 Merge pull request #2223 from antlarr/master
Fix send_file's attachment_filename to work with non-ascii filenames
2017-04-08 10:54:20 -07:00
David Lord
01e6088c41 need to test against raw header
parsing prefers the last value parsed for the option
2017-04-08 10:33:06 -07:00
David Lord
100863e4fd style cleanup
break out header parts in test
test for no filename* parameter for ascii header
2017-04-07 18:02:31 -07:00
Antonio Larrosa
cca5c27a67 Keep using only filename if it's valid ascii 2017-04-07 20:34:52 +02:00
jab
8a2db3db18 Change Flask.__init__ to accept two new keyword arguments, host_matching and static_host. (#1560)
This enables host_matching to be set properly by the time the constructor adds
the static route, and enables the static route to be properly associated with
the required host.

Previously, you could only enable host_matching once your app was already
instantiated (e.g. app.url_map.host_matching = True), but at that point
the constructor would have already added the static route without host matching
and an associated host, leaving the static route in a broken state.

Fixes #1559.
2017-04-07 16:31:54 +02:00
Grey Li
3d20e9184d Add example for virtualenv integration in cli docs (#2234) 2017-04-07 07:10:43 -07:00
David Lord
a72778fdda Merge pull request #2231 from asilversempirical/patch-1
Update out of date jsonify documentation
2017-04-06 08:31:25 -07:00
asilversempirical
d915c390a2 Update out of date jsonify documentation
https://github.com/pallets/flask/pull/2193 changed the conditions for when jsonify pretty prints, but this comment wasn't updated.
2017-04-06 11:26:01 -04:00
Adam Geitgey
742a143efd Correct imports in file upload example (#2230)
The example code uses `flash` but doesn't import it. So the code as written doesn't work.

This simply adds `flash` to the list of imports in the sample code.
2017-04-04 22:26:40 +02:00
Markus Unterwaditzer
6b38678139 Merge branch '0.12-maintenance' 2017-03-31 18:44:33 +02:00
Markus Unterwaditzer
247a0c906d Revert "Handle BaseExceptions (#2222)"
This reverts commit 1d4448abe3.
2017-03-31 18:44:14 +02:00
Markus Unterwaditzer
0cbee768d3 Bump to dev version 2017-03-31 18:43:52 +02:00
Markus Unterwaditzer
c6a9895dc6 Bump version number to 0.12.1 2017-03-31 18:43:36 +02:00
Markus Unterwaditzer
6b77184efb Prepare for 0.12.1 2017-03-31 18:43:34 +02:00
Markus Unterwaditzer
5b10ba89ce Correct changelog 2017-03-31 18:41:10 +02:00
Markus Unterwaditzer
6af8260d77 Merge branch 'Diggsey-db-handle-baseexceptions' into 0.12-maintenance 2017-03-31 18:40:55 +02:00
Diggory Blake
65cf64e019 Make test more idiomatic 2017-03-31 18:40:46 +02:00
Diggory Blake
965d444e0f Add test and changes 2017-03-31 18:40:46 +02:00
Diggory Blake
d41d0803ef Handle BaseExceptions 2017-03-31 18:40:46 +02:00
Diggory Blake
2774221987 Handle BaseExceptions (#2222)
* Handle BaseExceptions

* Add test and changes

* Make test more idiomatic
2017-03-31 18:07:43 +02:00
Antonio Larrosa
ebce4e2fc3 Remove unidecode dependency and use unicodedata instead
I found a way to remove the unidecode dependency without sacrificing
much by using unicodedata.normalize .
2017-03-30 17:32:21 +02:00
Antonio Larrosa
5e8ac066e4 Fix previous commits to work with python 2 and python 3
Also, parse_options_header seems to interpret filename* so we better
test the actual value used in the headers (and since it's valid
in any order, use a set to compare)
2017-03-24 20:05:01 +01:00
David Lord
be67b9d3ba Merge pull request #2217 from edbrannin/patch-1
shorten output when ImportError due to app bug.
2017-03-24 08:59:00 -07:00
Antonio Larrosa
0d07974a49 Fix send_file to work with non-ascii filenames
This commit implements https://tools.ietf.org/html/rfc2231#section-4 in
order to support sending unicode characters. Tested on both Firefox and
Chromium under Linux.

This adds unidecode as a dependency, which might be relaxed by using
.encode('latin-1', 'ignore') but wouldn't be as useful.

Also, added a test for the correct headers to be added.

Previously, using a filename parameter to send_file with unicode characters, it
failed with the next error since HTTP headers don't allow non latin-1 characters.
Error on request:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/werkzeug/serving.py", line 193, in run_wsgi
    execute(self.server.app)
  File "/usr/lib/python3.6/site-packages/werkzeug/serving.py", line 186, in execute
    write(b'')
  File "/usr/lib/python3.6/site-packages/werkzeug/serving.py", line 152, in write
    self.send_header(key, value)
  File "/usr/lib64/python3.6/http/server.py", line 509, in send_header
    ("%s: %s\r\n" % (keyword, value)).encode('latin-1', 'strict'))
UnicodeEncodeError: 'latin-1' codec can't encode character '\uff0f' in position 58: ordinal not in range(256)

Fixes #1286
2017-03-23 17:30:48 +01:00
Ed Brannin
9c40039620 Fix CLI test for ImportError -> NoAppException 2017-03-21 16:17:09 -04:00
Ed Brannin
9223569767 shorten output when ImportError due to app bug.
Before:
```
C:\dev\tmp>py -2 -m flask run
Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "c:\dev\sourcetree\flask\flask\__main__.py", line 15, in <module>
    main(as_module=True)
  File "c:\dev\sourcetree\flask\flask\cli.py", line 523, in main
    cli.main(args=args, prog_name=name)
  File "c:\dev\sourcetree\flask\flask\cli.py", line 383, in main
    return AppGroup.main(self, *args, **kwargs)
  File "C:\Python27\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Python27\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Python27\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Python27\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Python27\lib\site-packages\click\decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "C:\Python27\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\dev\sourcetree\flask\flask\cli.py", line 433, in run_command
    app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
  File "c:\dev\sourcetree\flask\flask\cli.py", line 153, in __init__
    self._load_unlocked()
  File "c:\dev\sourcetree\flask\flask\cli.py", line 177, in _load_unlocked
    self._app = rv = self.loader()
  File "c:\dev\sourcetree\flask\flask\cli.py", line 238, in load_app
    rv = locate_app(self.app_import_path)
  File "c:\dev\sourcetree\flask\flask\cli.py", line 91, in locate_app
    __import__(module)
  File "C:\dev\tmp\error.py", line 1, in <module>
    import whatisthisidonteven
ImportError: No module named whatisthisidonteven
```

After:
```
C:\dev\tmp>py -2 -m flask run
Usage: python -m flask run [OPTIONS]

Error: There was an error trying to import the app (error):
Traceback (most recent call last):
  File "c:\dev\sourcetree\flask\flask\cli.py", line 91, in locate_app
    __import__(module)
  File "C:\dev\tmp\error.py", line 1, in <module>
    import whatisthisidonteven
ImportError: No module named whatisthisidonteven```
2017-03-21 15:22:15 -04:00
David Lord
9e84eaa6c2 Merge pull request #2209 from svenstaro/print-stacktrace-on-cli-error
Print a stacktrace on CLI error (closes #2208)
2017-03-16 13:43:01 -07:00
Sven-Hendrik Haase
edd6e3154d Add test to showcase that printing a traceback works 2017-03-16 20:56:12 +01:00
Sven-Hendrik Haase
c53aa3affe Remove useless pass 2017-03-16 14:42:16 +01:00
Sven-Hendrik Haase
ae6617e85d Print a stacktrace on CLI error (closes #2208) 2017-03-16 14:37:58 +01:00
Jan Ferko
7664e605ba Use print function in quickstart (#2204)
Example in URL Building section uses `print` statement
instead of `print` function, which causes syntax error
when example is run on Python 3.
2017-03-13 13:58:24 +01:00
John Bodley
0dae045fe7 Document run() host defaulting to SERVER_NAME 2017-03-11 18:59:34 +01:00
Ben
42dfa1fce3 Fix broken link (#2202) 2017-03-08 20:26:38 +01:00