Skip to content

Commit

Permalink
Merge pull request PaulUithol#4 from areski/master
Browse files Browse the repository at this point in the history
Installer Setup / Readme fixes
  • Loading branch information
PaulUithol committed Oct 18, 2011
2 parents a04f78f + 653d113 commit dea127c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
6 changes: 6 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
global-exclude *.pyc

include README.md

recursive-include admin_tools_stats *
recursive-include backbone_tastypie *
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
A small conversion layer to make [backbone.js](https://github.com/documentcloud/backbone) and [django-tastypie](https://github.com/toastdriven/django-tastypie) work together happily.

## Usage
Add `django_tastypie` to your `INSTALLED_APPS` setting, and add the following to your base template:
Add `backbone_tastypie` to your `INSTALLED_APPS` setting, and add the following to your base template:
`<script type="text/javascript" src="{{ STATIC_URL }}js/backbone-tastypie.js"></script>`

## How it works
Specifically, it overrides `Backbone.sync` to do a GET request after creating an object (if there is no response body), and overrides `Backbone.Model.prototype.idAttribute`, `Backbone.Model.prototype.url`, `Backbone.Model.prototype.parse` and `Backbone.Collection.prototype.parse`.

`Backbone.Collection.prototype.url` is overridden so it can build urls for a set of models when using the `fetchRelated` method in [Backbone-relational](https://github.com/PaulUithol/Backbone-relational/).
`Backbone.Collection.prototype.url` is overridden so it can build urls for a set of models when using the `fetchRelated` method in [Backbone-relational](https://github.com/PaulUithol/Backbone-relational/).
25 changes: 25 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
#!/usr/bin/env python
from distutils.core import setup
import os


# taken from django-registration
# Compile the list of packages available, because distutils doesn't have
# an easy way to do this.
packages, data_files = [], []
root_dir = os.path.dirname(__file__)
if root_dir:
os.chdir(root_dir)

for dirpath, dirnames, filenames in os.walk('backbone_tastypie'):
# Ignore dirnames that start with '.'
for i, dirname in enumerate(dirnames):
if dirname.startswith('.'): del dirnames[i]
if '__init__.py' in filenames:
pkg = dirpath.replace(os.path.sep, '.')
if os.path.altsep:
pkg = pkg.replace(os.path.altsep, '.')
packages.append(pkg)
elif filenames:
prefix = dirpath[len('backbone_tastypie/'):] # Strip "backbone_tastypie/"
for f in filenames:
data_files.append(os.path.join(prefix, f))
print data_files
setup(
name='Backbone-tastypie',
version='1.0',
Expand All @@ -10,4 +34,5 @@
author_email='paul.uithol@gmail.com',
url='https://github.com/PaulUithol',
packages=['backbone_tastypie'],
package_data={'backbone_tastypie': data_files},
)

0 comments on commit dea127c

Please sign in to comment.