From ed16ae2183ad44a7ba89aedd331a180455ed0836 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Tue, 13 Jul 2010 23:14:53 +0200 Subject: [PATCH] Always register URL rules. This fixes #81 --- CHANGES | 4 ++++ flask/app.py | 13 ++++++++----- flask/helpers.py | 4 +--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 0c8f965e..db26bdc7 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,10 @@ Release date to be announced, codename to be decided. - OPTIONS is now automatically implemented by Flask unless the application explictly adds 'OPTIONS' as method to the URL rule. In this case no automatic OPTIONS handling kicks in. +- static rules are now even in place if there is no static folder + for the module. This was implemented to aid GAE which will + remove the static folder if it's part of a mapping in the .yml + file. Version 0.5.1 ------------- diff --git a/flask/app.py b/flask/app.py index 02f22aa3..a70a930d 100644 --- a/flask/app.py +++ b/flask/app.py @@ -271,11 +271,14 @@ class Flask(_PackageBoundObject): #: app.url_map.converters['list'] = ListConverter self.url_map = Map() - # if there is a static folder, register it for the application. - if self.has_static_folder: - self.add_url_rule(self.static_path + '/', - endpoint='static', - view_func=self.send_static_file) + # register the static folder for the application. Do that even + # if the folder does not exist. First of all it might be created + # while the server is running (usually happens during development) + # but also because google appengine stores static files somewhere + # else when mapped with the .yml file. + self.add_url_rule(self.static_path + '/', + endpoint='static', + view_func=self.send_static_file) #: The Jinja2 environment. It is created from the #: :attr:`jinja_options`. diff --git a/flask/helpers.py b/flask/helpers.py index cf00528e..99a001dc 100644 --- a/flask/helpers.py +++ b/flask/helpers.py @@ -366,9 +366,7 @@ class _PackageBoundObject(object): .. versionadded:: 0.5 """ - template_folder = os.path.join(self.root_path, 'templates') - if os.path.isdir(template_folder): - return FileSystemLoader(template_folder) + return FileSystemLoader(os.path.join(self.root_path, 'templates')) def send_static_file(self, filename): """Function used internally to send static files from the static