Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Make some staff

branch: develop

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 dealer
Octocat-spinner-32 docs
Octocat-spinner-32 tests
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 AUTHORS
Octocat-spinner-32 Changelog
Octocat-spinner-32 DESCRIPTION
Octocat-spinner-32 LICENSE
Octocat-spinner-32 MANIFEST.in python3
Octocat-spinner-32 Makefile
Octocat-spinner-32 README.rst
Octocat-spinner-32 pylama.ini
Octocat-spinner-32 requirements.txt
Octocat-spinner-32 setup.py Update tests.
Octocat-spinner-32 tox.ini
README.rst

logo Dealer

Dealer — SCM revision helper in your projects. Just add SCM revision to your static paths and get automatic control at client browser caches:

Somewhere in templates:

<script src='/main.js?{{ request.revision }}'

On clientside:

<script src='/main.js?34jhfd45hd8'

Supported Git, Mercurial and simple revision parse by file.

Note

You should install Mercurial for hg support.

Build Status Coverals Version Downloads Donate

Requirements

  • python (2.6, 2.7, 3.3)

Installation

Dealer should be installed using pip:

pip install dealer

Usage

Basic usage

from dealer.git import git

print git.revision

print git.tag
# Auto parse repository type
from dealer.auto import auto
print auto.revision

print auto.tag

Manually create backend

path — path to SCM repository (current dir by default)

from dealer.mercurial import Backend

hg = Backend('/path/to/hg/repo')

Django support

Settings

DEALER_TYPE — Type of SCM repository ('auto', 'git', 'mercurial', 'simple', 'env', 'null'). By default 'auto';

DEALER_PATH — Path to SCM. By default current dir;

DEALER_SILENT — Disable log warnings;

DEALER_BACKENDS — Backends for auto search by default ('git', 'mercurial', 'simple', 'env', 'null');

Context-processor

Append to your settings:

TEMPLATE_CONTEXT_PROCESSORS += 'dealer.contrib.django.staff.context_processor',

And use the REVISION and TAG variables in your templates:

<link href="/test.css?{{ REVISION }}" rel="stylesheet" type="text/css" media="screen" />
<script src="/test.js?{{ REVISION }}"></script>

Middleware

Append to your settings:

MIDDLEWARE_CLASSES += 'dealer.contrib.django.staff.Middleware',

And use in your views:

def view(request):
    return request.revision

Or in your templates by request.revision var.

Flask support

Settings

DEALER_TYPE — Type of SCM repository ('auto', 'git', 'mercurial', 'simple', 'env', 'null'). By default 'auto' DEALER_PARAMS — Params for backend

Usage

In views:

from flask import Flask, g
from dealer.contrib.flask import Dealer

app = Flask('test')
Dealer(app)
assert app.revision

@app.route('/')
def usage_in_view():
    return g.revision

In templates:

<link href="/test.css?{{ REVISION }}" rel="stylesheet" type="text/css" media="screen" />

Heroku support

Settings

DEALER_TYPE = 'env' DEALER_PARAMS:

System Message: ERROR/3 (<string>, line 184)

Unexpected indentation.
revision_env_keyname - Variable name for revision (default: DEALER_REVISION)
tag_env_keyname - Variable name for tag (default: DEALER_TAG)

Usage

Setup your revision and tag value in envirement variables. For example in Heroku.com:

System Message: ERROR/3 (<string>, line 193)

Unexpected indentation.
heroku config:set DEALER_REVISION='3ffb6b6'
heroku config:set DEALER_TAG=v1_1

After that use dealer as described above.

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/Dealer/issues

Contributing

Development of dealer happens at github: https://github.com/klen/dealer

Contributors

  • klen (Kirill Klenov)

License

Licensed under a BSD license.

Something went wrong with that request. Please try again.