Skip to main content

Dealer -- SCM (Git, Mercurial) watcher

Project description

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.

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
# Auto parse repository type
from dealer.auto import auto
print auto.revision

Manualy 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’, ‘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’, ‘null’);

Context-processor

Append to your settings:

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

And use REVISION variable 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’, ‘silent’). 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" />

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dealer-0.2.2.tar.gz (7.8 kB view details)

Uploaded Source

File details

Details for the file dealer-0.2.2.tar.gz.

File metadata

  • Download URL: dealer-0.2.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dealer-0.2.2.tar.gz
Algorithm Hash digest
SHA256 70e52b2dd9e28f8e56ee3ccd00e662756ee11e72fc2327bf4910ee9b8747101d
MD5 16954cf504bf6bf9f0d3e43064346ed5
BLAKE2b-256 53b3cbdb18a053d8700a6a153d6cba1ec0515004d802a54eac03067031294f77

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page