Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-pipeline
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-pipeline
Commits
261107ff
Commit
261107ff
authored
Jul 28, 2011
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a finder based storage
parent
0b06c867
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
2 deletions
+56
-2
docs/storages.rst
+13
-1
pipeline/conf/settings.py
+0
-1
pipeline/storage.py
+43
-0
No files found.
docs/storages.rst
View file @
261107ff
...
...
@@ -21,5 +21,17 @@ Using with staticfiles
Pipeline is providing a Finder for `staticfiles app <https://docs.djangoproject.com/en/dev/howto/static-files/>`_,
to use it configure ``STATICFILES_FINDERS`` like so : ::
STATICFILES_FINDERS = 'pipeline.finders.PipelineFinder'
STATICFILES_FINDERS = (
'pipeline.finders.PipelineFinder',
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder'
)
.. note::
``PipelineFinder`` should be the first finder in ``STATICFILES_FINDERS``.
Pipeline is also providing a storage that play nicely with staticfiles app
particularly for development : ::
PIPELINE_STORAGE = 'pipeline.storage.PipelineFinderStorage'
pipeline/conf/settings.py
View file @
261107ff
...
...
@@ -6,7 +6,6 @@ PIPELINE_ROOT = getattr(settings, 'PIPELINE_ROOT', settings.MEDIA_ROOT)
PIPELINE_URL
=
getattr
(
settings
,
'PIPELINE_URL'
,
settings
.
MEDIA_URL
)
PIPELINE
=
getattr
(
settings
,
'PIPELINE'
,
not
settings
.
DEBUG
)
PIPELINE_SOURCE
=
getattr
(
settings
,
'PIPELINE_SOURCE'
,
settings
.
STATIC_ROOT
)
PIPELINE_ROOT
=
getattr
(
settings
,
'PIPELINE_ROOT'
,
settings
.
STATIC_ROOT
)
PIPELINE_URL
=
getattr
(
settings
,
'PIPELINE_URL'
,
settings
.
STATIC_URL
)
PIPELINE_AUTO
=
getattr
(
settings
,
'PIPELINE_AUTO'
,
True
)
...
...
pipeline/storage.py
View file @
261107ff
import
errno
import
os
from
datetime
import
datetime
from
django.contrib.staticfiles
import
finders
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.files.storage
import
FileSystemStorage
,
get_storage_class
from
django.utils.functional
import
LazyObject
...
...
@@ -25,6 +28,46 @@ class PipelineStorage(FileSystemStorage):
def
modified_time
(
self
,
name
):
return
datetime
.
fromtimestamp
(
os
.
path
.
getmtime
(
self
.
path
(
name
)))
def
_open
(
self
,
name
,
mode
=
'rb'
):
full_path
=
self
.
path
(
name
)
directory
=
os
.
path
.
dirname
(
full_path
)
if
not
os
.
path
.
exists
(
directory
):
try
:
os
.
makedirs
(
directory
)
except
OSError
,
e
:
if
e
.
errno
!=
errno
.
EEXIST
:
raise
if
not
os
.
path
.
isdir
(
directory
):
raise
IOError
(
"
%
s exists and is not a directory."
%
directory
)
return
super
(
PipelineStorage
,
self
)
.
_open
(
name
,
mode
)
class
BaseFinderStorage
(
PipelineStorage
):
finders
=
None
def
__init__
(
self
,
finders
=
None
,
*
args
,
**
kwargs
):
if
finders
is
not
None
:
self
.
finders
=
finders
if
self
.
finders
is
None
:
raise
ImproperlyConfigured
(
"The storage
%
r doesn't have a finders class assigned."
%
self
.
__class__
)
super
(
BaseFinderStorage
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
path
(
self
,
name
):
path
=
self
.
finders
.
find
(
name
)
if
not
path
:
path
=
super
(
BaseFinderStorage
,
self
)
.
path
(
name
)
return
path
def
exists
(
self
,
name
):
exists
=
self
.
finders
.
find
(
name
)
!=
None
if
not
exists
:
exists
=
super
(
BaseFinderStorage
,
self
)
.
exists
(
name
)
return
exists
class
PipelineFinderStorage
(
BaseFinderStorage
):
finders
=
finders
class
DefaultStorage
(
LazyObject
):
def
_setup
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment