python-repoze.what-plugins-20090531/0000755000175000017500000000000011210567253015667 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/0000755000175000017500000000000011153054302022611 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/README.txt0000644000175000017500000000106611140644607024323 0ustar zackzack********************************* The repoze.what Quickstart plugin ********************************* This is an extras plugin for repoze.what. This plugin allows you to take advantage of a rather simple, and usual, authentication and authorization setup, in which the users' data, the groups and the permissions used in the application are all stored in a SQLAlchemy or Elixir-managed database. Put simply, it configures repoze.who and repoze.what in one go so that you can have an authentication and authorization system working quickly -- hence the name. python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze/0000755000175000017500000000000011153054302024115 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze/__init__.py0000644000175000017500000000164711140623132026235 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze/what/0000755000175000017500000000000011153054302025060 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze/what/__init__.py0000644000175000017500000000164611140623132027177 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze/what/plugins/0000755000175000017500000000000011153054302026541 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze/what/plugins/__init__.py0000644000175000017500000000173011140623132030652 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## """Special namespace for repoze.what plugins.""" # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze/what/plugins/quickstart.py0000644000175000017500000002360711147055237031330 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2007, Agendaless Consulting and Contributors. # Copyright (c) 2008, Florent Aide . # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## """ Sample plugins and middleware configuration for :mod:`repoze.who` and :mod:`repoze.what`. """ from repoze.who.plugins.auth_tkt import AuthTktCookiePlugin from repoze.who.plugins.sa import SQLAlchemyAuthenticatorPlugin, \ SQLAlchemyUserMDPlugin from repoze.who.plugins.friendlyform import FriendlyFormPlugin from repoze.what.middleware import setup_auth from repoze.what.plugins.sql import configure_sql_adapters def find_plugin_translations(translations={}): """ Process global translations for :mod:`repoze.who`/:mod:`repoze.what` SQLAlchemy plugins. :param translations: The translation dictionary. :type translations: dict :return: The respective translations for the group and permission adapters, the authenticator and the MD provider. :rtype: dict """ group_adapter = {} permission_adapter = {} authenticator = {} mdprovider = {} if 'validate_password' in translations: authenticator['validate_password'] = translations['validate_password'] if 'user_name' in translations: group_adapter['item_name'] = translations['user_name'] authenticator['user_name'] = translations['user_name'] mdprovider['user_name'] = translations['user_name'] if 'users' in translations: group_adapter['items'] = translations['users'] if 'group_name' in translations: group_adapter['section_name'] = translations['group_name'] permission_adapter['item_name'] = translations['group_name'] if 'groups' in translations: group_adapter['sections'] = translations['groups'] permission_adapter['items'] = translations['groups'] if 'permission_name' in translations: permission_adapter['section_name'] = translations['permission_name'] if 'permissions' in translations: permission_adapter['sections'] = translations['permissions'] final_translations = { 'group_adapter': group_adapter, 'permission_adapter': permission_adapter, 'authenticator': authenticator, 'mdprovider': mdprovider} return final_translations def setup_sql_auth(app, user_class, group_class, permission_class, dbsession, form_plugin=None, form_identifies=True, cookie_secret='secret', cookie_name='authtkt', login_url='/login', login_handler='/login_handler', post_login_url=None, logout_handler='/logout_handler', post_logout_url=None, login_counter_name=None, translations={}, **who_args): """ Configure :mod:`repoze.who` and :mod:`repoze.what` with SQL-only authentication and authorization, respectively. :param app: Your WSGI application. :param user_class: The SQLAlchemy/Elixir class for the users. :param group_class: The SQLAlchemy/Elixir class for the groups. :param permission_class: The SQLAlchemy/Elixir class for the permissions. :param dbsession: The SQLAlchemy/Elixir session. :param form_plugin: The main :mod:`repoze.who` challenger plugin; this is usually a login form. :param form_identifies: Whether the ``form_plugin`` may and should act as an :mod:`repoze.who` identifier. :type form_identifies: bool :param cookie_secret: The "secret" for the AuthTktCookiePlugin. :type cookie_secret: str :param cookie_name: The name for the AuthTktCookiePlugin. :type cookie_name: str :param login_url: The URL where the login form is displayed. :type login_url: str :param login_handler: The URL where the login form is submitted. :type login_handler: str :param post_login_url: The URL/path where users should be redirected to after login. :type post_login_url: str :param logout_handler: The URL where the logout is handled. :type login_handler: str :param post_logout_url: The URL/path where users should be redirected to after logout. :type post_logout_url: str :param login_counter_name: The name of the variable in the query string that represents the login counter; defaults to ``__logins``. :type login_counter_name: str :param translations: The model translations. :type translations: dict :return: The WSGI application with authentication and authorization middleware. It configures :mod:`repoze.who` with the following plugins: * Identifiers: * :class:`repoze.who.plugins.friendlyform.FriendlyFormPlugin` as the first identifier and challenger -- using ``login`` as the URL/path where the login form will be displayed, ``login_handler`` as the URL/path where the form will be sent and ``logout_handler`` as the URL/path where the user will be logged out. The so-called *rememberer* of such an identifier will be the identifier below. If ``post_login_url`` is defined, the user will be redirected to that page after login. Likewise, if ``post_logout_url`` is defined, the user will be redirected to that page after logout. You can override the :class:`repoze.who.plugins.friendlyform.FriendlyFormPlugin`'s login counter variable name (which defaults to ``__logins``) by defining ``login_counter_name``. .. tip:: This plugin may be overridden with the ``form_plugin`` argument. See also the ``form_identifies`` argument. * :class:`repoze.who.plugins.auth_tkt.AuthTktCookiePlugin`. You can customize the cookie name and secret using the ``cookie_name`` and ``cookie_secret`` arguments, respectively. Then it will append the identifiers you pass through the ``identifiers`` keyword argument, if any. * Authenticators: * :class:`repoze.who.plugins.sa.SQLAlchemyAuthenticatorPlugin`, using the ``user_class`` and ``dbsession`` arguments as its user class and DB session, respectively. Then it will append the authenticators you pass through the ``authenticators`` keyword argument, if any. * Challengers: * The same Form-based plugin used in the identifiers. Then it will append the challengers you pass through the ``challengers`` keyword argument, if any. * Metadata providers: * :class:`repoze.who.plugins.sa.SQLAlchemyUserMDPlugin`, using the ``user_class`` and ``dbsession`` arguments as its user class and DB session, respectively. Then it will append the metadata providers you pass through the ``mdproviders`` keyword argument, if any. Additional keyword arguments will be passed to :class:`repoze.who.middleware.PluggableAuthenticationMiddleware`. .. note:: If you don't want to use the groups/permissions-based authorization pattern, then set ``group_class`` and ``permission_class`` to ``None``. """ plugin_translations = find_plugin_translations(translations) if group_class is None or permission_class is None: group_adapters = permission_adapters = None else: source_adapters = configure_sql_adapters( user_class, group_class, permission_class, dbsession, plugin_translations['group_adapter'], plugin_translations['permission_adapter']) group_adapters = {'sql_auth': source_adapters['group']} permission_adapters = {'sql_auth': source_adapters['permission']} # Setting the repoze.who authenticators: sqlauth = SQLAlchemyAuthenticatorPlugin(user_class, dbsession) sqlauth.translations.update(plugin_translations['authenticator']) if 'authenticators' not in who_args: who_args['authenticators'] = [] who_args['authenticators'].append(('sqlauth', sqlauth)) cookie = AuthTktCookiePlugin(cookie_secret, cookie_name) # Setting the repoze.who identifiers if 'identifiers' not in who_args: who_args['identifiers'] = [] who_args['identifiers'].append(('cookie', cookie)) if form_plugin is None: form = FriendlyFormPlugin( login_url, login_handler, post_login_url, logout_handler, post_logout_url, login_counter_name=login_counter_name, rememberer_name='cookie') else: form = form_plugin if form_identifies: who_args['identifiers'].insert(0, ('main_identifier', form)) # Setting the repoze.who challengers: if 'challengers' not in who_args: who_args['challengers'] = [] who_args['challengers'].append(('form', form)) # Setting up the repoze.who mdproviders: sql_user_md = SQLAlchemyUserMDPlugin(user_class, dbsession) sql_user_md.translations.update(plugin_translations['mdprovider']) if 'mdproviders' not in who_args: who_args['mdproviders'] = [] who_args['mdproviders'].append(('sql_user_md', sql_user_md)) middleware = setup_auth(app, group_adapters, permission_adapters, **who_args) return middleware python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/PKG-INFO0000644000175000017500000000270411153054302023711 0ustar zackzackMetadata-Version: 1.0 Name: repoze.what-quickstart Version: 1.0 Summary: The repoze.what Quickstart plugin Home-page: http://code.gustavonarea.net/repoze.what-quickstart/ Author: Gustavo Narea Author-email: repoze-dev@lists.repoze.org License: BSD-derived (http://www.repoze.org/LICENSE.txt) Description: ********************************* The repoze.what Quickstart plugin ********************************* This is an extras plugin for repoze.what. This plugin allows you to take advantage of a rather simple, and usual, authentication and authorization setup, in which the users' data, the groups and the permissions used in the application are all stored in a SQLAlchemy or Elixir-managed database. Put simply, it configures repoze.who and repoze.what in one go so that you can have an authentication and authorization system working quickly -- hence the name. Keywords: web application wsgi server sql sqlalchemy elixir authentication authorization repoze Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Database Classifier: Topic :: Internet :: WWW/HTTP :: WSGI Classifier: Topic :: Security python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/VERSION.txt0000644000175000017500000000000311153053502024471 0ustar zackzack1.0python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/0000755000175000017500000000000011153054302031023 5ustar zackzack././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/requires.txtpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/requi0000644000175000017500000000017111153054302032072 0ustar zackzackrepoze.what >= 1.0.3 repoze.who repoze.who.plugins.sa >= 1.0rc1 repoze.what.plugins.sql >= 1.0rc1 repoze.who-friendlyform././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/namespace_packages.txtpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/names0000644000175000017500000000004711153054302032052 0ustar zackzackrepoze repoze.what repoze.what.plugins ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/dependency_links.txtpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/depen0000644000175000017500000000000111153054302032030 0ustar zackzack ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/PKG-INFOpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/PKG-I0000644000175000017500000000270411153054302031560 0ustar zackzackMetadata-Version: 1.0 Name: repoze.what-quickstart Version: 1.0 Summary: The repoze.what Quickstart plugin Home-page: http://code.gustavonarea.net/repoze.what-quickstart/ Author: Gustavo Narea Author-email: repoze-dev@lists.repoze.org License: BSD-derived (http://www.repoze.org/LICENSE.txt) Description: ********************************* The repoze.what Quickstart plugin ********************************* This is an extras plugin for repoze.what. This plugin allows you to take advantage of a rather simple, and usual, authentication and authorization setup, in which the users' data, the groups and the permissions used in the application are all stored in a SQLAlchemy or Elixir-managed database. Put simply, it configures repoze.who and repoze.what in one go so that you can have an authentication and authorization system working quickly -- hence the name. Keywords: web application wsgi server sql sqlalchemy elixir authentication authorization repoze Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Database Classifier: Topic :: Internet :: WWW/HTTP :: WSGI Classifier: Topic :: Security ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/entry_points.txtpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/entry0000644000175000017500000000000611153054302032103 0ustar zackzack ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/top_level.txtpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/top_l0000644000175000017500000000001511153054302032057 0ustar zackzackrepoze tests ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/not-zip-safepython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/not-z0000644000175000017500000000000111140641236032010 0ustar zackzack ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/SOURCES.txtpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/repoze.what_quickstart.egg-info/SOURC0000644000175000017500000000141011153054302031635 0ustar zackzackMANIFEST.in README.txt VERSION.txt ez_setup.py setup.cfg setup.py docs/Makefile docs/source/News.rst docs/source/conf.py docs/source/index.rst docs/source/_static/logo_hi.gif docs/source/_static/model_elixir_example.py docs/source/_static/model_sa_example.py docs/source/_static/repoze.css repoze/__init__.py repoze.what_quickstart.egg-info/PKG-INFO repoze.what_quickstart.egg-info/SOURCES.txt repoze.what_quickstart.egg-info/dependency_links.txt repoze.what_quickstart.egg-info/entry_points.txt repoze.what_quickstart.egg-info/namespace_packages.txt repoze.what_quickstart.egg-info/not-zip-safe repoze.what_quickstart.egg-info/requires.txt repoze.what_quickstart.egg-info/top_level.txt repoze/what/__init__.py repoze/what/plugins/__init__.py repoze/what/plugins/quickstart.pypython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/ez_setup.py0000644000175000017500000002231311140623133025022 0ustar zackzack#!python """Bootstrap setuptools installation If you want to use setuptools in your package's setup.py, just include this file in the same directory with it, and add this to the top of your setup.py:: from ez_setup import use_setuptools use_setuptools() If you want to require a specific version of setuptools, set a download mirror, or use an alternate download directory, you can do so by supplying the appropriate options to ``use_setuptools()``. This file can also be run as a script to install or upgrade setuptools. """ import sys DEFAULT_VERSION = "0.6c8" DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3] md5_data = { 'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca', 'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb', 'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b', 'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a', 'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618', 'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac', 'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5', 'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4', 'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c', 'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b', 'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27', 'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277', 'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa', 'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e', 'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e', 'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f', 'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2', 'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc', 'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167', 'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64', 'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d', 'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20', 'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab', 'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53', 'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2', 'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e', 'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372', 'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902', 'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de', 'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b', } import sys, os def _validate_md5(egg_name, data): if egg_name in md5_data: from md5 import md5 digest = md5(data).hexdigest() if digest != md5_data[egg_name]: print >>sys.stderr, ( "md5 validation of %s failed! (Possible download problem?)" % egg_name ) sys.exit(2) return data def use_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, download_delay=15 ): """Automatically find/download setuptools and make it available on sys.path `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where setuptools will be downloaded, if it is not already available. If `download_delay` is specified, it should be the number of seconds that will be paused before initiating a download, should one be required. If an older version of setuptools is installed, this routine will print a message to ``sys.stderr`` and raise SystemExit in an attempt to abort the calling script. """ was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules def do_download(): egg = download_setuptools(version, download_base, to_dir, download_delay) sys.path.insert(0, egg) import setuptools; setuptools.bootstrap_install_from = egg try: import pkg_resources except ImportError: return do_download() try: pkg_resources.require("setuptools>="+version); return except pkg_resources.VersionConflict, e: if was_imported: print >>sys.stderr, ( "The required version of setuptools (>=%s) is not available, and\n" "can't be installed while this script is running. Please install\n" " a more recent version first, using 'easy_install -U setuptools'." "\n\n(Currently using %r)" ) % (version, e.args[0]) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok return do_download() except pkg_resources.DistributionNotFound: return do_download() def download_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay = 15 ): """Download setuptools from a specified location and return its filename `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the number of seconds to pause before an actual download attempt. """ import urllib2, shutil egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3]) url = download_base + egg_name saveto = os.path.join(to_dir, egg_name) src = dst = None if not os.path.exists(saveto): # Avoid repeated downloads try: from distutils import log if delay: log.warn(""" --------------------------------------------------------------------------- This script requires setuptools version %s to run (even to display help). I will attempt to download it for you (from %s), but you may need to enable firewall access for this script first. I will start the download in %d seconds. (Note: if this machine does not have network access, please obtain the file %s and place it in this directory before rerunning this script.) ---------------------------------------------------------------------------""", version, download_base, delay, url ); from time import sleep; sleep(delay) log.warn("Downloading %s", url) src = urllib2.urlopen(url) # Read/write all in one block, so we don't create a corrupt file # if the download is interrupted. data = _validate_md5(egg_name, src.read()) dst = open(saveto,"wb"); dst.write(data) finally: if src: src.close() if dst: dst.close() return os.path.realpath(saveto) def main(argv, version=DEFAULT_VERSION): """Install or upgrade setuptools and EasyInstall""" try: import setuptools except ImportError: egg = None try: egg = download_setuptools(version, delay=0) sys.path.insert(0,egg) from setuptools.command.easy_install import main return main(list(argv)+[egg]) # we're done here finally: if egg and os.path.exists(egg): os.unlink(egg) else: if setuptools.__version__ == '0.0.1': print >>sys.stderr, ( "You have an obsolete version of setuptools installed. Please\n" "remove it from your system entirely before rerunning this script." ) sys.exit(2) req = "setuptools>="+version import pkg_resources try: pkg_resources.require(req) except pkg_resources.VersionConflict: try: from setuptools.command.easy_install import main except ImportError: from easy_install import main main(list(argv)+[download_setuptools(delay=0)]) sys.exit(0) # try to force an exit else: if argv: from setuptools.command.easy_install import main main(argv) else: print "Setuptools version",version,"or greater has been installed." print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)' def update_md5(filenames): """Update our built-in md5 registry""" import re from md5 import md5 for name in filenames: base = os.path.basename(name) f = open(name,'rb') md5_data[base] = md5(f.read()).hexdigest() f.close() data = [" %r: %r,\n" % it for it in md5_data.items()] data.sort() repl = "".join(data) import inspect srcfile = inspect.getsourcefile(sys.modules[__name__]) f = open(srcfile, 'rb'); src = f.read(); f.close() match = re.search("\nmd5_data = {\n([^}]+)}", src) if not match: print >>sys.stderr, "Internal error!" sys.exit(2) src = src[:match.start(1)] + repl + src[match.end(1):] f = open(srcfile,'w') f.write(src) f.close() if __name__=='__main__': if len(sys.argv)>2 and sys.argv[1]=='--md5update': update_md5(sys.argv[2:]) else: main(sys.argv[1:]) python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/docs/0000755000175000017500000000000011153054302023541 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/docs/source/0000755000175000017500000000000011153054302025041 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/docs/source/News.rst0000644000175000017500000000472011153053446026522 0ustar zackzack********************************************** :mod:`repoze.what.plugins.quickstart` releases ********************************************** This document describes the releases of :mod:`repoze.what.plugins.quickstart`. .. _1.0: :mod:`repoze.what.plugins.quickstart` 1.0 (2009-03-02) ====================================================== The final version 1.0 of :mod:`repoze.what.plugins.quickstart` is the same as v1.0rc4, since no bug has been found. .. _1.0rc4: :mod:`repoze.what.plugins.quickstart` 1.0rc4 (2009-02-18) ========================================================= * Made the groups/permissions-based authorization pattern optional, as in :mod:`repoze.what` itself. If you don't want to use it, set ``group_class`` and ``permission_class`` to ``None`` (when calling :func:`repoze.what.plugins.quickstart.setup_sql_auth`). .. _1.0rc3: :mod:`repoze.what.plugins.quickstart` 1.0rc3 (2009-02-17) ========================================================= * Updated the sample SQLAlchemy and Elixir models in the documentation, making clear how the SQLAlchemy session object should be imported depending on the used framework (if any). * Moved :class:`repoze.what.plugins.quickstart.FriendlyRedirectingFormPlugin` to :class:`repoze.who.plugins.friendlyform.FriendlyFormPlugin`. **This may seem like a backwards-incompatible change, but it is not** because since this :mod:`repoze.who` plugin was defined in this package as of version 1.0rc1, it was recommended not to use it directly because it was a temporary location. If you didn't use it directly, you have nothing to worry about. .. _1.0rc2: :mod:`repoze.what.plugins.quickstart` 1.0rc2 (2009-02-11) ========================================================= * :class:`FriendlyRedirectingFormPlugin ` ignored ``environ['SCRIPT_NAME']``. * Small fixes in the documentation. .. _1.0rc1: :mod:`repoze.what.plugins.quickstart` 1.0rc1 (2009-01-30) ========================================================= This is the first release of :mod:`repoze.what.plugins.quickstart` as an independent project. This module used to be defined by old versions of :mod:`repoze.what.plugins.sql`. There are no backwards incompatible changes at all. * Introduced the plugin :class:`FriendlyRedirectingFormPlugin ` and used by default in :func:`repoze.what.plugins.quickstart.setup_sql_auth`. python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/docs/source/_static/0000755000175000017500000000000011153054302026467 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/docs/source/_static/repoze.css0000644000175000017500000000047411140623133030512 0ustar zackzack@import url('default.css'); body { background-color: #006339; } div.document { background-color: #dad3bd; } div.sphinxsidebar h3,h4,h5,li,a { color: #127c56 !important; } div.related { color: #dad3bd !important; background-color: #00744a; } div.related a { color: #dad3bd !important; } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/docs/source/_static/model_sa_example.pypython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/docs/source/_static/model_sa_example.0000644000175000017500000000772011146526061032004 0ustar zackzack# -*- coding: utf-8 -*- """ Sample SQLAlchemy-powered model definition for the repoze.what SQL plugin. This model definition has been taken from a quickstarted TurboGears 2 project, but it's absolutely independent of TurboGears. """ import os from hashlib import sha1 from datetime import datetime from sqlalchemy import Table, ForeignKey, Column from sqlalchemy.types import String, Unicode, UnicodeText, Integer, DateTime, \ Boolean, Float from sqlalchemy.orm import relation, backref, synonym from yourproject.model import DeclarativeBase, metadata # This is the association table for the many-to-many relationship between # groups and permissions. group_permission_table = Table('group_permission', metadata, Column('group_id', Integer, ForeignKey('group.group_id', onupdate="CASCADE", ondelete="CASCADE")), Column('permission_id', Integer, ForeignKey('permission.permission_id', onupdate="CASCADE", ondelete="CASCADE")) ) # This is the association table for the many-to-many relationship between # groups and members - this is, the memberships. user_group_table = Table('user_group', metadata, Column('user_id', Integer, ForeignKey('user.user_id', onupdate="CASCADE", ondelete="CASCADE")), Column('group_id', Integer, ForeignKey('group.group_id', onupdate="CASCADE", ondelete="CASCADE")) ) # auth model class Group(DeclarativeBase): """An ultra-simple group definition.""" __tablename__ = 'group' group_id = Column(Integer, autoincrement=True, primary_key=True) group_name = Column(Unicode(16), unique=True) users = relation('User', secondary=user_group_table, backref='groups') class User(DeclarativeBase): """ Reasonably basic User definition. Probably would want additional attributes. """ __tablename__ = 'user' user_id = Column(Integer, autoincrement=True, primary_key=True) user_name = Column(Unicode(16), unique=True) _password = Column('password', Unicode(80)) def _set_password(self, password): """Hash password on the fly.""" hashed_password = password if isinstance(password, unicode): password_8bit = password.encode('UTF-8') else: password_8bit = password salt = sha1() salt.update(os.urandom(60)) hash = sha1() hash.update(password_8bit + salt.hexdigest()) hashed_password = salt.hexdigest() + hash.hexdigest() # Make sure the hased password is an UTF-8 object at the end of the # process because SQLAlchemy _wants_ a unicode object for Unicode # fields if not isinstance(hashed_password, unicode): hashed_password = hashed_password.decode('UTF-8') self._password = hashed_password def _get_password(self): """Return the password hashed""" return self._password password = synonym('_password', descriptor=property(_get_password, _set_password)) def validate_password(self, password): """ Check the password against existing credentials. :param password: the password that was provided by the user to try and authenticate. This is the clear text version that we will need to match against the hashed one in the database. :type password: unicode object. :return: Whether the password is valid. :rtype: bool """ hashed_pass = sha1() hashed_pass.update(password + self.password[:40]) return self.password[40:] == hashed_pass.hexdigest() class Permission(DeclarativeBase): """A relationship that determines what each Group can do""" __tablename__ = 'permission' permission_id = Column(Integer, autoincrement=True, primary_key=True) permission_name = Column(Unicode(16), unique=True) groups = relation(Group, secondary=group_permission_table, backref='permissions') python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/docs/source/_static/logo_hi.gif0000644000175000017500000000777611140623133030617 0ustar zackzackGIF89a4polܵEEE999VVUŪ؉ǼʤჂ򠞙dcaRRQ]\\{zx???MLL444333!,4@pH,Ȥrl:Ш@Zجvzxl-z|~su2WfoTe`UXboef :7=Óʋ<Ϥ5)ݳ߼˿ڶܾՎ΢55=C!ѷm+M>o6dtu._ݘUn>؟3:XfC`[0/h uCP![ W d(]"Xr_ 9"#2dwHe.zآ0]Z}7L PeI8tO aiCÃ WI -*蠄ozXv@5 @d "^0e80ݪ&p"|Cnk, 06,w)>jjwiɂ< ɂ:p +[8th k(8,#h,,/U"CPCg Z6 滲˙2宐A:Ё|{J/ B ؁Pp ZP p MK C,( g l| !p'| T)Prª P t5:z|pBX*R3( D-,. A'G, @8 @A*H@>P ql+0 䯀t)T>P`&(0,=#@V`?-;h_S܃ŭqWuo @/S^&  gZUG >B^EZUmyUk-}T0]w~;ܙ9%pquxO0 h07]- K-[^`q< ]rCyPb6Gy$a>p(%%@$g- }ǀ;%y'?rgy<2Tk=>Ng~'@S2D1\4l#px(w\i׀eBxx42-%eT\?05Ph>(}`(&u$`x/"r(^@6†Vz#ehy)iVhKng(`NHz!wB.  gx%d؉mȆl\e-7p_}4z!<`P#K`h~v,0\e `74(;0H9Ȇ<8،<@1#@։T9l(؎8mȆ $ LC9'J(.`KP hs3`"#׎yS:Y: 92`X`Yh ن0i2i 0m20UTYX`FC3Xo:HXyLB7. QI׋ 0dYfy)B gpr9tYtȗ~)|Xr(RV؄ 2xMxu2yuWɈZə捔ق闫W)B8^hBy)iXyiZHz¨I py1|?P雿Iٙy Ti PTK#p:ZP`a)zzEɚ  p?2UĢâ-j-ꓮB2/:1:= pq)@9>)U.ZFKKʣ>:0ڢ,60%ʥ#$b1P3Хɥ]٦Ӷ>ijkm 0 `U+mJ  l*djjr*A7ॆj v DGiZ$b905- :J** jJ*KfK jm2x=ښrʬJšjZ ׮*:ʩk8گʮ#Gڊ{7P0hzʮ:zK = 4 y<2=7U, M9P1:˳> +@+;KE۳@;LۮO۴NS[L[P;\XO+W;efac[\K]kR Y;././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/docs/source/_static/model_elixir_example.pypython-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/docs/source/_static/model_elixir_exam0000644000175000017500000000627011146526011032110 0ustar zackzack# -*- coding: utf-8 -*- """ Sample Elixir-powered model definition for the repoze.what SQL plugin. This model definition has been taken from a quickstarted TurboGears 2 project, but it's absolutely independent of TurboGears. """ import os from hashlib import sha1 from datetime import datetime from elixir import Entity, Field from elixir import DateTime, Unicode from elixir import using_options from elixir import ManyToMany class User(Entity): """Reasonably basic User definition. Probably would want additional attributes. """ using_options(tablename="user", auto_primarykey="user_id") user_name = Field(Unicode(16), required=True, unique=True) _password = Field(Unicode(80), colname="password", required=True) groups = ManyToMany( "Group", inverse="users", tablename="user_group", local_colname="group_id", remote_colname="user_id", ) def _set_password(self, password): """Hash password on the fly.""" hashed_password = password if isinstance(password, unicode): password_8bit = password.encode('UTF-8') else: password_8bit = password salt = sha1() salt.update(os.urandom(60)) hash = sha1() hash.update(password_8bit + salt.hexdigest()) hashed_password = salt.hexdigest() + hash.hexdigest() # Make sure the hased password is an UTF-8 object at the end of the # process because SQLAlchemy _wants_ a unicode object for Unicode # fields if not isinstance(hashed_password, unicode): hashed_password = hashed_password.decode('UTF-8') self._password = hashed_password def _get_password(self): """Return the password hashed""" return self._password password = descriptor=property(_get_password, _set_password) def validate_password(self, password): """Check the password against existing credentials. :param password: the password that was provided by the user to try and authenticate. This is the clear text version that we will need to match against the hashed one in the database. :type password: unicode object. :return: Whether the password is valid. :rtype: bool """ hashed_pass = sha1() hashed_pass.update(password + self.password[:40]) return self.password[40:] == hashed_pass.hexdigest() class Group(Entity): """An ultra-simple group definition.""" using_options(tablename="group", auto_primarykey="group_id") group_name = Field(Unicode(16), unique=True) display_name = Field(Unicode(255)) created = Field(DateTime, default=datetime.now) users = ManyToMany("User") permissions = ManyToMany( "Permission", inverse="groups", tablename="group_permission", local_colname="group_id", remote_colname="permission_id", ) class Permission(Entity): """A relationship that determines what each Group can do""" using_options(tablename="permission", auto_primarykey="permission_id") permission_name = Field(Unicode(16), unique=True) groups = ManyToMany("Group") python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/docs/source/index.rst0000644000175000017500000001211411146615710026711 0ustar zackzack**************************************** The :mod:`repoze.what` Quickstart plugin **************************************** :Author: Gustavo Narea. :Latest release: |release| .. module:: repoze.what.plugins.quickstart :synopsis: Ready-to-use authentication and authorization .. moduleauthor:: Gustavo Narea .. topic:: Overview This plugin allows you to take advantage of a rather simple, and usual, authentication and authorization setup, in which the users' data, the groups and the permissions used in the application are all stored in a SQLAlchemy or Elixir-managed database. Put simply, it configures :mod:`repoze.who` and :mod:`repoze.what` in one go so that you can have an authentication and authorization system working quickly -- hence the name. How to install ============== The minimum requirements are SQLAlchemy, :mod:`repoze.who.plugins.sa`, :mod:`repoze.who.plugins.friendlyform`, :mod:`repoze.what` and :mod:`repoze.what.plugins.sql`, and you can install it all with ``easy_install``:: easy_install repoze.what-quickstart The development mainline is available at the following Subversion repository:: http://svn.repoze.org/repoze.what/plugins/quickstart/trunk/ How to use it ============= To get started quickly, you may copy the SQLAlchemy-powered model defined in `model_sa_example.py `_ (or `model_elixir_example.py `_ for Elixir) and then create at least a few rows to try it out:: u = User() u.user_name = u'manager' u.password = u'managepass' DBSession.save(u) g = Group() g.group_name = u'managers' g.users.append(u) DBSession.save(g) p = Permission() p.permission_name = u'manage' p.groups.append(g) DBSession.save(p) DBSession.flush() Now that you have some rows in your database, you can set up authentication and authorization as explained in the next section. How to set it up ---------------- Although this is a :mod:`repoze.what` plugin and :mod:`repoze.what` is meant to deal with authorization only, this module configures authentication and identification for you through :mod:`repoze.who` as well. Such a setup is performed by the :func:`setup_sql_auth` function: .. autofunction:: setup_sql_auth See "`changing attribute names`_" to learn how to use the ``translations`` argument in :func:`setup_sql_auth`. Customizing the model definition -------------------------------- Your auth-related model doesn't `have to` be like the default one, where the class for your users, groups and permissions are, respectively, ``User``, ``Group`` and ``Permission``, and your users' user name is available in ``User.user_name``. What if you prefer ``Member`` and ``Team`` instead of ``User`` and ``Group``, respectively? Or what if you prefer ``Group.members`` instead of ``Group.users``? Read on! Changing class names ~~~~~~~~~~~~~~~~~~~~ Changing the name of an auth-related class (``User``, ``Group`` or ``Permission``) is a rather simple task. Just rename it in your model, and then make sure to update the parameters you pass to :func:`setup_sql_auth` accordingly. Changing attribute names ~~~~~~~~~~~~~~~~~~~~~~~~ You can also change the name of the attributes assumed by :mod:`repoze.what` in your auth-related classes, such as renaming ``User.groups`` to ``User.memberships``. Changing such values is what :mod:`repoze.what` calls "translating". You may set the translations for the attributes of the models :mod:`repoze.what` deals with in a dictionary passed to :func:`setup_sql_auth` as its ``translations`` parameters. For example, if you want to replace ``Group.users`` with ``Group.members``, you may use the following translation dictionary:: translations['users'] = 'members' Below are the translations that you would be able to set in the ``translations`` dictionary used above: * ``user_name``: The translation for the attribute in ``User.user_name``. * ``users``: The translation for the attribute in ``Group.users``. * ``group_name``: The translation for the attribute in ``Group.group_name``. * ``groups``: The translation for the attribute in ``User.groups`` and ``Permission.groups``. * ``permission_name``: The translation for the attribute in ``Permission.permission_name``. * ``permissions``: The translation for the attribute in ``User.permissions`` and ``Group.permissions``. * ``validate_password``: The translation for the method in ``User.validate_password``. How to get help? ================ The prefered place to ask questions is the `Repoze mailing list `_ or the `#repoze `_ IRC channel. Bugs reports and feature requests should be sent to `the issue tracker of the Repoze project `_. Contents ======== .. toctree:: :maxdepth: 2 News Indices and tables ------------------ * :ref:`genindex` * :ref:`modindex` * :ref:`search` python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/docs/source/conf.py0000644000175000017500000001413311153053252026345 0ustar zackzack# -*- coding: utf-8 -*- # # repoze.what documentation build configuration file, created by # sphinx-quickstart on Mon Nov 10 20:27:30 2008. # # This file is execfile()d with the current directory set to its containing dir. # # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleable (module imports are okay, they're removed automatically). # # All configuration values have a default value; values that are commented out # serve to show the default value. import sys, os here = os.path.dirname(os.path.abspath(__file__)) root = os.path.dirname(os.path.dirname(here)) # If setting up the auto(module|class) functionality: sys.path.append(os.path.abspath(root)) wd = os.getcwd() os.chdir(root) os.system('%s setup.py test -q' % sys.executable) os.chdir(wd) for item in os.listdir(root): if item.endswith('.egg'): sys.path.append(os.path.join(root, item)) # General configuration # --------------------- extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General substitutions. project = u'repoze.what Quickstart' copyright = u'2008-2009, The Repoze Project' # The default replacements for |version| and |release|, also used in various # other places throughout the built documents. # # The short X.Y version. version = '1.0' # The full version, including alpha/beta/rc tags. release = open(os.path.join(root, 'VERSION.txt')).readline().rstrip() # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build. #unused_docs = [] # List of directories, relative to source directories, that shouldn't be searched # for source files. exclude_trees = [] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # Options for HTML output # ----------------------- # The style sheet to use for HTML and HTML Help pages. A file of that name # must exist either in Sphinx' static/ path, or in one of the custom paths # given in html_static_path. html_style = 'repoze.css' # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. html_logo = '_static/logo_hi.gif' # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_use_modindex = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, the reST sources are included in the HTML build as _sources/. #html_copy_source = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = '' # Output file base name for HTML help builder. htmlhelp_basename = 'repozewhatquickstartdoc' # Options for LaTeX output # ------------------------ # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, document class [howto/manual]). latex_documents = [ ('index', 'repozewhatquickstart.tex', u'repoze.what Quickstart Documentation', u'Gustavo Narea', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_use_modindex = True intersphinx_mapping = { 'http://static.repoze.org/whatdocs/': None, 'http://static.repoze.org/whodocs/': None, 'http://code.gustavonarea.net/repoze.who.plugins.sa/': None, 'http://code.gustavonarea.net/repoze.who-friendlyform/': None, 'http://code.gustavonarea.net/repoze.what.plugins.sql/': None, } python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/docs/Makefile0000644000175000017500000000431311140623133025202 0ustar zackzack# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source .PHONY: help clean html web pickle htmlhelp latex changes linkcheck help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " pickle to make pickle files (usable by e.g. sphinx-web)" @echo " htmlhelp to make HTML files and a HTML help project" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " changes to make an overview over all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" clean: -rm -rf build/* html: mkdir -p build/html build/doctrees $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html @echo @echo "Build finished. The HTML pages are in build/html." pickle: mkdir -p build/pickle build/doctrees $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle @echo @echo "Build finished; now you can process the pickle files or run" @echo " sphinx-web build/pickle" @echo "to start the sphinx-web server." web: pickle htmlhelp: mkdir -p build/htmlhelp build/doctrees $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in build/htmlhelp." latex: mkdir -p build/latex build/doctrees $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex @echo @echo "Build finished; the LaTeX files are in build/latex." @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ "run these through (pdf)latex." changes: mkdir -p build/changes build/doctrees $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes @echo @echo "The overview file is in build/changes." linkcheck: mkdir -p build/linkcheck build/doctrees $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in build/linkcheck/output.txt." python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/MANIFEST.in0000644000175000017500000000030711140634704024355 0ustar zackzackinclude README.txt include VERSION.txt include MANIFEST.in recursive-include docs * prune docs/build recursive-include repoze * recursive-exclude tests * global-exclude *~ *.pyc *.egg .directory python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/setup.py0000644000175000017500000000532411153054173024335 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2007, Agendaless Consulting and Contributors. # Copyright (c) 2008, Florent Aide . # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## import os try: from setuptools import setup, find_packages except ImportError: from ez_setup import use_setuptools use_setuptools() from setuptools import setup, find_packages here = os.path.abspath(os.path.dirname(__file__)) README = open(os.path.join(here, 'README.txt')).read() version = open(os.path.join(here, 'VERSION.txt')).readline().rstrip() setup(name='repoze.what-quickstart', version=version, description=('The repoze.what Quickstart plugin'), long_description=README, classifiers=[ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Intended Audience :: Developers", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Database", "Topic :: Internet :: WWW/HTTP :: WSGI", "Topic :: Security" ], keywords='web application wsgi server sql sqlalchemy elixir ' \ 'authentication authorization repoze', author='Gustavo Narea', author_email='repoze-dev@lists.repoze.org', namespace_packages = ['repoze', 'repoze.what', 'repoze.what.plugins'], url='http://code.gustavonarea.net/repoze.what-quickstart/', license='BSD-derived (http://www.repoze.org/LICENSE.txt)', packages=find_packages(), include_package_data=True, zip_safe=False, tests_require=[ 'repoze.what', 'repoze.who', 'coverage', 'nose', 'repoze.who.plugins.sa', 'repoze.what.plugins.sql', 'repoze.who-friendlyform', ], install_requires=[ 'repoze.what >= 1.0.3', 'repoze.who', 'repoze.who.plugins.sa >= 1.0rc1', 'repoze.what.plugins.sql >= 1.0rc1', 'repoze.who-friendlyform', ], test_suite='nose.collector', entry_points = """\ """ ) python-repoze.what-plugins-20090531/repoze.what-quickstart-1.0/setup.cfg0000644000175000017500000000054111153054302024432 0ustar zackzack[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 [nosetests] cover-erase = 1 verbose = 1 cover-package = repoze.what.plugins.quickstart verbosity = 1 with-coverage = 1 detailed-errors = 1 no-path-adjustment = 1 testmatch = ^(tests|test_.*)$ with-doctest = 1 where = tests [aliases] release = egg_info -rDb "" sdist bdist_egg register upload python-repoze.what-plugins-20090531/repoze.what-quickstart0000777000175000017500000000000011210567251027177 2repoze.what-quickstart-1.0/ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.sql0000777000175000017500000000000011210567252027762 2repoze.what.plugins.sql-1.0rc1/ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.xml0000777000175000017500000000000011210567253027765 2repoze.what.plugins.xml-1.0rc1/ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-pylons0000777000175000017500000000000011210567250025462 2repoze.what-pylons-1.0/ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/0000755000175000017500000000000011140640730023307 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/README.txt0000644000175000017500000000062111140631234025003 0ustar zackzack************************** The repoze.what SQL plugin ************************** This is an adapters plugin for repoze.what. The SQL plugin makes repoze.what support sources defined in SQLAlchemy-managed databases by providing one group adapter, one permission adapter and one utility to configure both in one go (optionally, when the group source and the permission source have a relationship). python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze/0000755000175000017500000000000011140640730024613 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze/__init__.py0000644000175000017500000000164711137404712026740 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze/what/0000755000175000017500000000000011140640730025556 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze/what/__init__.py0000644000175000017500000000164611137404712027702 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze/what/plugins/0000755000175000017500000000000011140640730027237 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze/what/plugins/__init__.py0000644000175000017500000000173011137404712031355 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## """Special namespace for repoze.what plugins.""" # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze/what/plugins/sql/0000755000175000017500000000000011140640730030036 5ustar zackzack././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze/what/plugins/sql/adapters.pypython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze/what/plugins/sql/adapters.0000644000175000017500000004272211137647064031666 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## """ SQL plugin for :mod:`repoze.what` based on SQLAlchemy. This is a core plugin that provides ``source adapters`` for groups and permissions stored in databases. Below is the "translation" of the terminology used by repoze.what into databases' terminology: * source -> database * section -> parent row (in a one-to-many relationship) * item -> a child row (in a one-to-many relationship) In a group source adapter, a ``section`` is a group in the source (a parent row) and its items are the users that belong to that section (its children rows). In a permission source adapter, a ``section`` is a permission in the source (a parent row) and its items are the groups that are granted that permission (its children rows). For developers to be able to use the names they want in their model, both the groups and permissions source adapters use a "translation table" for the field and table names involved: * Group source adapter: * "section_name" (default: "group_name"): The name of the table field that contains the primary key in the groups table. * "sections" (default: "groups"): The groups to which a given user belongs. * "item_name" (default: "user_name"): The name of the table field that contains the primary key in the users table. * "items" (default: "users"): The users that belong to a given group. * Permission source adapter: * "section_name" (default: "permission_name"): The name of the table field that contains the primary key in the permissions table. * "sections" (default: "permissions"): The permissions granted to a given group. * "item_name" (default: "group_name"): The name of the table field that contains the primary key in the groups table. * "items" (default: "groups"): The groups that are granted a given permission. @attention: These adapters have a serious limitation, since they are based on one-to-many relations: If you're using the groups adapter, then your users' data must also be handled by SQLAlchemy; likewise, If you're using the permissions adapter, then your groups must also be handled by SQLAlchemy. @attention: When using the SQL group adapter, it will load the authenticated used object into repoze.who's identity dict (under the "user" key). """ from sqlalchemy.exceptions import SQLAlchemyError from sqlalchemy.orm.exc import NoResultFound from repoze.what.adapters import BaseSourceAdapter, SourceError __all__ = ['SqlGroupsAdapter', 'SqlPermissionsAdapter', 'configure_sql_adapters'] class _BaseSqlAdapter(BaseSourceAdapter): """Base class for SQL source adapters.""" def __init__(self, parent_class, children_class, dbsession): """ Create an SQL source adapter. :param parent_class: The SQLAlchemy table of the section. :param children_class: The SQLAlchemy table of the items. :param dbsession: The SQLAlchemy session. """ super(_BaseSqlAdapter, self).__init__() self.dbsession = dbsession self.parent_class = parent_class self.children_class = children_class # BaseSourceAdapter def _get_all_sections(self): sections = {} sections_as_rows = self.dbsession.query(self.parent_class).all() for section_as_row in sections_as_rows: section_name = getattr(section_as_row, self.translations['section_name']) sections[section_name] = self._get_section_items(section_name) return sections # BaseSourceAdapter def _get_section_items(self, section): section_as_row = self._get_section_as_row(section) # A short-cut a translation: item_name = self.translations['item_name'] # The name of all the items that belong to the section in question: items_as_rowset = getattr(section_as_row, self.translations['items']) return set((getattr(i, item_name) for i in items_as_rowset)) # TODO: Factor out the common code in _include_items and _exclude_items # BaseSourceAdapter def _include_items(self, section, items): self.dbsession.begin(subtransactions=True) item, included_items = self._get_items_as_rowset(section) for item_to_include in items: item_as_row = self._get_item_as_row(item_to_include) included_items.append(item_as_row) self.dbsession.commit() # BaseSourceAdapter def _exclude_items(self, section, items): self.dbsession.begin(subtransactions=True) item, included_items = self._get_items_as_rowset(section) for item_to_exclude in items: item_as_row = self._get_item_as_row(item_to_exclude) included_items.remove(item_as_row) self.dbsession.commit() # BaseSourceAdapter def _item_is_included(self, section, item): return item in self._get_section_items(section) # BaseSourceAdapter def _create_section(self, section): self.dbsession.begin(subtransactions=True) section_as_row = self.parent_class() # Creating the section with an empty set of items: setattr(section_as_row, self.translations['section_name'], section) setattr(section_as_row, self.translations['items'], []) self.dbsession.add(section_as_row) self.dbsession.commit() # BaseSourceAdapter def _edit_section(self, section, new_section): self.dbsession.begin(subtransactions=True) section_as_row = self._get_section_as_row(section) setattr(section_as_row, self.translations['section_name'], new_section) self.dbsession.commit() # BaseSourceAdapter def _delete_section(self, section): self.dbsession.begin(subtransactions=True) section_as_row = self._get_section_as_row(section) self.dbsession.delete(section_as_row) self.dbsession.commit() # BaseSourceAdapter def _section_exists(self, section): # TODO: There must be a more elegant way to do this with SQLAlchemy try: self._get_section_as_row(section) return True except SourceError: return False def _get_section_as_row(self, section_name): """ Return the SQLAlchemy row for the section called ``section_name``. When dealing with a group source, the section is a group. And when dealing with a permission source, the section is a permission. """ # "field" usually equals to {tg_package}.model.Group.group_name # or {tg_package}.model.Permission.permission_name field = getattr(self.parent_class, self.translations['section_name']) query = self.dbsession.query(self.parent_class) try: section_as_row = query.filter(field==section_name).one() except NoResultFound: msg = 'Section (%s) "%s" is not defined in the parent table' msg = msg % (self.translations['section_name'], section_name) raise SourceError(msg) return section_as_row def _get_item_as_row(self, item_name): """ Return the SQLAlchemy row for the item called ``item_name``. When dealing with a group source, the item is a user. And when dealing with a permission source, the item is a group. """ # "field" usually equals to {tg_package}.model.User.user_name # or {tg_package}.model.Group.group_name field = getattr(self.children_class, self.translations['item_name']) query = self.dbsession.query(self.children_class) try: item_as_row = query.filter(field==item_name).one() except NoResultFound: msg = 'Item (%s) "%s" does not exist in the child table' msg = msg % (self.translations['item_name'], item_name) raise SourceError(msg) return item_as_row def _get_items_as_rowset(self, section_name): """ Return the items of the section called ``section_name``. When dealing with a group source, the section is a group and the items (the result of this function) are the users that belong to such a group. When dealing with a permission source, the section is a permission and the items (the result of this function) are the groups that are granted such a permission. """ section_as_row = self._get_section_as_row(section_name) items_as_rowset = getattr(section_as_row, self.translations['items']) return section_as_row, items_as_rowset #{ Source adapters class SqlGroupsAdapter(_BaseSqlAdapter): """ The SQL group source adapter. To use this adapter, you must also define your users in a SQLAlchemy or Elixir-managed table with the relevant one-to-many (or many-to-many) relationship defined with ``group_class``. On the other hand, unless stated otherwise, it will also assume the following naming conventions in both classes; to replace any of those default values, you should use the ``translations`` dictionary of the relevant class accordingly: * In `group_class`, the attribute that contains the group name is ``group_name`` (e.g., ``Group.group_name``). * In `group_class`, the attribute that contains the members of such a group is ``users`` (e.g., ``Group.users``). * In `user_class`, the attribute that contains the user's name is ``user_name`` (e.g., ``User.user_name``). * In `user_class`, the attribute that contains the groups to which a user belongs is ``groups`` (e.g., ``User.groups``). Example #1, without special naming conventions:: # ... from repoze.what.plugins.sql import SqlGroupsAdapter from my_model import User, Group, DBSession groups = SqlGroupsAdapter(Group, User, DBSession) # ... Example #2, with special naming conventions:: # ... from repoze.what.plugins.sql import SqlGroupsAdapter from my_model import Member, Team, DBSession groups = SqlGroupsAdapter(Team, Member, DBSession) # Replacing the default attributes, if necessary: # We have "Team.team_name" instead of "Team.group_name": groups.translations['section_name'] = 'team_name' # We have "Team.members" instead of "Team.users": groups.translations['items'] = 'members' # We have "Member.username" instead of "Member.user_name": groups.translations['item_name'] = 'username' # We have "Member.teams" instead of "Member.groups": groups.translations['sections'] = 'teams' # ... """ def __init__(self, group_class, user_class, dbsession): """ Create an SQL groups source adapter. :param group_class: The class that manages the groups. :param user_class: The class that manages the users. :param dbsession: The SQLALchemy/Elixir session to be used. """ super(SqlGroupsAdapter, self).__init__(parent_class=group_class, children_class=user_class, dbsession=dbsession) self.translations = { 'section_name': 'group_name', 'sections': 'groups', 'item_name': 'user_name', 'items': 'users' } # BaseSourceAdapter def _find_sections(self, credentials): id_ = credentials['repoze.what.userid'] try: user = self._get_item_as_row(id_) except SourceError: return set() user_memberships = getattr(user, self.translations['sections']) return set([getattr(group, self.translations['section_name']) for group in user_memberships]) class SqlPermissionsAdapter(_BaseSqlAdapter): """ The SQL permission source adapter. To use this adapter, you must also define your groups in a SQLAlchemy or Elixir-managed table with the relevant one-to-many (or many-to-many) relationship defined with ``permission_class``. On the other hand, unless stated otherwise, it will also assume the following naming conventions in both classes; to replace any of those default values, you should use the ``translations`` dictionary of the relevant class accordingly: * In `permission_class`, the attribute that contains the permission name is ``permission_name`` (e.g., ``Permission.permission_name``). * In `permission_class`, the attribute that contains the groups that are granted such a permission is ``groups`` (e.g., ``Permission.groups``). * In `group_class`, the attribute that contains the group name is ``group_name`` (e.g., ``Group.group_name``). * In `group_class`, the attribute that contains the permissions granted to that group is ``permissions`` (e.g., ``Group.permissions``). Example #1, without special naming conventions:: # ... from repoze.what.plugins.sql import SqlPermissionsAdapter from my_model import Group, Permission, DBSession groups = SqlPermissionsAdapter(Permission, Group, DBSession) # ... Example #2, with special naming conventions:: # ... from repoze.what.plugins.sql import SqlPermissionsAdapter from my_model import Team, Permission, DBSession permissions = SqlPermissionsAdapter(Permission, Team, DBSession) # Replacing the default attributes, if necessary: # We have "Permission.perm_name" instead of "Permission.permission_name": permissions.translations['section_name'] = 'perm_name' # We have "Permission.teams" instead of "Permission.groups": permissions.translations['items'] = 'teams' # We have "Team.team_name" instead of "Team.group_name": permissions.translations['item_name'] = 'team_name' # We have "Team.perms" instead of "Team.permissions": permissions.translations['sections'] = 'perms' # ... """ def __init__(self, permission_class, group_class, dbsession): """ Create an SQL permissions source adapter. :param permission_class: The class that manages the permissions. :param group_class: The class that manages the groups. :param dbsession: The SQLALchemy/Elixir session to be used. """ super(SqlPermissionsAdapter, self).__init__( parent_class=permission_class, children_class=group_class, dbsession=dbsession ) self.translations = { 'section_name': 'permission_name', 'sections': 'permissions', 'item_name': 'group_name', 'items': 'groups' } # BaseSourceAdapter def _find_sections(self, group_name): try: group = self._get_item_as_row(group_name) except SourceError: return set() group_permissions = getattr(group, self.translations['sections']) return set([getattr(permission, self.translations['section_name']) for permission in group_permissions]) #{ Utilities def configure_sql_adapters(user_class, group_class, permission_class, session, group_translations={}, permission_translations={}): """ Configure and return group and permission adapters that share the same model. :param user_class: The class that manages the users. :param group_class: The class that manages the groups. :param user_class: The class that manages the permissions. :param dbsession: The SQLALchemy/Elixir session to be used. :param group_translations: The dictionary of translations for the group. :param permission_translations: The dictionary of translations for the permissions. :return: The ``group`` and ``permission`` adapters, configured. :rtype: dict For this function to work, ``user_class`` and ``group_class`` must have the relevant one-to-many (or many-to-many) relationship; likewise, ``group_class`` and ``permission_class`` must have the relevant one-to-many (or many-to-many) relationship. Example:: # ... from repoze.what.plugins.sql import configure_sql_adapters from my_model import User, Group, Permission, DBSession adapters = configure_sql_adapters(User, Group, Permission, DBSession) groups = adapters['group'] permissions = adapters['permission'] # ... """ # Creating the adapters: group = SqlGroupsAdapter(group_class, user_class, session) permission = SqlPermissionsAdapter(permission_class, group_class, session) # Translating some fields: group.translations.update(group_translations) permission.translations.update(permission_translations) return {'group': group, 'permission': permission} #} ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze/what/plugins/sql/__init__.pypython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze/what/plugins/sql/__init__.0000644000175000017500000000202211137404711031575 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## """SQL plugin for repoze.what based on SQLAlchemy.""" from repoze.what.plugins.sql.adapters import SqlGroupsAdapter, \ SqlPermissionsAdapter, \ configure_sql_adapters __all__ = ['SqlGroupsAdapter', 'SqlPermissionsAdapter', 'configure_sql_adapters'] python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/PKG-INFO0000644000175000017500000000235011140640730024404 0ustar zackzackMetadata-Version: 1.0 Name: repoze.what.plugins.sql Version: 1.0rc1 Summary: The repoze.what SQL plugin Home-page: http://code.gustavonarea.net/repoze.what.plugins.sql/ Author: Gustavo Narea Author-email: repoze-dev@lists.repoze.org License: BSD-derived (http://www.repoze.org/LICENSE.txt) Description: ************************** The repoze.what SQL plugin ************************** This is an adapters plugin for repoze.what. The SQL plugin makes repoze.what support sources defined in SQLAlchemy-managed databases by providing one group adapter, one permission adapter and one utility to configure both in one go (optionally, when the group source and the permission source have a relationship). Keywords: web application wsgi server wsgi sql sqlalchemy elixir authorization repoze Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Database Classifier: Topic :: Internet :: WWW/HTTP :: WSGI Classifier: Topic :: Security python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/VERSION.txt0000644000175000017500000000000611140632760025175 0ustar zackzack1.0rc1python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/ez_setup.py0000644000175000017500000002231311104031541025512 0ustar zackzack#!python """Bootstrap setuptools installation If you want to use setuptools in your package's setup.py, just include this file in the same directory with it, and add this to the top of your setup.py:: from ez_setup import use_setuptools use_setuptools() If you want to require a specific version of setuptools, set a download mirror, or use an alternate download directory, you can do so by supplying the appropriate options to ``use_setuptools()``. This file can also be run as a script to install or upgrade setuptools. """ import sys DEFAULT_VERSION = "0.6c8" DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3] md5_data = { 'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca', 'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb', 'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b', 'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a', 'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618', 'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac', 'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5', 'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4', 'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c', 'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b', 'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27', 'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277', 'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa', 'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e', 'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e', 'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f', 'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2', 'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc', 'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167', 'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64', 'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d', 'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20', 'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab', 'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53', 'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2', 'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e', 'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372', 'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902', 'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de', 'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b', } import sys, os def _validate_md5(egg_name, data): if egg_name in md5_data: from md5 import md5 digest = md5(data).hexdigest() if digest != md5_data[egg_name]: print >>sys.stderr, ( "md5 validation of %s failed! (Possible download problem?)" % egg_name ) sys.exit(2) return data def use_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, download_delay=15 ): """Automatically find/download setuptools and make it available on sys.path `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where setuptools will be downloaded, if it is not already available. If `download_delay` is specified, it should be the number of seconds that will be paused before initiating a download, should one be required. If an older version of setuptools is installed, this routine will print a message to ``sys.stderr`` and raise SystemExit in an attempt to abort the calling script. """ was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules def do_download(): egg = download_setuptools(version, download_base, to_dir, download_delay) sys.path.insert(0, egg) import setuptools; setuptools.bootstrap_install_from = egg try: import pkg_resources except ImportError: return do_download() try: pkg_resources.require("setuptools>="+version); return except pkg_resources.VersionConflict, e: if was_imported: print >>sys.stderr, ( "The required version of setuptools (>=%s) is not available, and\n" "can't be installed while this script is running. Please install\n" " a more recent version first, using 'easy_install -U setuptools'." "\n\n(Currently using %r)" ) % (version, e.args[0]) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok return do_download() except pkg_resources.DistributionNotFound: return do_download() def download_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay = 15 ): """Download setuptools from a specified location and return its filename `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the number of seconds to pause before an actual download attempt. """ import urllib2, shutil egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3]) url = download_base + egg_name saveto = os.path.join(to_dir, egg_name) src = dst = None if not os.path.exists(saveto): # Avoid repeated downloads try: from distutils import log if delay: log.warn(""" --------------------------------------------------------------------------- This script requires setuptools version %s to run (even to display help). I will attempt to download it for you (from %s), but you may need to enable firewall access for this script first. I will start the download in %d seconds. (Note: if this machine does not have network access, please obtain the file %s and place it in this directory before rerunning this script.) ---------------------------------------------------------------------------""", version, download_base, delay, url ); from time import sleep; sleep(delay) log.warn("Downloading %s", url) src = urllib2.urlopen(url) # Read/write all in one block, so we don't create a corrupt file # if the download is interrupted. data = _validate_md5(egg_name, src.read()) dst = open(saveto,"wb"); dst.write(data) finally: if src: src.close() if dst: dst.close() return os.path.realpath(saveto) def main(argv, version=DEFAULT_VERSION): """Install or upgrade setuptools and EasyInstall""" try: import setuptools except ImportError: egg = None try: egg = download_setuptools(version, delay=0) sys.path.insert(0,egg) from setuptools.command.easy_install import main return main(list(argv)+[egg]) # we're done here finally: if egg and os.path.exists(egg): os.unlink(egg) else: if setuptools.__version__ == '0.0.1': print >>sys.stderr, ( "You have an obsolete version of setuptools installed. Please\n" "remove it from your system entirely before rerunning this script." ) sys.exit(2) req = "setuptools>="+version import pkg_resources try: pkg_resources.require(req) except pkg_resources.VersionConflict: try: from setuptools.command.easy_install import main except ImportError: from easy_install import main main(list(argv)+[download_setuptools(delay=0)]) sys.exit(0) # try to force an exit else: if argv: from setuptools.command.easy_install import main main(argv) else: print "Setuptools version",version,"or greater has been installed." print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)' def update_md5(filenames): """Update our built-in md5 registry""" import re from md5 import md5 for name in filenames: base = os.path.basename(name) f = open(name,'rb') md5_data[base] = md5(f.read()).hexdigest() f.close() data = [" %r: %r,\n" % it for it in md5_data.items()] data.sort() repl = "".join(data) import inspect srcfile = inspect.getsourcefile(sys.modules[__name__]) f = open(srcfile, 'rb'); src = f.read(); f.close() match = re.search("\nmd5_data = {\n([^}]+)}", src) if not match: print >>sys.stderr, "Internal error!" sys.exit(2) src = src[:match.start(1)] + repl + src[match.end(1):] f = open(srcfile,'w') f.write(src) f.close() if __name__=='__main__': if len(sys.argv)>2 and sys.argv[1]=='--md5update': update_md5(sys.argv[2:]) else: main(sys.argv[1:]) ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/0000755000175000017500000000000011140640730031525 5ustar zackzack././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/requires.txtpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/0000644000175000017500000000004611140640730031527 0ustar zackzackrepoze.what >= 1.0.3 sqlalchemy >= 0.5././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/namespace_packages.txtpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/0000644000175000017500000000004711140640730031530 0ustar zackzackrepoze repoze.what repoze.what.plugins ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/dependency_links.txtpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/0000644000175000017500000000000111140640730031516 0ustar zackzack ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/PKG-INFOpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/0000644000175000017500000000235011140640730031527 0ustar zackzackMetadata-Version: 1.0 Name: repoze.what.plugins.sql Version: 1.0rc1 Summary: The repoze.what SQL plugin Home-page: http://code.gustavonarea.net/repoze.what.plugins.sql/ Author: Gustavo Narea Author-email: repoze-dev@lists.repoze.org License: BSD-derived (http://www.repoze.org/LICENSE.txt) Description: ************************** The repoze.what SQL plugin ************************** This is an adapters plugin for repoze.what. The SQL plugin makes repoze.what support sources defined in SQLAlchemy-managed databases by providing one group adapter, one permission adapter and one utility to configure both in one go (optionally, when the group source and the permission source have a relationship). Keywords: web application wsgi server wsgi sql sqlalchemy elixir authorization repoze Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Database Classifier: Topic :: Internet :: WWW/HTTP :: WSGI Classifier: Topic :: Security ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/entry_points.txtpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/0000644000175000017500000000000611140640730031523 0ustar zackzack ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/top_level.txtpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/0000644000175000017500000000003111140640730031521 0ustar zackzackrepoze tests test_elixir ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/not-zip-safepython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/0000644000175000017500000000000111107633364031526 0ustar zackzack ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/SOURCES.txtpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/repoze.what.plugins.sql.egg-info/0000644000175000017500000000137311140640730031533 0ustar zackzackMANIFEST.in README.txt VERSION.txt ez_setup.py setup.cfg setup.py docs/Makefile docs/source/Adapters.rst docs/source/News.rst docs/source/conf.py docs/source/index.rst docs/source/_static/logo_hi.gif docs/source/_static/repoze.css repoze/__init__.py repoze.what.plugins.sql.egg-info/PKG-INFO repoze.what.plugins.sql.egg-info/SOURCES.txt repoze.what.plugins.sql.egg-info/dependency_links.txt repoze.what.plugins.sql.egg-info/entry_points.txt repoze.what.plugins.sql.egg-info/namespace_packages.txt repoze.what.plugins.sql.egg-info/not-zip-safe repoze.what.plugins.sql.egg-info/requires.txt repoze.what.plugins.sql.egg-info/top_level.txt repoze/what/__init__.py repoze/what/plugins/__init__.py repoze/what/plugins/sql/__init__.py repoze/what/plugins/sql/adapters.pypython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/docs/0000755000175000017500000000000011140640730024237 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/docs/source/0000755000175000017500000000000011140640730025537 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/docs/source/News.rst0000644000175000017500000000511511140633002027201 0ustar zackzack*************************************** :mod:`repoze.what.plugins.sql` releases *************************************** This document describes the releases of :mod:`repoze.what.plugins.sql`. .. _repoze.what-sql-1.0rc1: :mod:`repoze.what.plugins.sql` 1.0rc1 (2009-01-30) ================================================= * Moved :mod:`repoze.what.plugins.quickstart` into an independent project. .. _repoze.what-sql-1.0b1: :mod:`repoze.what.plugins.sql` 1.0b1 (2009-01-27) ================================================= * Synchronized to :mod:`repoze.what` v1.0.1 and its ``credentials`` dict. * Loaded the user object into the ``identity`` thanks to :class:`repoze.who.plugins.sa.SQLAlchemyUserMDPlugin`. * Many minor fixes. .. _repoze.what-sql-1.0a5: :mod:`repoze.what.plugins.sql` 1.0a5 (2009-01-08) ================================================= * I replaced ``/logout_handler`` with ``/logout`` by mistake while making that setting customizable in the previous release, which broke some applications. That's now fixed (``/logout_handler`` is back). .. _repoze.what-sql-1.0a4: :mod:`repoze.what.plugins.sql` 1.0a4 (2009-01-02) ================================================= * Added the ability to customize the login/logout related URLs through :func:`repoze.what.plugins.quickstart.setup_sql_auth` (`TurboGears Ticket #2114 `_). .. _repoze.what-sql-1.0a3: :mod:`repoze.what.plugins.sql` 1.0a3 (2008-12-19) ================================================= * Moved the :class:`repoze.what.plugins.quickstart.SQLAuthenticatorPlugin` authenticator into a new, :mod:`repoze.what`-independent project: :mod:`repoze.who.plugins.sa`. * :class:`repoze.what.plugins.sql.adapters.SqlGroupsAdapter` ignored translations while retrieving the groups to which the authenticated user belongs (`TurboGears Ticket #2094 `_). * The documentation for this plugin has been updated and is now hosted at http://code.gustavonarea.net/repoze.what.plugins.sql/ .. _repoze.what-sql-1.0a2: :mod:`repoze.what.plugins.sql` 1.0a2 (2008-12-04) ================================================= * Fixed the broken test suite for Elixir, thanks to Helio Pereira. * Updated :func:`repoze.what.plugins.quickstart.setup_sql_auth` according to the backwards incompatible change on :func:`repoze.what.middleware.setup_auth` introduced in :mod:`repoze.what`-1.0b2. * Now it's possible to customize the authentication/identification cookie through :func:`repoze.what.plugins.quickstart.setup_sql_auth`. * Tons of minor bug fixes. python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/docs/source/Adapters.rst0000644000175000017500000000131711122555767030055 0ustar zackzack************************************** :mod:`repoze.what` SQL source adapters ************************************** .. module:: repoze.what.plugins.sql.adapters :synopsis: SQL adapters for repoze.what .. moduleauthor:: Gustavo Narea .. topic:: Overview This document explains the SQL source adapters provided by the plugin. The classes and functions mentioned below are imported into the :mod:`repoze.what.plugins.sql` namespace, so you can also import them from there. SQL adapters ============ .. autoclass:: SqlGroupsAdapter :members: __init__ .. autoclass:: SqlPermissionsAdapter :members: __init__ Utilities ========= .. autofunction:: configure_sql_adapters python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/docs/source/_static/0000755000175000017500000000000011140640730027165 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/docs/source/_static/repoze.css0000644000175000017500000000047411122532072031207 0ustar zackzack@import url('default.css'); body { background-color: #006339; } div.document { background-color: #dad3bd; } div.sphinxsidebar h3,h4,h5,li,a { color: #127c56 !important; } div.related { color: #dad3bd !important; background-color: #00744a; } div.related a { color: #dad3bd !important; } python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/docs/source/_static/logo_hi.gif0000644000175000017500000000777611122532072031314 0ustar zackzackGIF89a4polܵEEE999VVUŪ؉ǼʤჂ򠞙dcaRRQ]\\{zx???MLL444333!,4@pH,Ȥrl:Ш@Zجvzxl-z|~su2WfoTe`UXboef :7=Óʋ<Ϥ5)ݳ߼˿ڶܾՎ΢55=C!ѷm+M>o6dtu._ݘUn>؟3:XfC`[0/h uCP![ W d(]"Xr_ 9"#2dwHe.zآ0]Z}7L PeI8tO aiCÃ WI -*蠄ozXv@5 @d "^0e80ݪ&p"|Cnk, 06,w)>jjwiɂ< ɂ:p +[8th k(8,#h,,/U"CPCg Z6 滲˙2宐A:Ё|{J/ B ؁Pp ZP p MK C,( g l| !p'| T)Prª P t5:z|pBX*R3( D-,. A'G, @8 @A*H@>P ql+0 䯀t)T>P`&(0,=#@V`?-;h_S܃ŭqWuo @/S^&  gZUG >B^EZUmyUk-}T0]w~;ܙ9%pquxO0 h07]- K-[^`q< ]rCyPb6Gy$a>p(%%@$g- }ǀ;%y'?rgy<2Tk=>Ng~'@S2D1\4l#px(w\i׀eBxx42-%eT\?05Ph>(}`(&u$`x/"r(^@6†Vz#ehy)iVhKng(`NHz!wB.  gx%d؉mȆl\e-7p_}4z!<`P#K`h~v,0\e `74(;0H9Ȇ<8،<@1#@։T9l(؎8mȆ $ LC9'J(.`KP hs3`"#׎yS:Y: 92`X`Yh ن0i2i 0m20UTYX`FC3Xo:HXyLB7. QI׋ 0dYfy)B gpr9tYtȗ~)|Xr(RV؄ 2xMxu2yuWɈZə捔ق闫W)B8^hBy)iXyiZHz¨I py1|?P雿Iٙy Ti PTK#p:ZP`a)zzEɚ  p?2UĢâ-j-ꓮB2/:1:= pq)@9>)U.ZFKKʣ>:0ڢ,60%ʥ#$b1P3Хɥ]٦Ӷ>ijkm 0 `U+mJ  l*djjr*A7ॆj v DGiZ$b905- :J** jJ*KfK jm2x=ښrʬJšjZ ׮*:ʩk8گʮ#Gڊ{7P0hzʮ:zK = 4 y<2=7U, M9P1:˳> +@+;KE۳@;LۮO۴NS[L[P;\XO+W;efac[\K]kR Y;python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/docs/source/index.rst0000644000175000017500000000364711140625563027421 0ustar zackzack********************************* The :mod:`repoze.what` SQL plugin ********************************* :Author: Gustavo Narea. :Status: Official :Latest release: |release| .. module:: repoze.what.plugins.sql :synopsis: SQL support for repoze.what .. moduleauthor:: Gustavo Narea .. moduleauthor:: Florent Aide .. moduleauthor:: Agendaless Consulting and Contributors .. topic:: Overview The SQL plugin makes :mod:`repoze.what` support sources defined in `SQLAlchemy `_ or `Elixir `_-managed databases by providing one *group adapter*, one *permission adapter* and one utility to configure both in one go (optionally, when the *group source* and the *permission source* have a relationship). They are all defined in the :mod:`repoze.what.plugins.sql` module. .. warning:: Only SQLAlchemy is intended to be supported. Elixir is known to work but it's not officially supported, so Elixir support *might* be broken in future releases. How to install ============== The minimum requirements are SQLAlchemy, and :mod:`repoze.what`, and you can install it all with ``easy_install``:: easy_install repoze.what.plugins.sql The development mainline is available at the following Subversion repository:: http://svn.repoze.org/repoze.what/plugins/sql/trunk/ How to get help? ================ The prefered place to ask questions is the `Repoze mailing list `_ or the `#repoze `_ IRC channel. Bugs reports and feature requests should be sent to `the issue tracker of the Repoze project `_. Contents ======== .. toctree:: :maxdepth: 2 Adapters News Indices and tables ------------------ * :ref:`genindex` * :ref:`modindex` * :ref:`search` python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/docs/source/conf.py0000644000175000017500000001400411140624676027050 0ustar zackzack# -*- coding: utf-8 -*- # # repoze.what documentation build configuration file, created by # sphinx-quickstart on Mon Nov 10 20:27:30 2008. # # This file is execfile()d with the current directory set to its containing dir. # # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleable (module imports are okay, they're removed automatically). # # All configuration values have a default value; values that are commented out # serve to show the default value. import sys, os here = os.path.dirname(os.path.abspath(__file__)) root = os.path.dirname(os.path.dirname(here)) # If setting up the auto(module|class) functionality: sys.path.append(os.path.abspath(root)) wd = os.getcwd() os.chdir(root) os.system('%s setup.py test -q' % sys.executable) os.chdir(wd) for item in os.listdir(root): if item.endswith('.egg'): sys.path.append(os.path.join(root, item)) # General configuration # --------------------- extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General substitutions. project = u'repoze.what SQL plugin' copyright = u'2008, The Repoze Project' # The default replacements for |version| and |release|, also used in various # other places throughout the built documents. # # The short X.Y version. version = '1.0' # The full version, including alpha/beta/rc tags. release = open(os.path.join(root, 'VERSION.txt')).readline().rstrip() # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build. #unused_docs = [] # List of directories, relative to source directories, that shouldn't be searched # for source files. exclude_trees = [] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # Options for HTML output # ----------------------- # The style sheet to use for HTML and HTML Help pages. A file of that name # must exist either in Sphinx' static/ path, or in one of the custom paths # given in html_static_path. html_style = 'repoze.css' # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. html_logo = '_static/logo_hi.gif' # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_use_modindex = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, the reST sources are included in the HTML build as _sources/. #html_copy_source = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = '' # Output file base name for HTML help builder. htmlhelp_basename = 'repozewhatsqldoc' # Options for LaTeX output # ------------------------ # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, document class [howto/manual]). latex_documents = [ ('index', 'repozewhatsql.tex', u'repoze.what SQL plugin Documentation', u'Gustavo Narea', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_use_modindex = True intersphinx_mapping = { 'http://static.repoze.org/whatdocs/': None, 'http://static.repoze.org/whodocs/': None, 'http://code.gustavonarea.net/repoze.who.plugins.sa/': None, 'http://code.gustavonarea.net/repoze.what-quickstart/': None, } python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/docs/Makefile0000644000175000017500000000431311122532072025677 0ustar zackzack# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source .PHONY: help clean html web pickle htmlhelp latex changes linkcheck help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " pickle to make pickle files (usable by e.g. sphinx-web)" @echo " htmlhelp to make HTML files and a HTML help project" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " changes to make an overview over all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" clean: -rm -rf build/* html: mkdir -p build/html build/doctrees $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html @echo @echo "Build finished. The HTML pages are in build/html." pickle: mkdir -p build/pickle build/doctrees $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle @echo @echo "Build finished; now you can process the pickle files or run" @echo " sphinx-web build/pickle" @echo "to start the sphinx-web server." web: pickle htmlhelp: mkdir -p build/htmlhelp build/doctrees $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in build/htmlhelp." latex: mkdir -p build/latex build/doctrees $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex @echo @echo "Build finished; the LaTeX files are in build/latex." @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ "run these through (pdf)latex." changes: mkdir -p build/changes build/doctrees $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes @echo @echo "The overview file is in build/changes." linkcheck: mkdir -p build/linkcheck build/doctrees $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in build/linkcheck/output.txt." python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/MANIFEST.in0000644000175000017500000000034711140634065025055 0ustar zackzackinclude README.txt include VERSION.txt include MANIFEST.in recursive-include docs * prune docs/build recursive-include repoze * recursive-exclude tests * recursive-exclude test_elixir * global-exclude *~ *.pyc *.egg .directory python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/setup.py0000644000175000017500000000451611140640312025023 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2007, Agendaless Consulting and Contributors. # Copyright (c) 2008, Florent Aide . # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## import os from ez_setup import use_setuptools use_setuptools() from setuptools import setup, find_packages here = os.path.abspath(os.path.dirname(__file__)) README = open(os.path.join(here, 'README.txt')).read() version = open(os.path.join(here, 'VERSION.txt')).readline().rstrip() setup(name='repoze.what.plugins.sql', version=version, description=('The repoze.what SQL plugin'), long_description=README, classifiers=[ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Intended Audience :: Developers", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Database", "Topic :: Internet :: WWW/HTTP :: WSGI", "Topic :: Security" ], keywords='web application wsgi server wsgi sql sqlalchemy elixir '\ 'authorization repoze', author='Gustavo Narea', author_email='repoze-dev@lists.repoze.org', namespace_packages = ['repoze', 'repoze.what', 'repoze.what.plugins'], url='http://code.gustavonarea.net/repoze.what.plugins.sql/', license='BSD-derived (http://www.repoze.org/LICENSE.txt)', packages=find_packages(), include_package_data=True, zip_safe=False, tests_require=['repoze.what', 'sqlalchemy >= 0.5', 'coverage', 'nose'], install_requires=[ 'repoze.what >= 1.0.3', 'sqlalchemy >= 0.5', ], test_suite='nose.collector', entry_points = """\ """ ) python-repoze.what-plugins-20090531/repoze.what.plugins.sql-1.0rc1/setup.cfg0000644000175000017500000000053211140640730025130 0ustar zackzack[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 [nosetests] cover-erase = 1 verbose = 1 cover-package = repoze.what.plugins.sql verbosity = 1 with-coverage = 1 detailed-errors = 1 no-path-adjustment = 1 testmatch = ^(tests|test_.*)$ with-doctest = 1 where = tests [aliases] release = egg_info -rDb "" sdist bdist_egg register upload python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/0000755000175000017500000000000011163724045021754 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/README.txt0000644000175000017500000000121711144101154023440 0ustar zackzack********************************************* The repoze.what plugin for Pylons integration ********************************************* This is an extras plugin for repoze.what which provides optional and handy utilities for Pylons applications using this authorization framework. Some of the features of the plugin include: * The utilities are ready to use: There's nothing additional to be configured before using. * 100% documented. Each component is documented along with code samples. * The test suite has a coverage of 100% and it will never decrease -- if it ever does, report it as a bug! * TurboGears 2 is officially supported as well. python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze.what_pylons.egg-info/0000755000175000017500000000000011163724045027320 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze.what_pylons.egg-info/requires.txt0000644000175000017500000000006511163724045031721 0ustar zackzackrepoze.what >= 1.0.4 Pylons >= 0.9.7 decorator >= 3.0././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze.what_pylons.egg-info/namespace_packages.txtpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze.what_pylons.egg-info/namespace_pac0000644000175000017500000000004711163724045032023 0ustar zackzackrepoze repoze.what repoze.what.plugins ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze.what_pylons.egg-info/dependency_links.txtpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze.what_pylons.egg-info/dependency_li0000644000175000017500000000000111163724045032034 0ustar zackzack python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze.what_pylons.egg-info/PKG-INFO0000644000175000017500000000314111163724045030414 0ustar zackzackMetadata-Version: 1.0 Name: repoze.what-pylons Version: 1.0 Summary: The repoze.what v1 plugin for Pylons/TG2 integration Home-page: http://code.gustavonarea.net/repoze.what-pylons/ Author: Gustavo Narea Author-email: repoze-dev@lists.repoze.org License: BSD-derived (http://www.repoze.org/LICENSE.txt) Description: ********************************************* The repoze.what plugin for Pylons integration ********************************************* This is an extras plugin for repoze.what which provides optional and handy utilities for Pylons applications using this authorization framework. Some of the features of the plugin include: * The utilities are ready to use: There's nothing additional to be configured before using. * 100% documented. Each component is documented along with code samples. * The test suite has a coverage of 100% and it will never decrease -- if it ever does, report it as a bug! * TurboGears 2 is officially supported as well. Keywords: web application wsgi server pylons turbogears authorization repoze Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Framework :: Pylons Classifier: Framework :: TurboGears Classifier: Intended Audience :: Developers Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Database Classifier: Topic :: Internet :: WWW/HTTP :: WSGI Classifier: Topic :: Security ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze.what_pylons.egg-info/entry_points.txtpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze.what_pylons.egg-info/entry_points.0000644000175000017500000000000611163724045032052 0ustar zackzack ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze.what_pylons.egg-info/top_level.txtpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze.what_pylons.egg-info/top_level.txt0000644000175000017500000000001511163724045032046 0ustar zackzackrepoze tests python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze.what_pylons.egg-info/not-zip-safe0000644000175000017500000000000111143573677031561 0ustar zackzack python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze.what_pylons.egg-info/SOURCES.txt0000644000175000017500000000160111163724045031202 0ustar zackzackMANIFEST.in README.txt VERSION.txt ez_setup.py setup.cfg setup.py docs/Makefile docs/source/API.rst docs/source/News.rst docs/source/conf.py docs/source/index.rst docs/source/Manual/GettingStarted.rst docs/source/Manual/Misc.rst docs/source/Manual/Protecting.rst docs/source/Manual/index.rst docs/source/_static/logo_hi.gif docs/source/_static/repoze.css repoze/__init__.py repoze.what_pylons.egg-info/PKG-INFO repoze.what_pylons.egg-info/SOURCES.txt repoze.what_pylons.egg-info/dependency_links.txt repoze.what_pylons.egg-info/entry_points.txt repoze.what_pylons.egg-info/namespace_packages.txt repoze.what_pylons.egg-info/not-zip-safe repoze.what_pylons.egg-info/requires.txt repoze.what_pylons.egg-info/top_level.txt repoze/what/__init__.py repoze/what/plugins/__init__.py repoze/what/plugins/pylonshq/__init__.py repoze/what/plugins/pylonshq/protectors.py repoze/what/plugins/pylonshq/utils.pypython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze/0000755000175000017500000000000011163724045023260 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze/__init__.py0000644000175000017500000000164211143561361025372 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze/what/0000755000175000017500000000000011163724045024223 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze/what/__init__.py0000644000175000017500000000164111143561367026342 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze/what/plugins/0000755000175000017500000000000011163724045025704 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze/what/plugins/pylonshq/0000755000175000017500000000000011163724045027561 5ustar zackzack././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze/what/plugins/pylonshq/protectors.pypython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze/what/plugins/pylonshq/protectors.p0000644000175000017500000001461011153561230032142 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## """ Decorators to control access to controllers and controller actions in a Pylons or TurboGears 2 application. All these utilities are also available in the :mod:`repoze.what.plugins.pylonshq` namespace. """ import inspect import new from decorator import decorator from pylons import request, response from pylons.controllers.util import abort from repoze.what.predicates import NotAuthorizedError __all__ = ['ActionProtector', 'ControllerProtector'] class _BaseProtectionDecorator(object): default_denial_handler = None def __init__(self, predicate, denial_handler=None): """ Make :mod:`repoze.what` verify that the predicate is met. :param predicate: A :mod:`repoze.what` predicate. :param denial_handler: The callable to be run if authorization is denied (overrides :attr:`default_denial_handler` if defined). If called, ``denial_handler`` will be passed a positional argument which represents a message on why authorization was denied. """ self.predicate = predicate self.denial_handler = denial_handler or self.default_denial_handler class ActionProtector(_BaseProtectionDecorator): """ Function decorator to set predicate checkers in Pylons/TG2 controller actions. .. attribute:: default_denial_handler = None :type: callable The default denial handler. """ def __call__(self, action_): """ Return :meth:`wrap_action` as the decorator for ``action_``. """ return decorator(self.wrap_action, action_) def wrap_action(self, action_, *args, **kwargs): """ Wrap the controller action ``action_``. :param action_: The controller action to be wrapped. ``args`` and ``kwargs`` are the positional and named arguments which will be passed to ``action_`` when called. It will run ``action_`` if and only if authorization is granted (i.e., the predicate is met). Otherwise, it will set the HTTP status code (to 401 if the user is anonymous or 403 if authenticated) then, if defined, it will run the denial handler (if not, it will abort with :func:`pylons.controllers.util.abort`). It's worth noting that when the status code for the response is 401, that will trigger a :mod:`repoze.who` challenger (e.g., a login form will be displayed). .. note:: If you want to override the default behavior when authorization is denied (most likely), you should define just a denial handler. If you want to override the whole wrapper (very unlikely), it's safe to extend this class and override this method. """ try: self.predicate.check_authorization(request.environ) except NotAuthorizedError, e: reason = unicode(e) if request.environ.get('repoze.who.identity'): # The user is authenticated. code = 403 else: # The user is not authenticated. code = 401 if self.denial_handler: response.status = code return self.denial_handler(reason) abort(code, comment=reason) return action_(*args, **kwargs) class ControllerProtector(_BaseProtectionDecorator): """ Class decorator to set predicate checkers in Pylons/TG2 controllers. .. attribute:: default_denial_handler = None :type: callable or str The default denial handler to be passed to :attr:`protector`. When it's set as a string, the resulting handler will be the attribute of the controller class whose name is represented by ``default_denial_handler``. For example, if ``default_denial_handler`` equals ``"process_errors"`` and the decorated controller is ``NiceController``, the resulting denial handler will be: ``NiceController.process_errors``. .. attribute:: protector = ActionProtector :type: Subclass of :class:`ActionProtector` The action protection decorator to be added to ``Controller.__before__``. """ protector = ActionProtector def __call__(self, cls): """ Add the :attr:`protector` decorator to the ``__before__`` method of the ``cls`` controller. """ if inspect.isclass(cls): return self.decorate_class(cls) else: return self.decorate_instance(cls) def decorate_instance(self, obj): """Decorate the ``__before__`` method of a class instance.""" cls = obj.__class__ new_before = self.make_wrapped_method(cls) obj.__before__ = new.instancemethod(new_before, obj, cls) return obj def decorate_class(self, cls): """Decorate the ``__before__`` method of a class.""" cls.__before__ = self.make_wrapped_method(cls) return cls def make_wrapped_method(self, cls): """Decorate the ``__before__`` method with the defined protector""" if callable(self.denial_handler) or self.denial_handler is None: denial_handler = self.denial_handler else: denial_handler = getattr(cls, self.denial_handler) if hasattr(cls, '__before__'): old_before = cls.__before__.im_func else: def old_before(*args, **kwargs): pass old_before.__name__ = '__before__' protector = self.protector(self.predicate, denial_handler) return protector(old_before) python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze/what/plugins/pylonshq/utils.py0000644000175000017500000000437311157506126031303 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## """ Miscellaneous utilities for :mod:`repoze.what` when used in a Pylons application. """ from pylons import request from repoze.what.predicates import Predicate __all__ = ['is_met', 'not_met', 'booleanize_predicates', 'debooleanize_predicates'] #{ Evaluators def is_met(predicate): """ Evaluate the :mod:`repoze.what` ``predicate`` checker and return ``True`` if it's met. :param predicate: The :mod:`repoze.what` predicate checker to be evaluated. :return: ``True`` if it's met; ``False`` otherwise. :rtype: bool """ return predicate.is_met(request.environ) def not_met(predicate): """ Evaluate the :mod:`repoze.what` ``predicate`` checker and return ``False`` if it's met. :param predicate: The :mod:`repoze.what` predicate checker to be evaluated. :return: ``False`` if it's met; ``True`` otherwise. :rtype: bool """ return not predicate.is_met(request.environ) #{ Booleanizers def booleanize_predicates(): """ Make :mod:`repoze.what` predicates evaluable without passing the ``environ`` explicitly. .. warning:: The use of this function is **strongly discouraged**. Use :func:`is_met` or :func:`not_met` instead. """ Predicate.__nonzero__ = lambda self: self.is_met(request.environ) def debooleanize_predicates(): """ Stop :mod:`repoze.what` predicates from being evaluable without passing the ``environ`` explicitly. This function reverts :func:`booleanize_predicates`. """ del Predicate.__nonzero__ #} python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze/what/plugins/pylonshq/__init__.py0000644000175000017500000000246011157476005031677 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## """ Utilities to use :mod:`repoze.what` v1 in a Pylons or TurboGears 2 application. """ # Let's make all the utilities available in this namespace: from repoze.what.plugins.pylonshq.utils import booleanize_predicates, \ debooleanize_predicates, \ is_met, not_met from repoze.what.plugins.pylonshq.protectors import ActionProtector, \ ControllerProtector __all__ = ['ActionProtector', 'ControllerProtector', 'booleanize_predicates', 'debooleanize_predicates', 'is_met', 'not_met'] python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/repoze/what/plugins/__init__.py0000644000175000017500000000172311143561405030015 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## """Special namespace for repoze.what plugins.""" # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/PKG-INFO0000644000175000017500000000314111163724045023050 0ustar zackzackMetadata-Version: 1.0 Name: repoze.what-pylons Version: 1.0 Summary: The repoze.what v1 plugin for Pylons/TG2 integration Home-page: http://code.gustavonarea.net/repoze.what-pylons/ Author: Gustavo Narea Author-email: repoze-dev@lists.repoze.org License: BSD-derived (http://www.repoze.org/LICENSE.txt) Description: ********************************************* The repoze.what plugin for Pylons integration ********************************************* This is an extras plugin for repoze.what which provides optional and handy utilities for Pylons applications using this authorization framework. Some of the features of the plugin include: * The utilities are ready to use: There's nothing additional to be configured before using. * 100% documented. Each component is documented along with code samples. * The test suite has a coverage of 100% and it will never decrease -- if it ever does, report it as a bug! * TurboGears 2 is officially supported as well. Keywords: web application wsgi server pylons turbogears authorization repoze Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Framework :: Pylons Classifier: Framework :: TurboGears Classifier: Intended Audience :: Developers Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Database Classifier: Topic :: Internet :: WWW/HTTP :: WSGI Classifier: Topic :: Security python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/VERSION.txt0000644000175000017500000000000311163723366023640 0ustar zackzack1.0python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/ez_setup.py0000644000175000017500000002231311143557642024172 0ustar zackzack#!python """Bootstrap setuptools installation If you want to use setuptools in your package's setup.py, just include this file in the same directory with it, and add this to the top of your setup.py:: from ez_setup import use_setuptools use_setuptools() If you want to require a specific version of setuptools, set a download mirror, or use an alternate download directory, you can do so by supplying the appropriate options to ``use_setuptools()``. This file can also be run as a script to install or upgrade setuptools. """ import sys DEFAULT_VERSION = "0.6c8" DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3] md5_data = { 'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca', 'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb', 'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b', 'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a', 'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618', 'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac', 'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5', 'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4', 'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c', 'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b', 'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27', 'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277', 'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa', 'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e', 'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e', 'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f', 'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2', 'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc', 'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167', 'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64', 'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d', 'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20', 'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab', 'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53', 'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2', 'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e', 'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372', 'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902', 'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de', 'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b', } import sys, os def _validate_md5(egg_name, data): if egg_name in md5_data: from md5 import md5 digest = md5(data).hexdigest() if digest != md5_data[egg_name]: print >>sys.stderr, ( "md5 validation of %s failed! (Possible download problem?)" % egg_name ) sys.exit(2) return data def use_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, download_delay=15 ): """Automatically find/download setuptools and make it available on sys.path `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where setuptools will be downloaded, if it is not already available. If `download_delay` is specified, it should be the number of seconds that will be paused before initiating a download, should one be required. If an older version of setuptools is installed, this routine will print a message to ``sys.stderr`` and raise SystemExit in an attempt to abort the calling script. """ was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules def do_download(): egg = download_setuptools(version, download_base, to_dir, download_delay) sys.path.insert(0, egg) import setuptools; setuptools.bootstrap_install_from = egg try: import pkg_resources except ImportError: return do_download() try: pkg_resources.require("setuptools>="+version); return except pkg_resources.VersionConflict, e: if was_imported: print >>sys.stderr, ( "The required version of setuptools (>=%s) is not available, and\n" "can't be installed while this script is running. Please install\n" " a more recent version first, using 'easy_install -U setuptools'." "\n\n(Currently using %r)" ) % (version, e.args[0]) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok return do_download() except pkg_resources.DistributionNotFound: return do_download() def download_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay = 15 ): """Download setuptools from a specified location and return its filename `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the number of seconds to pause before an actual download attempt. """ import urllib2, shutil egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3]) url = download_base + egg_name saveto = os.path.join(to_dir, egg_name) src = dst = None if not os.path.exists(saveto): # Avoid repeated downloads try: from distutils import log if delay: log.warn(""" --------------------------------------------------------------------------- This script requires setuptools version %s to run (even to display help). I will attempt to download it for you (from %s), but you may need to enable firewall access for this script first. I will start the download in %d seconds. (Note: if this machine does not have network access, please obtain the file %s and place it in this directory before rerunning this script.) ---------------------------------------------------------------------------""", version, download_base, delay, url ); from time import sleep; sleep(delay) log.warn("Downloading %s", url) src = urllib2.urlopen(url) # Read/write all in one block, so we don't create a corrupt file # if the download is interrupted. data = _validate_md5(egg_name, src.read()) dst = open(saveto,"wb"); dst.write(data) finally: if src: src.close() if dst: dst.close() return os.path.realpath(saveto) def main(argv, version=DEFAULT_VERSION): """Install or upgrade setuptools and EasyInstall""" try: import setuptools except ImportError: egg = None try: egg = download_setuptools(version, delay=0) sys.path.insert(0,egg) from setuptools.command.easy_install import main return main(list(argv)+[egg]) # we're done here finally: if egg and os.path.exists(egg): os.unlink(egg) else: if setuptools.__version__ == '0.0.1': print >>sys.stderr, ( "You have an obsolete version of setuptools installed. Please\n" "remove it from your system entirely before rerunning this script." ) sys.exit(2) req = "setuptools>="+version import pkg_resources try: pkg_resources.require(req) except pkg_resources.VersionConflict: try: from setuptools.command.easy_install import main except ImportError: from easy_install import main main(list(argv)+[download_setuptools(delay=0)]) sys.exit(0) # try to force an exit else: if argv: from setuptools.command.easy_install import main main(argv) else: print "Setuptools version",version,"or greater has been installed." print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)' def update_md5(filenames): """Update our built-in md5 registry""" import re from md5 import md5 for name in filenames: base = os.path.basename(name) f = open(name,'rb') md5_data[base] = md5(f.read()).hexdigest() f.close() data = [" %r: %r,\n" % it for it in md5_data.items()] data.sort() repl = "".join(data) import inspect srcfile = inspect.getsourcefile(sys.modules[__name__]) f = open(srcfile, 'rb'); src = f.read(); f.close() match = re.search("\nmd5_data = {\n([^}]+)}", src) if not match: print >>sys.stderr, "Internal error!" sys.exit(2) src = src[:match.start(1)] + repl + src[match.end(1):] f = open(srcfile,'w') f.write(src) f.close() if __name__=='__main__': if len(sys.argv)>2 and sys.argv[1]=='--md5update': update_md5(sys.argv[2:]) else: main(sys.argv[1:]) python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/docs/0000755000175000017500000000000011163724045022704 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/docs/source/0000755000175000017500000000000011163724045024204 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/docs/source/News.rst0000644000175000017500000000562411163723263025662 0ustar zackzack******************************* **repoze.what-pylons** releases ******************************* This document describes the releases of :mod:`repoze.what.plugins.pylonshq`. .. _1.0: **repoze.what-pylons** 1.0 (2009-03-29) ======================================= * Fixed some typos in the documentation thanks to Binet Bruno. .. _1.0rc4: **repoze.what-pylons** 1.0rc4 (2009-03-16) ========================================== * Added a couple of trivial functions: :func:`is_met ` and :func:`not_met `. * Added warnings on why "predicate booleanizers" should be avoided by all means. .. _1.0rc3: **repoze.what-pylons** 1.0rc3 (2009-03-04) ========================================== * :class:`repoze.what.plugins.pylonshq.ControllerProtector` didn't support class instances. Fixed thanks to Alberto Valverde and Christopher Perkins! * Functional test suite ported to **repoze.who-testutil** to ease maintenance. * Documentation enhancements. .. _1.0rc2: **repoze.what-pylons** 1.0rc2 (2009-02-20) ========================================== * This plugin requires ``decorator`` v3.0 or better, but no minimum version was required. Reported by Binet Bruno. .. _1.0rc1: **repoze.what-pylons** 1.0rc1 (2009-02-19) ========================================== * Now :mod:`repoze.what` predicates can be evaluated without passing the ``environ`` explicitly, thanks to :func:`repoze.what.plugins.pylonshq.booleanize_predicates`. This *magical* functionality can be disabled with :func:`repoze.what.plugins.pylonshq.debooleanize_predicates`. .. _1.0b3: **repoze.what-pylons** 1.0b3 (2009-02-16) ========================================= * Now :class:`repoze.what.plugins.pylonshq.ActionProtector` is a signature preserving decorator. This means that now Pylons users can have positional and named arguments in their controller actions. .. _1.0b2: **repoze.what-pylons** 1.0b2 (2009-02-11) ========================================= * The :class:`repoze.what.plugins.pylonshq.ActionProtector` decorator made the decorated function ignore its decorators defined after ``@ActionProtector``. Thanks to Florent Aide and Alberto Valverde for finding the bug and proposing the solution, respectively. .. _1.0b1: **repoze.what-pylons** 1.0b1 (2009-02-09) ========================================= This is the first release of **repoze.what-pylons** as an independent project. Much of the initial functionality has been taken from the `TurboGears v2.0 project `_. * Created a decorator similar to the former TurboGears' ``@require``, but improved: :class:`repoze.what.plugins.pylonshq.ActionProtector`. As of TurboGears v2.0b6, its ``@require`` decorator is a subclass of this decorator. * Introduced the class decorator for controller-wide authorization :class:`repoze.what.plugins.pylonshq.ControllerProtector`. python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/docs/source/API.rst0000644000175000017500000000106611157504555025357 0ustar zackzack***************************************************** :mod:`repoze.what.plugins.pylonshq` API documentation ***************************************************** .. automodule:: repoze.what.plugins.pylonshq Protectors ========== .. autoclass:: ActionProtector :members: __init__, __call__, wrap_action .. autoclass:: ControllerProtector :members: __init__, __call__ Miscellaneous utilities ======================= .. autofunction:: is_met .. autofunction:: not_met .. autofunction:: booleanize_predicates .. autofunction:: debooleanize_predicates python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/docs/source/_static/0000755000175000017500000000000011163724045025632 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/docs/source/_static/repoze.css0000644000175000017500000000047411143557642027662 0ustar zackzack@import url('default.css'); body { background-color: #006339; } div.document { background-color: #dad3bd; } div.sphinxsidebar h3,h4,h5,li,a { color: #127c56 !important; } div.related { color: #dad3bd !important; background-color: #00744a; } div.related a { color: #dad3bd !important; } python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/docs/source/_static/logo_hi.gif0000644000175000017500000000777611143557642027767 0ustar zackzackGIF89a4polܵEEE999VVUŪ؉ǼʤჂ򠞙dcaRRQ]\\{zx???MLL444333!,4@pH,Ȥrl:Ш@Zجvzxl-z|~su2WfoTe`UXboef :7=Óʋ<Ϥ5)ݳ߼˿ڶܾՎ΢55=C!ѷm+M>o6dtu._ݘUn>؟3:XfC`[0/h uCP![ W d(]"Xr_ 9"#2dwHe.zآ0]Z}7L PeI8tO aiCÃ WI -*蠄ozXv@5 @d "^0e80ݪ&p"|Cnk, 06,w)>jjwiɂ< ɂ:p +[8th k(8,#h,,/U"CPCg Z6 滲˙2宐A:Ё|{J/ B ؁Pp ZP p MK C,( g l| !p'| T)Prª P t5:z|pBX*R3( D-,. A'G, @8 @A*H@>P ql+0 䯀t)T>P`&(0,=#@V`?-;h_S܃ŭqWuo @/S^&  gZUG >B^EZUmyUk-}T0]w~;ܙ9%pquxO0 h07]- K-[^`q< ]rCyPb6Gy$a>p(%%@$g- }ǀ;%y'?rgy<2Tk=>Ng~'@S2D1\4l#px(w\i׀eBxx42-%eT\?05Ph>(}`(&u$`x/"r(^@6†Vz#ehy)iVhKng(`NHz!wB.  gx%d؉mȆl\e-7p_}4z!<`P#K`h~v,0\e `74(;0H9Ȇ<8،<@1#@։T9l(؎8mȆ $ LC9'J(.`KP hs3`"#׎yS:Y: 92`X`Yh ن0i2i 0m20UTYX`FC3Xo:HXyLB7. QI׋ 0dYfy)B gpr9tYtȗ~)|Xr(RV؄ 2xMxu2yuWɈZə捔ق闫W)B8^hBy)iXyiZHz¨I py1|?P雿Iٙy Ti PTK#p:ZP`a)zzEɚ  p?2UĢâ-j-ꓮB2/:1:= pq)@9>)U.ZFKKʣ>:0ڢ,60%ʥ#$b1P3Хɥ]٦Ӷ>ijkm 0 `U+mJ  l*djjr*A7ॆj v DGiZ$b905- :J** jJ*KfK jm2x=ښrʬJšjZ ׮*:ʩk8گʮ#Gڊ{7P0hzʮ:zK = 4 y<2=7U, M9P1:˳> +@+;KE۳@;LۮO۴NS[L[P;\XO+W;efac[\K]kR Y;python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/docs/source/index.rst0000644000175000017500000000307611144076521026051 0ustar zackzack**************************************************** The :mod:`repoze.what` plugin for Pylons integration **************************************************** :Author: Gustavo Narea. :Latest release: |release| .. module:: repoze.what.plugins.pylons :synopsis: Authorization with repoze.what in Pylons applications .. moduleauthor:: Gustavo Narea .. topic:: Overview This plugin provides optional and handy utilities for Pylons applications using :mod:`repoze.what`. Some of the features of the plugin include: * The utilities are ready to use: There's nothing additional to be configured before using. * 100% documented. Each component is documented along with code samples. * The test suite has a coverage of 100% and it will never decrease -- if it ever does, report it as a bug! * `TurboGears 2 `_ is officially supported as well. Documentation ============= .. toctree:: :maxdepth: 3 Manual/index API Support and development ======================= The prefered place to ask questions is the `Repoze mailing list `_ or the `#repoze `_ IRC channel. Bugs reports and feature requests should be sent to `the issue tracker of the Repoze project `_. The development mainline is available at the following Subversion repository:: http://svn.repoze.org/repoze.what/plugins/pylons/trunk/ Releases -------- .. toctree:: :maxdepth: 2 News python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/docs/source/Manual/0000755000175000017500000000000011163724045025421 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what-pylons-1.0/docs/source/Manual/GettingStarted.rst0000644000175000017500000000135611144056042031102 0ustar zackzack*************** Getting started *************** Overview ======== To use any of the utilities of this plugin it's not necessary to configure anything additional to :mod:`repoze.what` itself. You can use some or all of its components independently as well. How to install ============== *Once you have at least Pylons or TurboGears 2 installed*, run the following command to install this plugin: .. code-block:: bash $ easy_install repoze.what-pylons If you have not installed Pylons or TurboGears 2 yet, install one of them first and then run the command above: * `Installing Pylons `_. * `Installing TurboGears 2 `_. python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/docs/source/Manual/index.rst0000644000175000017500000000036411147066144027266 0ustar zackzack**************************************** The **repoze.what-pylons** Users' Manual **************************************** :Author: Gustavo Narea. :Version: |version| .. toctree:: :maxdepth: 3 GettingStarted Protecting Misc python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/docs/source/Manual/Protecting.rst0000644000175000017500000002171611153511717030277 0ustar zackzack********************************************* Protecting controllers and controller actions ********************************************* .. topic:: Overview This plugin provides decorators to add access rules to controllers and controller actions, which have been created with extensibility in mind so that you can adapt them to suit your needs. Protecting a controller action ============================== To set controller-wide access rules, you can use the :class:`ActionProtector ` class decorator as in the example below:: from repoze.what.predicates import has_permission from repoze.what.plugins.pylonshq import ActionProtector class RootController(YourBaseController): # Place an expose() here if you use TG2 def index(self): return nice_function_to_do_nothing() # Place an expose() here if you use TG2 @ActionProtector(has_permission('edit-articles')) def edit_article(self, article_id): return get_article_edition_form(article_id) With the controller and action controllers above, anyone who tries to access ``/edit_article`` will have to be granted the ``edit-articles`` permission. Otherwise, authorization will be denied. .. tip:: TurboGears 2 provides the :class:`tg.require` decorator to set the access rules in controller actions, which is a subclass of :class:`ActionProtector ` with additional functionality specific to TG2 applications. Protecting a controller ======================= To set controller-wide access rules, you can use the :class:`ControllerProtector ` class decorator as in the example below:: from repoze.what.predicates import has_permission from repoze.what.plugins.pylonshq import ControllerProtector @ControllerProtector(has_permission('manage')) class ControlPanel(YourBaseController): # Place an expose() here if you use TG2 def index(self): return nice_function_to_do_nothing() # Place an expose() here if you use TG2 def delete_user(self, user_id): return nice_function_to_delete_a_user(user_id) class RootController(YourBaseController): panel = ControlPanel() # Place an expose() here if you use TG2 def index(self): return nice_function_to_do_nothing() With the controllers and action controllers above, anyone who tries to access ``/panel/*`` will have to be granted the ``manage`` permission. Otherwise, authorization will be denied. .. tip:: As of version 2.0b6, TurboGears provides the :class:`tg.allow_only` decorator for controller-wide authorization, which is a subclass of :class:`ControllerProtector ` with additional functionality specific to TG2 applications. .. note:: If you're using Python v2.4 or v2.5, you will have to use the alternate syntax because class decorators are supported as of Python v2.6:: class ControlPanel(YourBaseController): # ... pass ControlPanel = ControllerProtector(has_permission('manage'))(ControlPanel) Using denial handlers ===================== By default, an authorization denial triggers one of the following actions: * If the user is anonymous, :mod:`repoze.who` will perform a challenge (e.g., a login form will be displayed). * If the user is authenticated, a page whose HTTP status code is 403 will be served. If you want to override the default behavior when authorization is denied, you have define a so-called "denial handler". A denial handler is a callable which receives one positional argument (which is the message that describes why authorization is denied; this is, the relevant :mod:`repoze.what` predicate message) and is called only when authorization is denied. The following is a denial handler:: # This is yourapplication.anotherpackage from pylons import request, response from pylons.controllers.util import abort # nice_flash is a function that inserts a user-visible message in the # template from yourapplication.somepackage import nice_flash def cool_denial_handler(reason): # When this handler is called, response.status has two possible values: # 401 or 403. if response.status_int == 401: message = 'Oops, you have to login: %s' % reason message_type = 'warning' else: identity = request.environ['repoze.who.identity'] userid = identity['repoze.who.userid'] message = "Come on, %s, you know you can't do that: %s" % (userid, reason) message_type = 'error' nice_flash(message, message_type) abort(response.status_int, comment=reason) .. attention:: The denial handler above **must** call ``abort()``, otherwise we'd be granting access to the request denied by :mod:`repoze.what`. Note that this is a feature, not a bug: In some situations you may not want to abort (e.g., you may want to redirect). And you can use it as in:: from repoze.what.predicates import has_permission from repoze.what.plugins.pylonshq import ActionProtector, ControllerProtector from yourapplication.anotherpackage import cool_denial_handler @ControllerProtector(has_permission('manage'), cool_denial_handler) class ControlPanel(YourBaseController): # Place an expose() here if you use TG2 def index(self): return nice_function_to_do_nothing() # Place an expose() here if you use TG2 def delete_user(self, user_id): return nice_function_to_delete_a_user(user_id) class RootController(YourBaseController): panel = ControlPanel() # Place an expose() here if you use TG2 def index(self): return nice_function_to_do_nothing() # Place an expose() here if you use TG2 @ActionProtector(has_permission('edit-articles'), cool_denial_handler) def edit_article(self, article_id): return get_article_edition_form(article_id) Then, when authorization is denied: * If the user is anonymous, she should be served a web page which contains a login form and a message that starts with "Oops, you have to login (...)". The status code of such a response is up to the :mod:`repoze.who` challenger. * If the user is authenticated, she should be served a web page that contains a message that starts with "Come on, ``{{username}}``, you know (..)" and whose HTTP status code is 403. Creating application-specific protectors ======================================== Sometimes you may need to customize the controller and controller action protectors in many places within your application (or in the whole application). All you have to do is subclass the relevant protector. For example, if we use the ``cool_denial_handler`` function above very often, then we should create controller and controller action protectors which use that handler by default:: # This is yourapplication.yetanotherpackage from repoze.what.plugins.pylonshq import ActionProtector, ControllerProtector from yourapplication.anotherpackage import cool_denial_handler class CoolActionProtector(ActionProtector): default_denial_handler = staticmethod(cool_denial_handler) class CoolControllerProtector(ControllerProtector): protector = CoolActionProtector # The following is an alternate way to define CoolControllerProtector: # class CoolControllerProtector(ControllerProtector): # default_denial_handler = staticmethod(cool_denial_handler) Then our controllers would look like this:: from repoze.what.predicates import has_permission from yourapplication.yetanotherpackage import CoolActionProtector, \ CoolControllerProtector @CoolControllerProtector(has_permission('manage')) class ControlPanel(YourBaseController): # Place an expose() here if you use TG2 def index(self): return nice_function_to_do_nothing() # Place an expose() here if you use TG2 def delete_user(self, user_id): return nice_function_to_delete_a_user(user_id) class RootController(YourBaseController): panel = ControlPanel() # Place an expose() here if you use TG2 def index(self): return nice_function_to_do_nothing() # Place an expose() here if you use TG2 @CoolActionProtector(has_permission('edit-articles')) def edit_article(self, article_id): return get_article_edition_form(article_id) And every time authorization is denied, the ``cool_denial_handler`` function will be called. python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/docs/source/Manual/Misc.rst0000644000175000017500000000723211163722627027056 0ustar zackzack*********************** Miscellaneous utilities *********************** Because :mod:`repoze.what` is framework-independent, its predicates can only be evaluated if you pass the WSGI environ whenever you want to evaluate them. But to makes things easier, this plugin defines utilities to evaluate predicates without passing the environ explicitly: Predicate evaluators ==================== With :func:`repoze.what.plugins.pylonshq.is_met`, you'll be able to evaluate your predicates without passing the WSGI environ explicitly, as in: >>> from repoze.what.plugins.pylonshq import is_met >>> from repoze.what.predicates import is_user >>> is_met(is_user('gustavo')) # Will return True if the user is "gustavo" False instead of: >>> from pylons import request >>> from repoze.what.predicates import is_user >>> p = is_user('gustavo') >>> p.is_met(request.environ) # Will return True if the user is "gustavo" False If you want to evaluate the opposite, that it's not met, you can use :func:`not_met ` instead: >>> from repoze.what.plugins.pylonshq import not_met >>> from repoze.what.predicates import is_user >>> not_met(is_user('gustavo')) # Will return True if the user isn't "gustavo" True instead of: >>> from pylons import request >>> from repoze.what.predicates import is_user >>> p = is_user('gustavo') >>> not p.is_met(request.environ) # Will return True if the user isn't "gustavo" True Boolean predicates ================== .. warning:: This functionality was implemented by popular demand, but it's **strongly discouraged** by the author of :mod:`repoze.what` because it's a monkey-patch which brings serious side-effects when enabled: 1. Third-party components which handle :mod:`repoze.what` predicates may get erroneous values after evaluating a predicate checker (even if they don't use this functionality!). 2. If another non-Pylons-based application uses the same monkey-patch and you mount it on your application (or vice versa), the predicates used by both application will share the same WSGI environ. In the two scenarios above, **it will lead to serious security flaws**. So *avoid it by all means!* Use `predicate evaluators`_ instead. :func:`repoze.what.plugins.pylonshq.booleanize_predicates` allows you to use predicate checkers like boolean variables. Once you call it, you'll be able to evaluate your predicates without passing the environ:: >>> from repoze.what.predicates import not_anonymous >>> p = non_anonymous() >>> bool(p) # Will return False if the user is anonymous; True otherwise False instead of:: >>> from pylons import request >>> from repoze.what.predicates import not_anonymous >>> p = non_anonymous() >>> p.is_met(request.environ) # Will return False if the user is anonymous; True otherwise False Keep in mind that you don't have to call this function multiple times -- once is enough. For example, you could call it in the function where you set up the application in ``{pylonsproject}.config.middleware``:: # (...) from repoze.what.plugins.pylonshq import booleanize_predicates # (...) def make_app(global_conf, full_stack=True, **app_conf): # (...) booleanize_predicates() # (...) return app .. tip:: If you ever need to disable this "magical" behavior, you should use :func:`repoze.what.plugins.pylonshq.debooleanize_predicates`. .. note:: **TurboGears 2 users:** TG calls this function for you, unless you disabled the default auth mechanism in ``{tg2application}.config.app_cfg``. python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/docs/source/conf.py0000644000175000017500000001373611144043137025510 0ustar zackzack# -*- coding: utf-8 -*- # # repoze.what documentation build configuration file, created by # sphinx-quickstart on Mon Nov 10 20:27:30 2008. # # This file is execfile()d with the current directory set to its containing dir. # # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleable (module imports are okay, they're removed automatically). # # All configuration values have a default value; values that are commented out # serve to show the default value. import sys, os here = os.path.dirname(os.path.abspath(__file__)) root = os.path.dirname(os.path.dirname(here)) # If setting up the auto(module|class) functionality: sys.path.append(os.path.abspath(root)) wd = os.getcwd() os.chdir(root) os.system('%s setup.py test -q' % sys.executable) os.chdir(wd) for item in os.listdir(root): if item.endswith('.egg'): sys.path.append(os.path.join(root, item)) # General configuration # --------------------- extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General substitutions. project = u'repoze.what utilities for Pylons applications' copyright = u'2009, The Repoze Project' # The default replacements for |version| and |release|, also used in various # other places throughout the built documents. # # The short X.Y version. version = '1.0' # The full version, including alpha/beta/rc tags. release = open(os.path.join(root, 'VERSION.txt')).readline().rstrip() # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build. #unused_docs = [] # List of directories, relative to source directories, that shouldn't be searched # for source files. exclude_trees = [] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # Options for HTML output # ----------------------- # The style sheet to use for HTML and HTML Help pages. A file of that name # must exist either in Sphinx' static/ path, or in one of the custom paths # given in html_static_path. html_style = 'repoze.css' # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. html_logo = '_static/logo_hi.gif' # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_use_modindex = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, the reST sources are included in the HTML build as _sources/. #html_copy_source = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = '' # Output file base name for HTML help builder. htmlhelp_basename = 'repozewhatpylonsdoc' # Options for LaTeX output # ------------------------ # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, document class [howto/manual]). latex_documents = [ ('index', 'repozewhatpylons.tex', u'repoze.what utilities for Pylons Documentation', u'Gustavo Narea', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_use_modindex = True intersphinx_mapping = { #'http://turbogears.org/2.0/docs/': None, 'http://www.pylonshq.com/docs/en/0.9.7/': None, 'http://static.repoze.org/whatdocs/': None, } python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/docs/Makefile0000644000175000017500000000431311143557642024352 0ustar zackzack# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source .PHONY: help clean html web pickle htmlhelp latex changes linkcheck help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " pickle to make pickle files (usable by e.g. sphinx-web)" @echo " htmlhelp to make HTML files and a HTML help project" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " changes to make an overview over all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" clean: -rm -rf build/* html: mkdir -p build/html build/doctrees $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html @echo @echo "Build finished. The HTML pages are in build/html." pickle: mkdir -p build/pickle build/doctrees $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle @echo @echo "Build finished; now you can process the pickle files or run" @echo " sphinx-web build/pickle" @echo "to start the sphinx-web server." web: pickle htmlhelp: mkdir -p build/htmlhelp build/doctrees $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in build/htmlhelp." latex: mkdir -p build/latex build/doctrees $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex @echo @echo "Build finished; the LaTeX files are in build/latex." @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ "run these through (pdf)latex." changes: mkdir -p build/changes build/doctrees $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes @echo @echo "The overview file is in build/changes." linkcheck: mkdir -p build/linkcheck build/doctrees $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in build/linkcheck/output.txt." python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/MANIFEST.in0000644000175000017500000000030711143557642023517 0ustar zackzackinclude README.txt include VERSION.txt include MANIFEST.in recursive-include docs * prune docs/build recursive-include repoze * recursive-exclude tests * global-exclude *~ *.pyc *.egg .directory python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/setup.py0000644000175000017500000000462511163723462023477 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## import os from ez_setup import use_setuptools use_setuptools() from setuptools import setup, find_packages here = os.path.abspath(os.path.dirname(__file__)) README = open(os.path.join(here, 'README.txt')).read() version = open(os.path.join(here, 'VERSION.txt')).readline().rstrip() setup(name='repoze.what-pylons', version=version, description=('The repoze.what v1 plugin for Pylons/TG2 integration'), long_description=README, classifiers=[ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Pylons", "Framework :: TurboGears", "Intended Audience :: Developers", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Database", "Topic :: Internet :: WWW/HTTP :: WSGI", "Topic :: Security" ], keywords='web application wsgi server pylons turbogears ' \ 'authorization repoze', author='Gustavo Narea', author_email='repoze-dev@lists.repoze.org', namespace_packages = ['repoze', 'repoze.what', 'repoze.what.plugins'], url='http://code.gustavonarea.net/repoze.what-pylons/', license='BSD-derived (http://www.repoze.org/LICENSE.txt)', packages=find_packages(), include_package_data=True, zip_safe=False, tests_require=[ 'repoze.what >= 1.0.5', 'coverage', 'nose', 'Pylons', 'TurboGears2 >= 2.0b5', ], install_requires=[ 'repoze.what >= 1.0.4', 'Pylons >= 0.9.7', 'decorator >= 3.0', ], test_suite='nose.collector', entry_points = """\ """ ) python-repoze.what-plugins-20090531/repoze.what-pylons-1.0/setup.cfg0000644000175000017500000000053511163724045023600 0ustar zackzack[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 [nosetests] cover-erase = 1 verbose = 1 cover-package = repoze.what.plugins.pylons verbosity = 1 with-coverage = 1 detailed-errors = 1 no-path-adjustment = 1 testmatch = ^(tests|test_.*)$ with-doctest = 1 where = tests [aliases] release = egg_info -rDb "" sdist bdist_egg register upload python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/0000755000175000017500000000000011140014417023305 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/tests/0000755000175000017500000000000011140014417024447 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/tests/fixture/0000755000175000017500000000000011140014417026135 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/tests/fixture/__init__.py0000644000175000017500000000134711137672303030265 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## """The test fixture for the repoze.what XML plugin"""python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/tests/fixture/permissions.xml0000644000175000017500000000054411121253416031240 0ustar zackzack python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/tests/fixture/groups.xml0000644000175000017500000000067411121273365030215 0ustar zackzack python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/tests/__init__.py0000644000175000017500000000134511137672303026575 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## """The test suite for the repoze.what XML plugin"""python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/tests/test_adapters.py0000644000175000017500000000577211137672303027710 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## """The test suite for the adapters in the repoze.what XML plugin""" import unittest, os from shutil import copy from repoze.what.adapters.testutil import GroupsAdapterTester, \ PermissionsAdapterTester from repoze.what.plugins.xml import XMLGroupsAdapter, XMLPermissionsAdapter here = os.path.abspath(os.path.dirname(__file__)) fixtures = os.path.join(here, 'fixture') class _BaseXmlAdapterTester(unittest.TestCase): """The base test case for the XML source adapters""" def _setup_xml_adapter(self): tmp_filename = self.filename + '.tmp' original = os.path.join(fixtures, self.filename) self.tmp_file = os.path.join(fixtures, tmp_filename) copy(original, self.tmp_file) # Setting up the XML adapter: self.adapter = self.adapter_class(self.tmp_file) def tearDown(self): os.remove(self.tmp_file) def test_open_file_works(self): open_file = open(self.tmp_file, 'rw+') adapter = self.adapter_class(open_file) adapter.create_section('i_dont_exist') open_file.close() def test_file_really_is_updated(self): sections = self.adapter.get_all_sections() self.adapter.create_section('helloworld') sections['helloworld'] = set() # Testing it with a new adapter: new_adapter = self.adapter_class(self.tmp_file) self.assertEqual(sections, new_adapter.get_all_sections()) def test_unicode_support(self): sections = self.adapter.get_all_sections() self.adapter.create_section(u'caraqueños') self.adapter.include_item(u'caraqueños', u'maría') class TestXMLGroupsAdapter(GroupsAdapterTester, _BaseXmlAdapterTester): """Test case for the XML group source adapter""" filename = 'groups.xml' adapter_class = XMLGroupsAdapter def setUp(self): super(TestXMLGroupsAdapter, self).setUp() self._setup_xml_adapter() class TestXMLPermissionsAdapter(PermissionsAdapterTester, _BaseXmlAdapterTester): """Test case for the XML permission source adapter""" filename = 'permissions.xml' adapter_class = XMLPermissionsAdapter def setUp(self): super(TestXMLPermissionsAdapter, self).setUp() self._setup_xml_adapter() python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/README.txt0000644000175000017500000000205711137671636025031 0ustar zackzack************************** The repoze.what XML plugin ************************** This is an adapters plugin for repoze.what. Supported source formats ======================== A sample group source may look like this: A sample permission source may look like this: python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze/0000755000175000017500000000000011140014417024611 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze/__init__.py0000644000175000017500000000164711137672303026744 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze/what/0000755000175000017500000000000011140014417025554 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze/what/__init__.py0000644000175000017500000000164711137672303027707 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze/what/plugins/0000755000175000017500000000000011140014417027235 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze/what/plugins/__init__.py0000644000175000017500000000164711137672303031370 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze/what/plugins/xml/0000755000175000017500000000000011140014417030035 5ustar zackzack././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze/what/plugins/xml/adapters.pypython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze/what/plugins/xml/adapters.0000644000175000017500000001775011137672461031672 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## """The repoze.what groups and permission adapters for XML sources""" from xml.dom.minidom import parse from repoze.what.adapters import BaseSourceAdapter, SourceError __all__ = ['XMLGroupsAdapter', 'XMLPermissionsAdapter'] class _BaseXMLAdapter(BaseSourceAdapter): """The base class for XML source adapters""" def __init__(self, file, **kwargs): """ Create an XML source adapter for ``file``. :param file: The path to the XML file or a :class:`file` object. :type file: ``str`` or ``file`` """ self.file = file self.document = parse(file) self.is_writable = True super(_BaseXMLAdapter, self).__init__(**kwargs) # The translations: self.section_tag = self.elements['section'] self.item_tag = self.elements['item'] # BaseSourceAdapter def _get_all_sections(self): sections = {} for section in self.document.getElementsByTagName(self.section_tag): section_name = section.getAttribute('name') items = set() for item in section.getElementsByTagName(self.item_tag): items.add(item.getAttribute('name')) sections[section_name] = items return sections # BaseSourceAdapter def _get_section_items(self, section): section_as_element = self._get_section_as_element(section) items = set() for item in section_as_element.getElementsByTagName(self.item_tag): items.add(item.getAttribute('name')) return items # BaseSourceAdapter def _include_items(self, section, items): section_as_element = self._get_section_as_element(section) for item in items: item_element = self.document.createElement(self.item_tag) item_element.setAttribute('name', item) section_as_element.appendChild(item_element) self._save() # BaseSourceAdapter def _exclude_items(self, section, items): section_as_element = self._get_section_as_element(section) for item in section_as_element.getElementsByTagName(self.item_tag): if item.getAttribute('name') in items: section_as_element.removeChild(item) self._save() # BaseSourceAdapter def _item_is_included(self, section, item_name): section_as_element = self._get_section_as_element(section) for item in section_as_element.getElementsByTagName(self.item_tag): if item.getAttribute('name') == item_name: return True return False # BaseSourceAdapter def _create_section(self, section): section_element = self.document.createElement(self.section_tag) section_element.setAttribute('name', section) self.document.documentElement.appendChild(section_element) self._save() # BaseSourceAdapter def _edit_section(self, section, new_section): section_as_element = self._get_section_as_element(section) section_as_element.setAttribute('name', new_section) self._save() # BaseSourceAdapter def _delete_section(self, section): section_as_element = self._get_section_as_element(section) self.document.documentElement.removeChild(section_as_element) self._save() # BaseSourceAdapter def _section_exists(self, section): section_as_element = self._get_section_as_element(section) return section_as_element is not None def _get_sections_of_item(self, item_name): sections = set() for section in self.document.getElementsByTagName(self.section_tag): for item in section.getElementsByTagName(self.item_tag): if item_name == item.getAttribute('name'): sections.add(section.getAttribute('name')) return sections def _get_section_as_element(self, section_name): for section in self.document.getElementsByTagName(self.section_tag): if section.getAttribute('name') == section_name: return section def _save(self): if hasattr(self.file, 'write'): writer = self.file else: writer = open(self.file, 'w') # The Node.writexml() method generates ugly output, that's why we do it # this way writer.write(self.document.toprettyxml(encoding='utf-8')) class XMLGroupsAdapter(_BaseXMLAdapter): """ The XML group source adapter. The ``file`` is the path to the XML-based group source or the :class:`file` object for such a file. Additional arguments will be passed to :class:`repoze.what.adapters.BaseSourceAdapter`. For example, if we have the following XML-based group source: .. code-block:: xml Then we can use its adapter like this:: >>> from repoze.what.plugins.xml.adapters import XMLGroupsAdapter >>> groups = XMLGroupsAdapter('tests/fixture/groups.xml') >>> groups.get_section_items('developers') set([u'rms', u'linus']) """ elements = { 'section': 'group', 'item': 'member' } # BaseSourceAdapter def _find_sections(self, credentials): userid = credentials['repoze.what.userid'] return self._get_sections_of_item(userid) class XMLPermissionsAdapter(_BaseXMLAdapter): """ The XML permission source adapter. The ``file`` is the path to the XML-based permission source or the :class:`file` object for such a file. Additional arguments will be passed to :class:`repoze.what.adapters.BaseSourceAdapter`. For example, if we have the following XML-based permission source: .. code-block:: xml Then we can use its adapter like this: >>> from repoze.what.plugins.xml.adapters import XMLPermissionsAdapter >>> permissions = XMLPermissionsAdapter('tests/fixture/permissions.xml') >>> permissions.get_section_items('edit-site') set([u'admins', u'developers']) """ elements = { 'section': 'permission', 'item': 'group' } # BaseSourceAdapter def _find_sections(self, group): return self._get_sections_of_item(group) ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze/what/plugins/xml/__init__.pypython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze/what/plugins/xml/__init__.0000644000175000017500000000153211137672303031610 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea . # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## """The repoze.what XML plugin.""" from repoze.what.plugins.xml.adapters import XMLGroupsAdapter, \ XMLPermissionsAdapter python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/PKG-INFO0000644000175000017500000000375711140014417024416 0ustar zackzackMetadata-Version: 1.0 Name: repoze.what.plugins.xml Version: 1.0rc1 Summary: The repoze.what XML plugin Home-page: http://code.gustavonarea.net/repoze.what.plugins.xml/ Author: Gustavo Narea Author-email: repoze-dev@lists.repoze.org License: BSD-derived (http://www.repoze.org/LICENSE.txt) Description: ************************** The repoze.what XML plugin ************************** This is an adapters plugin for repoze.what. Supported source formats ======================== A sample group source may look like this: A sample permission source may look like this: Keywords: web application server wsgi xml authorization repoze Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Internet :: WWW/HTTP :: WSGI Classifier: Topic :: Security Classifier: Topic :: Text Processing :: Markup :: XML python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/VERSION.txt0000644000175000017500000000000611137672022025177 0ustar zackzack1.0rc1././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/0000755000175000017500000000000011140014417031524 5ustar zackzack././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/requires.txtpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/0000644000175000017500000000002411140014417031522 0ustar zackzackrepoze.what >= 1.0.1././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/namespace_packages.txtpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/0000644000175000017500000000004711140014417031527 0ustar zackzackrepoze repoze.what repoze.what.plugins ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/dependency_links.txtpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/0000644000175000017500000000000111140014417031515 0ustar zackzack ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/PKG-INFOpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/0000644000175000017500000000375711140014417031542 0ustar zackzackMetadata-Version: 1.0 Name: repoze.what.plugins.xml Version: 1.0rc1 Summary: The repoze.what XML plugin Home-page: http://code.gustavonarea.net/repoze.what.plugins.xml/ Author: Gustavo Narea Author-email: repoze-dev@lists.repoze.org License: BSD-derived (http://www.repoze.org/LICENSE.txt) Description: ************************** The repoze.what XML plugin ************************** This is an adapters plugin for repoze.what. Supported source formats ======================== A sample group source may look like this: A sample permission source may look like this: Keywords: web application server wsgi xml authorization repoze Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Topic :: Internet :: WWW/HTTP :: WSGI Classifier: Topic :: Security Classifier: Topic :: Text Processing :: Markup :: XML ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/entry_points.txtpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/0000644000175000017500000000000611140014417031522 0ustar zackzack ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/top_level.txtpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/0000644000175000017500000000001511140014417031522 0ustar zackzackrepoze tests ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/not-zip-safepython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/0000644000175000017500000000000111121541442031517 0ustar zackzack ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/SOURCES.txtpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/repoze.what.plugins.xml.egg-info/0000644000175000017500000000150411140014417031526 0ustar zackzackREADME.txt VERSION.txt setup.cfg setup.py docs/Makefile docs/source/News.rst docs/source/conf.py docs/source/index.rst docs/source/_static/logo_hi.gif docs/source/_static/repoze.css repoze/__init__.py repoze.what.plugins.xml.egg-info/PKG-INFO repoze.what.plugins.xml.egg-info/SOURCES.txt repoze.what.plugins.xml.egg-info/dependency_links.txt repoze.what.plugins.xml.egg-info/entry_points.txt repoze.what.plugins.xml.egg-info/namespace_packages.txt repoze.what.plugins.xml.egg-info/not-zip-safe repoze.what.plugins.xml.egg-info/requires.txt repoze.what.plugins.xml.egg-info/top_level.txt repoze/what/__init__.py repoze/what/plugins/__init__.py repoze/what/plugins/xml/__init__.py repoze/what/plugins/xml/adapters.py tests/__init__.py tests/test_adapters.py tests/fixture/__init__.py tests/fixture/groups.xml tests/fixture/permissions.xmlpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/docs/0000755000175000017500000000000011140014417024235 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/docs/source/0000755000175000017500000000000011140014417025535 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/docs/source/News.rst0000644000175000017500000000111111121544140027175 0ustar zackzack*************************************** :mod:`repoze.what.plugins.xml` releases *************************************** This document describes the releases of the :mod:`repoze.what` :mod:`XML plugin `. .. _repoze.what.plugins.xml-1.0b1: :mod:`repoze.what.plugins.xml` 1.0b1 (2008-12-15) ================================================= The first release of the XML plugin, featuring a :class:`group adapter ` and a :class:`permission adapter `.python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/docs/source/_static/0000755000175000017500000000000011140014417027163 5ustar zackzackpython-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/docs/source/_static/repoze.css0000644000175000017500000000047411112057356031216 0ustar zackzack@import url('default.css'); body { background-color: #006339; } div.document { background-color: #dad3bd; } div.sphinxsidebar h3,h4,h5,li,a { color: #127c56 !important; } div.related { color: #dad3bd !important; background-color: #00744a; } div.related a { color: #dad3bd !important; } python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/docs/source/_static/logo_hi.gif0000644000175000017500000000777611076123133031317 0ustar zackzackGIF89a4polܵEEE999VVUŪ؉ǼʤჂ򠞙dcaRRQ]\\{zx???MLL444333!,4@pH,Ȥrl:Ш@Zجvzxl-z|~su2WfoTe`UXboef :7=Óʋ<Ϥ5)ݳ߼˿ڶܾՎ΢55=C!ѷm+M>o6dtu._ݘUn>؟3:XfC`[0/h uCP![ W d(]"Xr_ 9"#2dwHe.zآ0]Z}7L PeI8tO aiCÃ WI -*蠄ozXv@5 @d "^0e80ݪ&p"|Cnk, 06,w)>jjwiɂ< ɂ:p +[8th k(8,#h,,/U"CPCg Z6 滲˙2宐A:Ё|{J/ B ؁Pp ZP p MK C,( g l| !p'| T)Prª P t5:z|pBX*R3( D-,. A'G, @8 @A*H@>P ql+0 䯀t)T>P`&(0,=#@V`?-;h_S܃ŭqWuo @/S^&  gZUG >B^EZUmyUk-}T0]w~;ܙ9%pquxO0 h07]- K-[^`q< ]rCyPb6Gy$a>p(%%@$g- }ǀ;%y'?rgy<2Tk=>Ng~'@S2D1\4l#px(w\i׀eBxx42-%eT\?05Ph>(}`(&u$`x/"r(^@6†Vz#ehy)iVhKng(`NHz!wB.  gx%d؉mȆl\e-7p_}4z!<`P#K`h~v,0\e `74(;0H9Ȇ<8،<@1#@։T9l(؎8mȆ $ LC9'J(.`KP hs3`"#׎yS:Y: 92`X`Yh ن0i2i 0m20UTYX`FC3Xo:HXyLB7. QI׋ 0dYfy)B gpr9tYtȗ~)|Xr(RV؄ 2xMxu2yuWɈZə捔ق闫W)B8^hBy)iXyiZHz¨I py1|?P雿Iٙy Ti PTK#p:ZP`a)zzEɚ  p?2UĢâ-j-ꓮB2/:1:= pq)@9>)U.ZFKKʣ>:0ڢ,60%ʥ#$b1P3Хɥ]٦Ӷ>ijkm 0 `U+mJ  l*djjr*A7ॆj v DGiZ$b905- :J** jJ*KfK jm2x=ښrʬJšjZ ׮*:ʩk8گʮ#Gڊ{7P0hzʮ:zK = 4 y<2=7U, M9P1:˳> +@+;KE۳@;LۮO۴NS[L[P;\XO+W;efac[\K]kR Y;python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/docs/source/index.rst0000644000175000017500000000252211121546476027415 0ustar zackzack********************************* The :mod:`repoze.what` XML plugin ********************************* .. module:: repoze.what.plugins.xml :synopsis: XML adapters plugin for repoze.what .. moduleauthor:: Gustavo Narea :Author: Gustavo Narea. :Latest version: |release| .. topic:: Overview The :mod:`repoze.what` XML plugin adds support to XML source adapters on this authorization framework. How to install ============== This package has no external dependencies and can be installed by running:: easy_install repoze.what.plugins.xml It has been tested under Python v2.5 and v2.6. It's not expected to work on previous versions. Adapters ======== .. module:: repoze.what.plugins.xml.adapters :synopsis: XML source adapters for repoze.what .. moduleauthor:: Gustavo Narea The XML plugin provides one group adapter and one permission adapter, which receive one parameter: The XML file. .. autoclass:: XMLGroupsAdapter .. autoclass:: XMLPermissionsAdapter They are both imported into the :mod:`repoze.what.plugins.xml` namespace, so you can do:: from repoze.what.plugins.xml import XMLGroupsAdapter, XMLPermissionsAdapter Contents ======== .. toctree:: :maxdepth: 2 News Indices and tables ------------------ * :ref:`genindex` * :ref:`modindex` * :ref:`search` python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/docs/source/conf.py0000644000175000017500000001446411121537571027057 0ustar zackzack# -*- coding: utf-8 -*- # # repoze.what XML plugin documentation build configuration file, created by # sphinx-quickstart on Mon Dec 15 21:17:13 2008. # # This file is execfile()d with the current directory set to its containing dir. # # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleable (module imports are okay, they're removed automatically). # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os here = os.path.dirname(os.path.abspath(__file__)) root = os.path.dirname(os.path.dirname(here)) # If setting up the auto(module|class) functionality: sys.path.append(os.path.abspath(root)) wd = os.getcwd() os.chdir(root) os.system('%s setup.py test -q' % sys.executable) os.chdir(wd) for item in os.listdir(root): if item.endswith('.egg'): sys.path.append(os.path.join(root, item)) # General configuration # --------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. source_encoding = 'utf-8' # The master toctree document. master_doc = 'index' # General information about the project. project = u'repoze.what XML plugin' copyright = u'2008, Gustavo Narea' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '1.0' # The full version, including alpha/beta/rc tags. release = open(os.path.join(root, 'VERSION.txt')).readline().rstrip() # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build. #unused_docs = [] # List of directories, relative to source directory, that shouldn't be searched # for source files. exclude_trees = [] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # Options for HTML output # ----------------------- # The style sheet to use for HTML and HTML Help pages. A file of that name # must exist either in Sphinx' static/ path, or in one of the custom paths # given in html_static_path. html_style = 'repoze.css' # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. html_logo = '_static/logo_hi.gif' # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_use_modindex = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, the reST sources are included in the HTML build as _sources/. #html_copy_source = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = '' # Output file base name for HTML help builder. htmlhelp_basename = 'repozewhatXMLplugindoc' # Options for LaTeX output # ------------------------ # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, document class [howto/manual]). latex_documents = [ ('index', 'repozewhatXMLplugin.tex', ur'repoze.what XML plugin Documentation', ur'Gustavo Narea', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_use_modindex = True # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = {'http://static.repoze.org/whatdocs/': None} python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/docs/Makefile0000644000175000017500000000445011121535511025702 0ustar zackzack# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source .PHONY: help clean html web pickle htmlhelp latex changes linkcheck help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " changes to make an overview over all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" clean: -rm -rf build/* html: mkdir -p build/html build/doctrees $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html @echo @echo "Build finished. The HTML pages are in build/html." pickle: mkdir -p build/pickle build/doctrees $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle @echo @echo "Build finished; now you can process the pickle files." web: pickle json: mkdir -p build/json build/doctrees $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) build/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: mkdir -p build/htmlhelp build/doctrees $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in build/htmlhelp." latex: mkdir -p build/latex build/doctrees $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex @echo @echo "Build finished; the LaTeX files are in build/latex." @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ "run these through (pdf)latex." changes: mkdir -p build/changes build/doctrees $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes @echo @echo "The overview file is in build/changes." linkcheck: mkdir -p build/linkcheck build/doctrees $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in build/linkcheck/output.txt." python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/setup.py0000644000175000017500000000402611140014373025022 0ustar zackzack# -*- coding: utf-8 -*- ############################################################################## # # Copyright (c) 2008-2009, Gustavo Narea # All Rights Reserved. # # This software is subject to the provisions of the BSD-like license at # http://www.repoze.org/LICENSE.txt. A copy of the license should accompany # this distribution. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL # EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND # FITNESS FOR A PARTICULAR PURPOSE. # ############################################################################## import os from setuptools import setup, find_packages here = os.path.abspath(os.path.dirname(__file__)) README = open(os.path.join(here, 'README.txt')).read() version = open(os.path.join(here, 'VERSION.txt')).readline().rstrip() setup(name='repoze.what.plugins.xml', version=version, description=('The repoze.what XML plugin'), long_description=README, classifiers=[ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP :: WSGI", "Topic :: Security", "Topic :: Text Processing :: Markup :: XML", ], keywords='web application server wsgi xml authorization repoze', author="Gustavo Narea", author_email="repoze-dev@lists.repoze.org", namespace_packages = ['repoze', 'repoze.what', 'repoze.what.plugins'], url="http://code.gustavonarea.net/repoze.what.plugins.xml/", license="BSD-derived (http://www.repoze.org/LICENSE.txt)", packages=find_packages(), include_package_data=True, zip_safe=False, tests_require=['repoze.what', 'coverage', 'nose'], install_requires=['repoze.what >= 1.0.1'], test_suite="nose.collector", entry_points = """\ """ ) python-repoze.what-plugins-20090531/repoze.what.plugins.xml-1.0rc1/setup.cfg0000644000175000017500000000053211140014417025126 0ustar zackzack[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 [nosetests] cover-erase = 1 verbose = 1 cover-package = repoze.what.plugins.xml verbosity = 1 with-coverage = 1 detailed-errors = 1 no-path-adjustment = 1 testmatch = ^(tests|test_.*)$ with-doctest = 1 where = tests [aliases] release = egg_info -rDb "" sdist bdist_egg register upload