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
f03910d8
Commit
f03910d8
authored
Sep 16, 2011
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve syncompress cache busting
parent
c454e619
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
30 deletions
+20
-30
pipeline/management/commands/synccompress.py
+10
-18
pipeline/packager.py
+6
-7
pipeline/signals.py
+2
-3
pipeline/versioning/__init__.py
+2
-2
No files found.
pipeline/management/commands/synccompress.py
View file @
f03910d8
...
...
@@ -8,18 +8,12 @@ class Command(BaseCommand):
make_option
(
'--force'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Force
update of all files, even if the source files are older than the current compressed file
.'
help
=
'Force
compression and/or cache busting
.'
),
make_option
(
'--dry-run'
,
action
=
'store_false'
,
default
=
True
,
help
=
'Don
\'
t attempt to update files.'
),
make_option
(
'--no-cache-bust'
,
dest
=
'bust_cache'
,
action
=
'store_false'
,
default
=
True
,
help
=
'Don
\'
t update version cache.'
help
=
'Don
\'
t attempt to compress package.'
)
)
help
=
'Updates and compresses CSS and JS on-demand'
...
...
@@ -27,32 +21,30 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
from
pipeline.packager
import
Packager
packager
=
Packager
(
force
=
options
.
get
(
'force'
,
False
),
verbose
=
int
(
options
.
get
(
'verbosity'
,
1
))
>=
2
)
force
=
options
.
get
(
'force'
,
False
)
verbose
=
int
(
options
.
get
(
'verbosity'
,
1
))
>=
2
sync
=
options
.
get
(
'dry_run'
,
True
)
bust_cache
=
options
.
get
(
'bust_cache'
,
True
)
packager
=
Packager
(
verbose
=
verbose
)
for
package_name
in
packager
.
packages
[
'css'
]:
if
args
and
package_name
not
in
args
:
continue
package
=
packager
.
package_for
(
'css'
,
package_name
)
if
packager
.
verbose
or
packager
.
forc
e
:
if
verbos
e
:
print
message
=
"CSS Group '
%
s'"
%
package_name
print
message
print
len
(
message
)
*
'-'
packager
.
pack_stylesheets
(
package
,
sync
=
sync
,
bust_cache
=
bust_cach
e
)
packager
.
pack_stylesheets
(
package
,
sync
=
sync
,
force
=
forc
e
)
for
package_name
in
packager
.
packages
[
'js'
]:
if
args
and
package_name
not
in
args
:
continue
package
=
packager
.
package_for
(
'js'
,
package_name
)
if
packager
.
verbose
or
packager
.
forc
e
:
if
verbos
e
:
print
message
=
"JS Group '
%
s'"
%
package_name
print
message
print
len
(
message
)
*
'-'
packager
.
pack_javascripts
(
package
,
sync
=
sync
,
bust_cache
=
bust_cach
e
)
packager
.
pack_javascripts
(
package
,
sync
=
sync
,
force
=
forc
e
)
pipeline/packager.py
View file @
f03910d8
...
...
@@ -13,8 +13,7 @@ from pipeline.versioning import Versioning
class
Packager
(
object
):
def
__init__
(
self
,
force
=
False
,
verbose
=
False
,
css_packages
=
None
,
js_packages
=
None
):
self
.
force
=
force
def
__init__
(
self
,
verbose
=
False
,
css_packages
=
None
,
js_packages
=
None
):
self
.
verbose
=
verbose
self
.
compressor
=
Compressor
(
verbose
)
self
.
versioning
=
Versioning
(
verbose
)
...
...
@@ -50,17 +49,17 @@ class Packager(object):
def
compile
(
self
,
paths
):
return
self
.
compiler
.
compile
(
paths
)
def
pack
(
self
,
package
,
compress
,
signal
,
sync
=
False
,
**
kwargs
):
if
settings
.
PIPELINE_AUTO
or
self
.
force
or
sync
:
def
pack
(
self
,
package
,
compress
,
signal
,
sync
=
False
,
force
=
False
,
**
kwargs
):
if
settings
.
PIPELINE_AUTO
or
(
force
and
sync
)
:
need_update
,
version
=
self
.
versioning
.
need_update
(
package
[
'output'
],
package
[
'paths'
])
if
need_update
or
self
.
force
:
if
need_update
or
force
:
output_filename
=
self
.
versioning
.
output_filename
(
package
[
'output'
],
version
)
self
.
versioning
.
cleanup
(
package
[
'output'
])
if
self
.
verbose
or
self
.
force
:
if
self
.
verbose
:
print
"Version:
%
s"
%
version
print
"Saving:
%
s"
%
output_filename
paths
=
self
.
compile
(
package
[
'paths'
])
...
...
@@ -69,7 +68,7 @@ class Packager(object):
self
.
save_file
(
output_filename
,
content
)
else
:
filename_base
,
filename
=
os
.
path
.
split
(
package
[
'output'
])
version
=
self
.
versioning
.
version_from_file
(
filename_base
,
filename
)
version
=
self
.
versioning
.
version_from_file
(
filename_base
,
filename
,
force
=
force
)
signal
.
send
(
sender
=
self
,
package
=
package
,
version
=
version
,
**
kwargs
)
return
self
.
versioning
.
output_filename
(
package
[
'output'
],
version
)
...
...
pipeline/signals.py
View file @
f03910d8
...
...
@@ -12,8 +12,7 @@ js_compressed = Signal(providing_args=["package", "version"])
@receiver
(
css_compressed
)
@receiver
(
js_compressed
)
def
invalidate_cache
(
sender
,
package
,
version
,
bust_cache
=
False
,
**
kwargs
):
def
invalidate_cache
(
sender
,
package
,
version
,
**
kwargs
):
filename_base
,
filename
=
os
.
path
.
split
(
package
[
'output'
])
if
bust_cache
:
cache
.
set
(
"pipeline:
%
s"
%
filename
,
str
(
version
),
cache
.
set
(
"pipeline:
%
s"
%
filename
,
str
(
version
),
settings
.
PIPELINE_CACHE_TIMEOUT
)
pipeline/versioning/__init__.py
View file @
f03910d8
...
...
@@ -19,9 +19,9 @@ class Versioning(object):
def
version
(
self
,
paths
):
return
getattr
(
self
.
versioner
,
'version'
)(
paths
)
def
version_from_file
(
self
,
path
,
filename
):
def
version_from_file
(
self
,
path
,
filename
,
force
=
False
):
version
=
cache
.
get
(
"pipeline:
%
s"
%
filename
)
if
not
version
:
if
(
not
version
)
or
force
:
filename
=
settings
.
PIPELINE_VERSION_PLACEHOLDER
.
join
([
re
.
escape
(
part
)
for
part
in
filename
.
split
(
settings
.
PIPELINE_VERSION_PLACEHOLDER
)])
regex
=
re
.
compile
(
r'^
%
s$'
%
self
.
output_filename
(
filename
,
r'([A-Za-z0-9]+)'
))
...
...
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