Skip to content

Commit

Permalink
Fix compatibility with modern versions of django-pipeline.
Browse files Browse the repository at this point in the history
django-pipeline removed match_location() in a recent release, which
broke our packaging and static finding. They no longer needed it, due to
other changes they made, but we still need it for our cross-storage
lookups. This brings over an equivalent version of the function.
  • Loading branch information
chipx86 committed Mar 17, 2014
1 parent 57db3b7 commit 465dbb4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
23 changes: 21 additions & 2 deletions djblets/extensions/staticfiles.py
Expand Up @@ -137,15 +137,34 @@ def find_storage(self, name):
files = finder.list([])

for path, storage in files:
prefix = getattr(storage, 'prefix', None)
matched_path = self.match_location(name, path, prefix)
matched_path = self._match_location(
name,
path,
getattr(storage, 'prefix', None))

if matched_path:
return matched_path, storage

raise ValueError("The file '%s' could not be found with %r."
% (name, self))

def _match_location(self, name, path, prefix=None):
if prefix:
if prefix != name[:len(prefix)]:
return None

prefix = '%s%s' % (prefix, os.sep)
name = name[len(prefix):]

norm_path = os.path.normpath(path)
norm_name = os.path.normpath(name)

if (norm_path == norm_name or
os.path.splitext(norm_path)[0] == os.path.splitext(norm_name)[0]):
return name

return None


class PackagingFinder(FileSystemFinder):
"""Finds static media files for an extension.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -135,7 +135,7 @@ def run_tests(*args):
cmdclass=cmdclasses,
install_requires=[
'Django>=1.6.2,<1.7',
'django-pipeline>=1.3.15',
'django-pipeline>=1.3.23',
'feedparser>=5.1.2',
'pillowfight',
'pytz',
Expand Down

0 comments on commit 465dbb4

Please sign in to comment.