Skip to content

Commit

Permalink
dropped pkg_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Jul 4, 2010
1 parent 532347d commit fedc06c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Codename to be decided, release date to be announced.
single file.
- :func:`flask.send_file` now emits etags and has the ability to
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
-----------
Expand Down
6 changes: 2 additions & 4 deletions flask/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from werkzeug.exceptions import HTTPException, InternalServerError, NotFound

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.config import ConfigAttribute, Config
from flask.ctx import _default_template_ctx_processor, _RequestContext
Expand Down Expand Up @@ -319,9 +319,7 @@ def create_jinja_loader(self):
`templates` folder. To add other loaders it's possible to
override this method.
"""
if get_pkg_resources() is None:
return FileSystemLoader(os.path.join(self.root_path, 'templates'))
return PackageLoader(self.import_name)
return FileSystemLoader(os.path.join(self.root_path, 'templates'))

def init_jinja_globals(self):
"""Called directly after the environment was created to inject
Expand Down
18 changes: 1 addition & 17 deletions flask/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,6 @@ def get_current_user():
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):
"""Generates a URL to the given endpoint with the method provided.
The endpoint is relative to the active module if modules are in use.
Expand Down Expand Up @@ -365,7 +352,4 @@ def open_resource(self, resource):
:param resource: the name of the resource. To access resources within
subfolders use forward slashes as separator.
"""
pkg_resources = get_pkg_resources()
if pkg_resources is None:
return open(os.path.join(self.root_path, resource), 'rb')
return pkg_resources.resource_stream(self.import_name, resource)
return open(os.path.join(self.root_path, resource), 'rb')

0 comments on commit fedc06c

Please sign in to comment.