[Repoze-dev] repoze.what patch for using it with pasteDeploy
Hello I'm interested in using repoze.what with paster, so I made this patch that allows pasteDeploy to initializate repoze.what and its plugins via repoze.who. Example of Use: Suppose you have a repoze.bfg instance of name zbfg. You activate repoze.who as usual in zbfg.ini: [DEFAULT] debug = true [server:main] use = egg:Paste#http host = 0.0.0.0 port = 6543 [app:main] use = egg:zbfg#app reload_templates = true filter-with = who [filter:who] use = egg:repoze.who#config config_file = %(here)s/who.ini log_file = stdout log_level = debug Now, you can configure repoze.who and repoze.what in who.ini # the habitual repoze.who plugins [plugin:basicauth] use = repoze.who.plugins.basicauth:make_plugin realm = 'zbfg app' [plugin:htpasswd] use = repoze.who.plugins.htpasswd:make_plugin filename = %(here)s/passwd check_fn = repoze.who.plugins.htpasswd:crypt_check # Now, repoze.what [plugin:what] use = repoze.what.config:make_plugin config_file = what.ini curdir = %(here)s/ # the usual repoze.who config [general] request_classifier = repoze.who.classifiers:default_request_classifier challenge_decider = repoze.who.classifiers:default_challenge_decider remote_user_key = REMOTE_USER [identifiers] plugins = basicauth [authenticators] plugins = htpasswd [challengers] plugins = basicauth # and repoze.what [mdproviders] plugins = what repoze.what plugins can be configured in what.ini. One section per plugin, one entry per parameter, plus use=package.module:class to instantiate the plugin: [group:ini] use = repoze.what.plugins.ini:INIGroupAdapter filename = group.ini [permissions:ini] use = repoze.what.plugins.ini:INIPermissionsAdapter filename = permissions.ini Best regards -- Ing. José Dinuncio Unidad de Redes Telemáticas Universidad de Carabobodiff -Naur repoze.what.orig/repoze/what/config.py repoze.what/repoze/what/config.py --- repoze.what.orig/repoze/what/config.py 1969-12-31 20:00:00.0 -0400 +++ repoze.what/repoze/what/config.py 2008-12-12 08:35:22.0 -0430 @@ -0,0 +1,43 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +# Inspired in repoze.who.config + +from ConfigParser import ConfigParser +from pkg_resources import EntryPoint +from repoze.what.middleware import AuthorizationMetadata + + +class WhatConfig: +def __init__(self): +self.group_adapters = {} +self.permissions_adapters = {} + +def _make_plugin(self, name, **kw): +obj = EntryPoint.parse('entry=%s' % name).load(False) +obj = obj(**kw) +return obj + +def parse(self, fname): +cp = ConfigParser() +cp.readfp(fname) + +for s_id in cp.sections(): +options = dict(cp.items(s_id)) +if s_id.startswith('group:'): +plugin_id = s_id[len('group:'):] +adapter = self.group_adapters +if s_id.startswith('permissions:'): +plugin_id = s_id[len('permissions:'):] +adapter = self.permissions_adapters + +if 'use' in options: +name = options.pop('use') +adapter[plugin_id] = self._make_plugin(name, **options) + + +def make_plugin(config_file, **kw): +parser = WhatConfig() +parser.parse(open(config_file)) +return AuthorizationMetadata(parser.group_adapters, parser.permissions_adapters) +___ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev
[Repoze-dev] bfg Buildout comments.
Platform current Debian Sid python2.5. 0) nothing to do with repoze. virtualenv -p python2.5 ... does not work. python2.5 /usr/lib/python2.5/site-packages/virtualenv.py ... is fine. Also, current Debian may have multiple python-dev packages, choose version you need, as in python2.4-dev or python2.5-dev. python-dev is a virtual package giving the current default python's package, and no older or more recent versions. 1) I don't know if this is easy to fix, but I suspect it is. buildout downloaded and built libxml2 and libxslt as expected. buildout then died, with a message about needing a new setuptools. running bin/python-bfg -U setuptools as in the failure message installed setuptools fine. Then the freshly built libxml2 and libxslt were deleted, the tarballs redownloaded and rebuilt. Is there any way to move the setuptools check so that it occurs before the wasted download/build cycle? 2) built a project from the template per instructions. bin/paster was fine. cd myproject; ../bin/python-bfg setup.py test -q did not run. Failed because it could not find ../bin/README.txt. touch ../bin/README.txt and then rerun. Now fails on ../bin/CHANGES.txt. touch and rerun, and it complete normally. Should either be fixed or documented. Seems pretty flaky to want .txt files in ../bin anyway! ___ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev
Re: [Repoze-dev] repoze.what patch for using it with pasteDeploy
Hello, José. This is awesome. Thank you *very* much! I'm currently working on a project where I wanted authentication and authorization to be configured from simple files (not from scripts), so it's great news I'll be able to take advantage of this feature :) However, I'm going to include it in the next release because v1.0 already has a release candidate, and I'd prefer to fix its bugs only (instead of adding features). Cheers! On Friday December 12, 2008 15:05:58 jdinu...@uc.edu.ve wrote: Hello I'm interested in using repoze.what with paster, so I made this patch that allows pasteDeploy to initializate repoze.what and its plugins via repoze.who. Example of Use: Suppose you have a repoze.bfg instance of name zbfg. You activate repoze.who as usual in zbfg.ini: [DEFAULT] debug = true [server:main] use = egg:Paste#http host = 0.0.0.0 port = 6543 [app:main] use = egg:zbfg#app reload_templates = true filter-with = who [filter:who] use = egg:repoze.who#config config_file = %(here)s/who.ini log_file = stdout log_level = debug Now, you can configure repoze.who and repoze.what in who.ini # the habitual repoze.who plugins [plugin:basicauth] use = repoze.who.plugins.basicauth:make_plugin realm = 'zbfg app' [plugin:htpasswd] use = repoze.who.plugins.htpasswd:make_plugin filename = %(here)s/passwd check_fn = repoze.who.plugins.htpasswd:crypt_check # Now, repoze.what [plugin:what] use = repoze.what.config:make_plugin config_file = what.ini curdir = %(here)s/ # the usual repoze.who config [general] request_classifier = repoze.who.classifiers:default_request_classifier challenge_decider = repoze.who.classifiers:default_challenge_decider remote_user_key = REMOTE_USER [identifiers] plugins = basicauth [authenticators] plugins = htpasswd [challengers] plugins = basicauth # and repoze.what [mdproviders] plugins = what repoze.what plugins can be configured in what.ini. One section per plugin, one entry per parameter, plus use=package.module:class to instantiate the plugin: [group:ini] use = repoze.what.plugins.ini:INIGroupAdapter filename = group.ini [permissions:ini] use = repoze.what.plugins.ini:INIPermissionsAdapter filename = permissions.ini Best regards -- Gustavo Narea http://gustavonarea.net/. Get rid of unethical constraints! Get freedomware: http://www.getgnulinux.org/ ___ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev