[Python-modules-commits] [django-guardian] 01/13: import django-guardian_1.2.4+git20141127.orig.tar.gz
Brian May
bam at moszumanska.debian.org
Tue Nov 3 10:01:59 UTC 2015
This is an automated email from the git hooks/post-receive script.
bam pushed a commit to branch master
in repository django-guardian.
commit f5c84736db787d36525136be260882cd076dbba6
Author: Brian May <brian at linuxpenguins.xyz>
Date: Tue Nov 3 19:44:02 2015 +1100
import django-guardian_1.2.4+git20141127.orig.tar.gz
---
.gitignore | 25 +
.travis.yml | 41 ++
AUTHORS | 52 ++
CHANGES | 238 ++++++
LICENSE | 24 +
MANIFEST.in | 16 +
README.rst | 106 +++
benchmarks/__init__.py | 0
benchmarks/models.py | 21 +
benchmarks/run_benchmarks.py | 168 +++++
benchmarks/settings.py | 35 +
docs/Makefile | 96 +++
docs/api/guardian.admin.rst | 16 +
docs/api/guardian.backends.rst | 14 +
docs/api/guardian.core.rst | 14 +
docs/api/guardian.decorators.rst | 23 +
docs/api/guardian.forms.rst | 36 +
docs/api/guardian.management.commands.rst | 9 +
docs/api/guardian.managers.rst | 24 +
docs/api/guardian.mixins.rst | 28 +
docs/api/guardian.models.rst | 34 +
docs/api/guardian.shortcuts.rst | 67 ++
docs/api/guardian.templatetags.guardian_tags.rst | 13 +
docs/api/guardian.utils.rst | 25 +
docs/api/index.rst | 22 +
docs/conf.py | 220 ++++++
docs/configuration.rst | 129 ++++
docs/develop/changes.rst | 7 +
docs/develop/example_project.rst | 28 +
docs/develop/index.rst | 13 +
docs/develop/overview.rst | 76 ++
docs/develop/supported-versions.rst | 24 +
docs/develop/testing.rst | 117 +++
docs/exts.py | 43 ++
docs/index.rst | 33 +
docs/installation.rst | 25 +
docs/license.rst | 7 +
docs/make.bat | 121 ++++
docs/overview.rst | 46 ++
docs/theme/rtd_theme/breadcrumbs.html | 11 +
docs/theme/rtd_theme/footer.html | 16 +
docs/theme/rtd_theme/layout.html | 137 ++++
docs/theme/rtd_theme/layout_old.html | 205 ++++++
docs/theme/rtd_theme/sass/_badge.sass | 84 +++
.../rtd_theme/sass/_badge_font_awesome_mini.sass | 53 ++
docs/theme/rtd_theme/sass/_breadcrumbs.sass | 25 +
docs/theme/rtd_theme/sass/_nav.sass | 260 +++++++
docs/theme/rtd_theme/sass/badge_only.sass | 9 +
docs/theme/rtd_theme/sass/config.rb | 38 +
docs/theme/rtd_theme/sass/theme.sass | 57 ++
docs/theme/rtd_theme/search.html | 50 ++
docs/theme/rtd_theme/searchbox.html | 5 +
docs/theme/rtd_theme/static/badge_only.css | 1 +
.../rtd_theme/static/font/fontawesome_webfont.eot | Bin 0 -> 37405 bytes
.../rtd_theme/static/font/fontawesome_webfont.svg | 399 +++++++++++
.../rtd_theme/static/font/fontawesome_webfont.ttf | Bin 0 -> 79076 bytes
.../rtd_theme/static/font/fontawesome_webfont.woff | Bin 0 -> 43572 bytes
docs/theme/rtd_theme/static/theme.css | 1 +
docs/theme/rtd_theme/static/theme.js | 16 +
docs/theme/rtd_theme/theme.conf | 7 +
docs/theme/rtd_theme/versions.html | 38 +
docs/userguide/admin-integration.rst | 94 +++
docs/userguide/assign.rst | 106 +++
docs/userguide/caveats.rst | 79 ++
docs/userguide/check.rst | 181 +++++
docs/userguide/custom-user-model.rst | 71 ++
docs/userguide/index.rst | 16 +
docs/userguide/performance.rst | 111 +++
docs/userguide/remove.rst | 26 +
docs/watch-docs.sh | 15 +
example_project/__init__.py | 0
example_project/context_processors.py | 5 +
example_project/core/__init__.py | 0
example_project/core/models.py | 22 +
example_project/integration_tests/__init__.py | 0
example_project/integration_tests/models.py | 0
example_project/integration_tests/tests.py | 17 +
example_project/manage.py | 17 +
example_project/posts/__init__.py | 0
example_project/posts/admin.py | 16 +
example_project/posts/models.py | 22 +
.../posts/templates/posts/post_detail.html | 41 ++
.../posts/templates/posts/post_list.html | 36 +
example_project/posts/urls.py | 8 +
example_project/posts/views.py | 29 +
example_project/requirements.txt | 3 +
example_project/settings.py | 132 ++++
example_project/static/css/bootstrap.min.css | 9 +
.../static/img/glyphicons-halflings-white.png | Bin 0 -> 8777 bytes
.../static/img/glyphicons-halflings.png | Bin 0 -> 12799 bytes
example_project/static/js/bootstrap.min.js | 6 +
example_project/templates/403.html | 17 +
example_project/templates/404.html | 18 +
example_project/templates/500.html | 16 +
example_project/templates/base.html | 58 ++
example_project/templates/home.html | 15 +
example_project/urls.py | 25 +
extras.py | 86 +++
guardian/__init__.py | 31 +
guardian/admin.py | 446 ++++++++++++
guardian/apps.py | 13 +
guardian/backends.py | 65 ++
guardian/compat.py | 131 ++++
guardian/conf/__init__.py | 2 +
guardian/conf/settings.py | 29 +
guardian/core.py | 125 ++++
guardian/decorators.py | 138 ++++
guardian/exceptions.py | 22 +
guardian/forms.py | 194 +++++
guardian/locale/es/LC_MESSAGES/django.mo | Bin 0 -> 1688 bytes
guardian/locale/es/LC_MESSAGES/django.po | 159 ++++
guardian/locale/fr/LC_MESSAGES/django.mo | Bin 0 -> 1811 bytes
guardian/locale/fr/LC_MESSAGES/django.po | 156 ++++
guardian/locale/pl/LC_MESSAGES/django.mo | Bin 0 -> 1703 bytes
guardian/locale/pl/LC_MESSAGES/django.po | 157 ++++
guardian/locale/pt_BR/LC_MESSAGES/django.mo | Bin 0 -> 1792 bytes
guardian/locale/pt_BR/LC_MESSAGES/django.po | 159 ++++
guardian/management/__init__.py | 48 ++
guardian/management/commands/__init__.py | 2 +
.../management/commands/clean_orphan_obj_perms.py | 25 +
guardian/managers.py | 116 +++
guardian/migrations/0001_initial.py | 112 +++
...tpermission_object_pk__add_field_userobjectp.py | 85 +++
.../0003_update_objectpermission_object_pk.py | 86 +++
...tpermission_object_id__del_unique_groupobjec.py | 107 +++
...tpermission_object_pk__chg_field_userobjectp.py | 84 +++
guardian/migrations/__init__.py | 0
guardian/mixins.py | 215 ++++++
guardian/models.py | 98 +++
guardian/shortcuts.py | 560 +++++++++++++++
.../admin/guardian/contrib/grappelli/field.html | 23 +
.../contrib/grappelli/obj_perms_manage.html | 141 ++++
.../contrib/grappelli/obj_perms_manage_group.html | 52 ++
.../contrib/grappelli/obj_perms_manage_user.html | 52 ++
.../admin/guardian/model/change_form.html | 7 +
guardian/templates/admin/guardian/model/field.html | 14 +
.../admin/guardian/model/obj_perms_manage.html | 134 ++++
.../guardian/model/obj_perms_manage_group.html | 41 ++
.../guardian/model/obj_perms_manage_user.html | 41 ++
.../admin/guardian/model/obj_perms_no.html | 3 +
.../admin/guardian/model/obj_perms_yes.html | 3 +
guardian/templatetags/__init__.py | 2 +
guardian/templatetags/guardian_tags.py | 134 ++++
guardian/testapp/__init__.py | 2 +
guardian/testapp/migrations/0001_initial.py | 117 +++
.../testapp/migrations/0002_logentrywithgroup.py | 25 +
.../testapp/migrations/0003_auto_20141124_0729.py | 30 +
guardian/testapp/migrations/__init__.py | 0
guardian/testapp/models.py | 73 ++
guardian/testapp/tests/__init__.py | 24 +
guardian/testapp/tests/admin_test.py | 458 ++++++++++++
guardian/testapp/tests/conf.py | 98 +++
guardian/testapp/tests/conf_test.py | 16 +
guardian/testapp/tests/core_test.py | 176 +++++
guardian/testapp/tests/custompkmodel_test.py | 32 +
guardian/testapp/tests/decorators_test.py | 371 ++++++++++
guardian/testapp/tests/direct_rel_test.py | 199 +++++
guardian/testapp/tests/forms_test.py | 31 +
guardian/testapp/tests/management_test.py | 31 +
guardian/testapp/tests/managers_test.py | 21 +
guardian/testapp/tests/mixins_test.py | 157 ++++
guardian/testapp/tests/orphans_test.py | 102 +++
guardian/testapp/tests/other_test.py | 301 ++++++++
guardian/testapp/tests/shortcuts_test.py | 797 +++++++++++++++++++++
guardian/testapp/tests/tags_test.py | 132 ++++
guardian/testapp/tests/templates/404.html | 0
guardian/testapp/tests/templates/500.html | 0
guardian/testapp/tests/templates/blank.html | 1 +
guardian/testapp/tests/templates/dummy403.html | 1 +
guardian/testapp/tests/urls.py | 25 +
guardian/testapp/tests/utils_test.py | 121 ++++
guardian/testsettings.py | 70 ++
guardian/utils.py | 181 +++++
run_test_and_report.sh | 9 +
setup.cfg | 13 +
setup.py | 56 ++
tests.py | 51 ++
tox.ini | 199 +++++
utils.py | 27 +
179 files changed, 12704 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f502980
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,25 @@
+*.pyc
+*.log
+*.egg
+*.egg-info
+*.swp
+*.bak
+*.db
+*.orig
+build
+_build
+dist
+.DS_Store
+.coverage
+.hgignore
+.tox
+.ropeproject
+
+example_project/media
+example_project/conf/*.py
+.idea/
+
+# WebDAV remote filesystem
+.DAV
+.project
+.pydevproject
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..e74e6b4
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,41 @@
+language: python
+python:
+ - 2.6
+ - 2.7
+ - 3.3
+
+env:
+ - DJANGO_VERSION=1.2.7
+ - DJANGO_VERSION=1.3.7
+ - DJANGO_VERSION=1.4.16
+ - DJANGO_VERSION=1.5.11
+ - DJANGO_VERSION=1.6.8
+
+install:
+ - pip install -q mock==0.8 Django==$DJANGO_VERSION coverage coveralls
+ - pip install . --use-mirrors
+
+script:
+ - coverage run --source=guardian setup.py test
+
+after_success:
+ - coverage report --omit "guardian/compat.py,guardian/testsettings.py" -m guardian/*.py
+ - coveralls
+
+notifications:
+ irc: "irc.freenode.net#django-guardian"
+
+
+matrix:
+ exclude:
+ - python: 3.3
+ env: DJANGO_VERSION=1.2.7
+ - python: 3.3
+ env: DJANGO_VERSION=1.3.7
+ - python: 3.3
+ env: DJANGO_VERSION=1.4.16
+ include:
+ - python: 3.3
+ env: DJANGO_VERSION=1.7.1
+ - python: 3.4
+ env: DJANGO_VERSION=1.7.1
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..57da6ac
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,52 @@
+Authors ordered by first contribution
+
+- Lukasz Balcerzak <lukaszbalcerzak at gmail.com>
+- Cesar Canassa <cesar.canassa at gmail.com>
+- Vincent Driessen <vincent at datafox.nl>
+- John Hensley <john at fairviewcomputing.com>
+- Ramanan Sivaranjan <ramanan at funkaoshi.com>
+- Woosuk Suh <pipoket88 at gmail.com>
+- Bojan Mihelac <bmihelac at mihelac.org>
+- Rafael Ponieman <rafadev at gmail.com>
+- Daniel Sokolowski <daniel.sokolowski at danols.com>
+- Ali Lozano <alilozanoc at gmail.com>
+- BJ Dierkes <derks at bjdierkes.com>
+- Rach Belaid <rachid.belaid at gmail.com>
+- Michael Crosby <crosby.michael at gmail.com>
+- Greg Hinch <greg at greghinch.com>
+- Aram Dulyan <aram at dulyan.com>
+- Florian Hahn <flo at fhahn.com>
+- Piotr Kilczuk <piotr at tymaszweb.pl>
+- Reavis Sutphin-Gray <reavis at sutphin-gray.com>
+- Adrián López <adrianlopezcalvo at hotmail.com>
+- Jameel Al-Aziz <me at jalaziz.net>
+- John P. Neumann <arrantsquid at gmail.com>
+- Andreas Madsack <andreas at madflex.de>
+- Ivan Kharlamov <the.paper.men at gmail.com>
+- Miguel de Val-Borro <miguel.deval at gmail.com>
+- Jan Nakladal <mojeto1 at gmail.com>
+- Yonel Ceruto <yceruto at abalt.org>
+- Luke Faraone <lfaraone at humbughq.com>
+- John Wegis <john at presencelearning.com>
+- Florentin Sardan <florentin.sardan at gmail.com>
+- Geoff Greer <geoff at greer.fm>
+- Hans Larsen <hans at hansl.ca>
+- Fabio C. Barrionuevo da Luz <bnafta at gmail.com> @luzfcb
+- Tomasz Wsuł <2nickers at gmail.com>
+- Xavier Ordoquy <xordoquy at linovia.com>
+- Joshua Bonnett <joshua.bonnett at gmail.com>
+- Jernej Kos <jernej at kos.mx>
+- Bruno Ribeiro da Silva <bruno at e3c.com.br>
+- Cezar Jenkins <emperorcezar at gmail.com>
+- Warren Volz <warren at warrenvolz.com>
+- Omer Katz <omer.drow at gmail.com>
+- Vishal Lal <vish61 at gmail.com>
+- Steven DeMartini <sjd at yelp.com>
+- zauddelig <zauddelig at gmail.com>
+- Remco Wendt <remco.wendt at gmail.com>
+- Kevin London <kevinlondon at gmail.com>
+- Kouhei Maeda <mkouhei at gmail.com>
+- Samuel Sutch <sam at sutch.net>
+- Morgan Aubert <morgan.aubert at zoho.com>
+- Brian May <brian at microcomaustralia.com.au>
+- Troy Grosfield <troy.grosfield at gmail.com>
diff --git a/CHANGES b/CHANGES
new file mode 100644
index 0000000..f99e6db
--- /dev/null
+++ b/CHANGES
@@ -0,0 +1,238 @@
+Release DEV
+===========
+
+* Official Django 1.7 support (thanks Troy Grosfield and Brian May)
+* Allow to override ``PermissionRequiredMixin.get_permission_object``, part
+ of ``PermissionRequiredMixin.check_permissions`` method, responsible for
+ retrieving single object (Thanks zauddelig)
+* French translations (Thanks Morgan Aubert)
+
+Release 1.2.4 (Jul 14, 2014)
+============================
+
+* Fixed another issue with custom primary keys at admin extensions (Thanks Omer
+ Katz)
+
+
+Release 1.2.3 (Jul 14, 2014)
+============================
+
+Unfortunately this was broken release not including any important changes.
+
+
+Release 1.2.2 (Jul 2, 2014)
+===========================
+
+* Fixed issue with custom primary keys at admin extensions (Thanks Omer Katz)
+* ``get_403_or_None`` now accepts Python path to the view function, for example
+ ``'django.contrib.auth.views.login'`` (Thanks Warren Volz)
+* Added ``with_superuser`` flag to ``guardian.shortcuts.get_objects_for_user``
+ (Thanks Bruno Ribeiro da Silva)
+* Added possibility to disable monkey patching of the ``User`` model.
+ (Thanks Cezar Jenkins)
+
+
+Release 1.2 (Mar 7, 2014)
+=========================
+
+* Removed ``get_for_object`` methods from managers (#188)
+* Extended documentation
+* GuardedModelAdmin has been splitted into mixins
+* Faster queries in get_objects_for_user when use_groups=False or any_perm=True
+ (#148)
+* Improved speed of get_objects_for_user shortcut
+* Support for custom User model with not default username field
+* Added GUARDIAN_GET_INIT_ANONYMOUS_USER setting (#179)
+* Added ``accept_global_perms`` to ``PermissionRequiredMixin``
+* Added brazilian portuguese translations
+* Added polish translations
+* Added ``wheel`` support
+* Fixed wrong anonymous user checks
+* Support for Django 1.6
+* Support for Django 1.7 alpha
+
+.. important::
+ In this release we have removed undocumented ``get_for_object`` method
+ from both ``UserObjectPermissionManager`` and
+ ``GroupObjectPermissionManager``. Not deprecated, removed. Those methods
+ were not used within ``django-guardian`` and their odd names could lead to
+ issues if user would believe they would return object level permissions
+ associated with user/group and object passed as the input. If you depend
+ on those methods, you'd need to stick with version 1.1 and make sure you
+ do not misuse them.
+
+
+Release 1.1 (May 26, 2013)
+==========================
+
+* Support for Django 1.5 (including Python 3 combination)
+* Support for custom user models (introduced by Django 1.5)
+* Ability to create permissions using Foreign Keys
+* Added ``user_can_access_owned_by_group_objects_only`` option to
+ ``GuardedModelAdmin.``
+* Minor documentation fixups
+* Spanish translations
+* Better support for grappelli_
+* Updated examples project
+* Speed up ``get_perms`` shortcut function
+
+
+Release 1.0.4 (Jul 15, 2012)
+============================
+
+* Added ``GUARDIAN_RENDER_403`` and ``GUARDIAN_RAISE_403`` settings (#40)
+* Updated docstring for ``get_obj_perms`` (#43)
+* Updated codes to run with newest django-grappelli (#51)
+* Fixed problem with building a RPM package (#50)
+* Updated caveats docs related with oprhaned object permissions (#47)
+* Updated ``permission_required`` docstring (#49)
+* Added ``accept_global_perms`` for decorators (#49)
+* Fixed problem with MySQL and booleans (#56)
+* Added flag to check for *any* permission in ``get_objects_for_user`` and
+ ``get_objects_for_group`` (#65)
+* Added missing *tag closing* at template (#63)
+* Added view mixins related with authorization and authentication (#73)
+* Added tox_ support
+* Added Travis_ support
+
+
+Release 1.0.3 (Jul 25, 2011)
+============================
+
+* Added ``get_objects_for_group`` shortcut (thanks to Rafael Ponieman)
+* Added ``user_can_access_owned_objects_only`` flag to ``GuardedModelAdmin``
+* Updated and fixed issues with example app (thanks to Bojan Mihelac)
+* Minor typo fixed at documentation
+* Included ADC theme for documentation
+
+Release 1.0.2 (Apr 12, 2011)
+============================
+
+* ``get_users_with_perms`` now accepts ``with_group_users`` flag
+* Fixed ``group_id`` issue at admin templates
+* Small fix for documentation building process
+* It's 2011 (updated dates within this file)
+
+
+Release 1.0.1 (Mar 25, 2011)
+============================
+
+* ``get_users_with_perms`` now accepts ``with_superusers`` flag
+* Small fix for documentation building process
+
+
+Release 1.0.0 (Jan 27, 2011)
+============================
+
+* A final v1.0 release!
+
+
+Release 1.0.0.beta2 (Jan 14, 2011)
+==================================
+
+* Added ``get_objects_for_user`` shortcut function
+* Added few tests
+* Fixed issues related with ``django.contrib.auth`` tests
+* Removed example project from source distribution
+
+
+Release 1.0.0.beta1 (Jan 11, 2011)
+==================================
+
+* Simplified example project
+* Fixed issues related with test suite
+* Added ability to clear orphaned object permissions
+* Added ``clean_orphan_obj_perms`` management command
+* Documentation cleanup
+* Added grappelli_ admin templates
+
+
+Release 1.0.0.alpha2 (Dec 2, 2010)
+==================================
+
+* Added possibility to operate with global permissions for assign and
+ ``remove_perm`` shortcut functions
+* Added possibility to generate PDF documentation
+* Fixed some tests
+
+
+Release 1.0.0.alpha1 (Nov 23, 2010)
+===================================
+
+* Fixed admin templates not included in ``MANIFEST.in``
+* Fixed admin integration codes
+
+
+Release 1.0.0.pre (Nov 23, 2010)
+================================
+
+* Added admin integration
+* Added reusable forms for object permissions management
+
+
+Release 0.2.3 (Nov 17, 2010)
+============================
+
+* Added ``guardian.shortcuts.get_users_with_perms`` function
+* Added ``AUTHORS`` file
+
+
+Release 0.2.2 (Oct 19, 2010)
+============================
+
+* Fixed migrations order (thanks to Daniel Rech)
+
+
+Release 0.2.1 (Oct 3, 2010)
+===========================
+
+* Fixed migration (it wasn't actually updating object_pk field)
+
+
+Release 0.2.0 (Oct 3, 2010)
+===========================
+
+Fixes
+~~~~~
+
+* #4: guardian now supports models with not-integer primary keys and
+ they don't need to be called "id".
+
+ .. important::
+ For 0.1.X users: it is required to *migrate* guardian in your projects.
+ Add ``south`` to ``INSTALLED_APPS`` and run::
+
+ python manage.py syncdb
+ python manage.py migrate guardian 0001 --fake
+ python manage.py migrate guardian
+
+Improvements
+~~~~~~~~~~~~
+
+* Added South_ migrations support
+
+
+Release 0.1.1 (Sep 27, 2010)
+============================
+
+Improvements
+~~~~~~~~~~~~
+
+* Added view decorators: ``permission_required`` and
+ ``permission_required_403``
+
+
+Release 0.1.0 (Jun 6, 2010)
+===========================
+
+* Initial public release
+
+
+.. _south: http://south.aeracode.org/
+.. _grappelli: https://github.com/sehmaschine/django-grappelli
+.. _tox: http://tox.testrun.org/
+.. _travis: http://travis-ci.org/
+
+
+.. vim: ft=rst
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..bc92662
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+Copyright (c) 2010-2014 Lukasz Balcerzak <lukaszbalcerzak at gmail.com>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..92df0a6
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,16 @@
+include CHANGES
+include LICENSE
+include README.rst
+include MANIFEST.in
+include extras.py
+include tests.py
+include run_test_and_report.sh
+recursive-include guardian *.py
+recursive-include guardian/locale *.po *.mo
+recursive-include guardian/fixtures *.json
+recursive-include guardian/templates *.html
+recursive-include guardian/tests/templates *.html
+recursive-include docs *
+recursive-exclude example_project *
+recursive-exclude docs/build *
+recursive-exclude benchmarks *
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..1c86c4c
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,106 @@
+===============
+django-guardian
+===============
+
+.. image:: https://secure.travis-ci.org/lukaszb/django-guardian.png?branch=master
+ :target: http://travis-ci.org/lukaszb/django-guardian
+
+.. image:: https://coveralls.io/repos/lukaszb/django-guardian/badge.png?branch=master
+ :target: https://coveralls.io/r/lukaszb/django-guardian/
+
+.. image:: https://pypip.in/v/django-guardian/badge.png
+ :target: https://crate.io/packages/django-guardian/
+
+.. image:: https://pypip.in/d/django-guardian/badge.png
+ :target: https://crate.io/packages/django-guardian/
+
+
+``django-guardian`` is implementation of per object permissions [1]_ as
+authorization backend which is supported since Django_ 1.2. It won't
+work with older Django_ releases.
+
+Documentation
+-------------
+
+Online documentation is available at http://django-guardian.rtfd.org/.
+
+Installation
+------------
+
+To install ``django-guardian`` simply run::
+
+ pip install django-guardian
+
+Configuration
+-------------
+
+We need to hook ``django-guardian`` into our project.
+
+1. Put ``guardian`` into your ``INSTALLED_APPS`` at settings module::
+
+ INSTALLED_APPS = (
+ ...
+ 'guardian',
+ )
+
+2. Add extra authorization backend::
+
+ AUTHENTICATION_BACKENDS = (
+ 'django.contrib.auth.backends.ModelBackend', # default
+ 'guardian.backends.ObjectPermissionBackend',
+ )
+
+3. Configure anonymous user ID ::
+
+ ANONYMOUS_USER_ID = -1
+
+
+Usage
+-----
+
+After installation and project hooks we can finally use object permissions
+with Django_.
+
+Lets start really quickly::
+
+ >>> jack = User.objects.create_user('jack', 'jack at example.com', 'topsecretagentjack')
+ >>> admins = Group.objects.create(name='admins')
+ >>> jack.has_perm('change_group', admins)
+ False
+ >>> UserObjectPermission.objects.assign_perm('change_group', user=jack, obj=admins)
+ <UserObjectPermission: admins | jack | change_group>
+ >>> jack.has_perm('change_group', admins)
+ True
+
+Of course our agent jack here would not be able to *change_group* globally::
+
+ >>> jack.has_perm('change_group')
+ False
+
+Admin integration
+-----------------
+
+Replace ``admin.ModelAdmin`` with ``GuardedModelAdmin`` for those models
+which should have object permissions support within admin panel.
+
+For example::
+
+ from django.contrib import admin
+ from myapp.models import Author
+ from guardian.admin import GuardedModelAdmin
+
+ # Old way:
+ #class AuthorAdmin(admin.ModelAdmin):
+ # pass
+
+ # With object permissions support
+ class AuthorAdmin(GuardedModelAdmin):
+ pass
+
+ admin.site.register(Author, AuthorAdmin)
+
+
+.. [1] Great paper about this feature is available at `djangoadvent articles <https://github.com/djangoadvent/djangoadvent-articles/blob/master/1.2/06_object-permissions.rst>`_.
+
+.. _Django: http://www.djangoproject.com/
+
diff --git a/benchmarks/__init__.py b/benchmarks/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/benchmarks/models.py b/benchmarks/models.py
new file mode 100644
index 0000000..c825082
--- /dev/null
+++ b/benchmarks/models.py
@@ -0,0 +1,21 @@
+from django.db import models
+from guardian.models import UserObjectPermissionBase
+from guardian.models import GroupObjectPermissionBase
+
+
+class TestModel(models.Model):
+ name = models.CharField(max_length=128)
+
+
+
+class DirectUser(UserObjectPermissionBase):
+ content_object = models.ForeignKey('TestDirectModel')
+
+
+class DirectGroup(GroupObjectPermissionBase):
+ content_object = models.ForeignKey('TestDirectModel')
+
+
+class TestDirectModel(models.Model):
+ name = models.CharField(max_length=128)
+
diff --git a/benchmarks/run_benchmarks.py b/benchmarks/run_benchmarks.py
new file mode 100644
index 0000000..7dc984d
--- /dev/null
+++ b/benchmarks/run_benchmarks.py
@@ -0,0 +1,168 @@
+#!/usr/bin/env python
+"""
+This benchmark package should be treated as work-in-progress, not a production
+ready benchmarking solution for django-guardian.
+"""
+import datetime
+import os
+import random
+import string
+import sys
+
+abspath = lambda *p: os.path.abspath(os.path.join(*p))
+
+THIS_DIR = abspath(os.path.dirname(__file__))
+ROOT_DIR = abspath(THIS_DIR, '..')
+
+# so the preferred guardian module is one within this repo and
+# not system-wide
+sys.path.insert(0, ROOT_DIR)
+
+os.environ["DJANGO_SETTINGS_MODULE"] = 'benchmarks.settings'
+from benchmarks import settings
+from guardian.shortcuts import assign_perm
+
+settings.DJALOG_LEVEL = 40
+settings.INSTALLED_APPS = (
+ 'django.contrib.auth',
+ 'django.contrib.sessions',
+ 'django.contrib.contenttypes',
+ 'django.contrib.admin',
+ 'django.contrib.sites',
+ 'guardian',
+ 'benchmarks',
+)
+
+from utils import show_settings
+from django.contrib.auth.models import User, Group
+from django.utils.termcolors import colorize
+from benchmarks.models import TestModel
+from benchmarks.models import TestDirectModel
+
+USERS_COUNT = 50
+OBJECTS_COUNT = 1000
+OBJECTS_WIHT_PERMS_COUNT = 1000
+
+def random_string(length=25, chars=string.ascii_letters+string.digits):
+ return ''.join(random.choice(chars) for i in range(length))
+
+
+class Call(object):
+ def __init__(self, args, kwargs, start=None, finish=None):
+ self.args = args
+ self.kwargs = kwargs
+ self.start = start
+ self.finish = finish
+
+ def delta(self):
+ return self.finish - self.start
+
+
+class Timed(object):
+
+ def __init__(self, action=None):
+ self.action = action
+
+ def __call__(self, func):
+
+ if not hasattr(func, 'calls'):
+ func.calls = []
+
+ def wrapper(*args, **kwargs):
+ if self.action:
+ print(" -> [%s]" % self.action)
+ start = datetime.datetime.now()
+ call = Call(list(args), dict(kwargs), start)
+ try:
+ return func(*args, **kwargs)
+ finally:
+ call.finish = datetime.datetime.now()
+ func.calls.append(call)
+ if self.action:
+ print(" -> [%s] Done (Total time: %s)" % (self.action,
+ call.delta()))
+ return wrapper
+
+
+class Benchmark(object):
+
+ def __init__(self, name, users_count, objects_count,
+ objects_with_perms_count, model):
+ self.name = name
+ self.users_count = users_count
+ self.objects_count = objects_count
+ self.objects_with_perms_count = objects_with_perms_count
+
+ self.Model = model
+ self.perm = 'auth.change_%s' % model._meta.module_name
+
+ def info(self, msg):
+ print(colorize(msg + '\n', fg='green'))
+
+ def prepare_db(self):
+ from django.core.management import call_command
+ call_command('syncdb', interactive=False)
+
+ for model in [User, Group, self.Model]:
+ model.objects.all().delete()
+
+ @Timed("Creating users")
+ def create_users(self):
+ User.objects.bulk_create(User(id=x, username=random_string().capitalize())
+ for x in range(self.users_count))
+
+ @Timed("Creating objects")
+ def create_objects(self):
+ Model = self.Model
+ Model.objects.bulk_create(Model(id=x, name=random_string(20))
+ for x in range(self.objects_count))
+
+ @Timed("Grant permissions")
+ def grant_perms(self):
+ ids = range(1, self.objects_count)
+ for user in User.objects.iterator():
+ for x in xrange(self.objects_with_perms_count):
+ obj = self.Model.objects.get(id=random.choice(ids))
+ self.grant_perm(user, obj, self.perm)
+
+ def grant_perm(self, user, obj, perm):
+ assign_perm(perm, user, obj)
+
+ @Timed("Check permissions")
+ def check_perms(self):
+ ids = range(1, self.objects_count)
+ for user in User.objects.iterator():
+ for x in xrange(self.objects_with_perms_count):
+ obj = self.Model.objects.get(id=random.choice(ids))
+ self.check_perm(user, obj, self.perm)
+
+ def check_perm(self, user, obj, perm):
+ user.has_perm(perm, obj)
+
+ @Timed("Benchmark")
+ def main(self):
+ self.info('=' * 80)
+ self.info(self.name.center(80))
+ self.info('=' * 80)
+ self.prepare_db()
+ self.create_users()
+ self.create_objects()
+ self.grant_perms()
+ self.check_perms()
+
+
+def main():
+ show_settings(settings, 'benchmarks')
+ benchmark = Benchmark('Direct relations benchmark',
+ USERS_COUNT, OBJECTS_COUNT, OBJECTS_WIHT_PERMS_COUNT, TestDirectModel)
+ benchmark.main()
+
+ benchmark = Benchmark('Generic relations benchmark',
+ USERS_COUNT, OBJECTS_COUNT, OBJECTS_WIHT_PERMS_COUNT, TestModel)
+ benchmark.main()
+
+if __name__ == '__main__':
+ main()
+
+
+
diff --git a/benchmarks/settings.py b/benchmarks/settings.py
new file mode 100644
index 0000000..c5f2dad
--- /dev/null
+++ b/benchmarks/settings.py
@@ -0,0 +1,35 @@
+import os
+import sys
+
+abspath = lambda *p: os.path.abspath(os.path.join(*p))
+
+THIS_DIR = abspath(os.path.dirname(__file__))
+ROOT_DIR = abspath(THIS_DIR, '..')
+
+# so the preferred guardian module is one within this repo and
+# not system-wide
+sys.path.insert(0, ROOT_DIR)
+
+
+INSTALLED_APPS = (
+ 'django.contrib.auth',
+ 'django.contrib.sessions',
+ 'django.contrib.contenttypes',
+ 'django.contrib.admin',
+ 'django.contrib.sites',
+ 'guardian',
+ 'benchmarks',
+)
+
+
+ANONYMOUS_USER_ID = -1
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
+ 'NAME': 'guardian_benchmarks',
+ 'USER': 'guardian_bench',
+ 'PASSWORD': 'guardian_bench',
+ },
+}
+
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..06c1e6a
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,96 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
... 12922 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-guardian.git
More information about the Python-modules-commits
mailing list