Browse Source

dropped pkg_resources

pull/112/head
Armin Ronacher 15 years ago
parent
commit
fedc06c295
  1. 2
      CHANGES
  2. 6
      flask/app.py
  3. 18
      flask/helpers.py

2
CHANGES

@ -19,6 +19,8 @@ Codename to be decided, release date to be announced.
single file. single file.
- :func:`flask.send_file` now emits etags and has the ability to - :func:`flask.send_file` now emits etags and has the ability to
do conditional responses builtin. do conditional responses builtin.
- (temporarily) dropped support for zipped applications. This was a
rarely used feature and led to some confusing behaviour.
Version 0.4 Version 0.4
----------- -----------

6
flask/app.py

@ -21,7 +21,7 @@ from werkzeug.routing import Map, Rule
from werkzeug.exceptions import HTTPException, InternalServerError, NotFound from werkzeug.exceptions import HTTPException, InternalServerError, NotFound
from flask.helpers import _PackageBoundObject, url_for, get_flashed_messages, \ from flask.helpers import _PackageBoundObject, url_for, get_flashed_messages, \
_tojson_filter, get_pkg_resources, send_file _tojson_filter, send_file
from flask.wrappers import Request, Response from flask.wrappers import Request, Response
from flask.config import ConfigAttribute, Config from flask.config import ConfigAttribute, Config
from flask.ctx import _default_template_ctx_processor, _RequestContext from flask.ctx import _default_template_ctx_processor, _RequestContext
@ -319,9 +319,7 @@ class Flask(_PackageBoundObject):
`templates` folder. To add other loaders it's possible to `templates` folder. To add other loaders it's possible to
override this method. override this method.
""" """
if get_pkg_resources() is None: return FileSystemLoader(os.path.join(self.root_path, 'templates'))
return FileSystemLoader(os.path.join(self.root_path, 'templates'))
return PackageLoader(self.import_name)
def init_jinja_globals(self): def init_jinja_globals(self):
"""Called directly after the environment was created to inject """Called directly after the environment was created to inject

18
flask/helpers.py

@ -82,19 +82,6 @@ def jsonify(*args, **kwargs):
indent=None if request.is_xhr else 2), mimetype='application/json') indent=None if request.is_xhr else 2), mimetype='application/json')
def get_pkg_resources():
"""Use pkg_resource if that works, otherwise fall back to cwd. The
current working directory is generally not reliable with the notable
exception of google appengine.
"""
try:
import pkg_resources
pkg_resources.resource_stream
except (ImportError, AttributeError):
return
return pkg_resources
def url_for(endpoint, **values): def url_for(endpoint, **values):
"""Generates a URL to the given endpoint with the method provided. """Generates a URL to the given endpoint with the method provided.
The endpoint is relative to the active module if modules are in use. The endpoint is relative to the active module if modules are in use.
@ -365,7 +352,4 @@ class _PackageBoundObject(object):
:param resource: the name of the resource. To access resources within :param resource: the name of the resource. To access resources within
subfolders use forward slashes as separator. subfolders use forward slashes as separator.
""" """
pkg_resources = get_pkg_resources() return open(os.path.join(self.root_path, resource), 'rb')
if pkg_resources is None:
return open(os.path.join(self.root_path, resource), 'rb')
return pkg_resources.resource_stream(self.import_name, resource)

Loading…
Cancel
Save