Parse INI-file configuration using SafeConfigParser.
Allows escaping the ``'%'`` so that e.g. a query template using for a DB-API
connection using ``pyformat`` preserves the template.
| | |
| | | 2.2 (unreleased) |
| | | ---------------- |
| | | |
| | | - Parse INI-file configuration using ``SafeConfigParser``: allows |
| | | escaping the ``'%'`` so that e.g. a query template using for a DB-API |
| | | connection using ``pyformat`` preserves the template. |
| | | |
| | | - Added support for Python 3.3, PyPy. |
| | | |
| | | |
| | |
| | | [plugin:sqlusers] |
| | | # authentication |
| | | use = repoze.who.plugins.sql:make_authenticator_plugin |
| | | query = "SELECT userid, password FROM users where login = %(login)s;" |
| | | # Note the double %%: we have to escape it from the config parser in |
| | | # order to preserve it as a template for the psycopg2, whose 'paramstyle' |
| | | # is 'pyformat'. |
| | | query = SELECT userid, password FROM users where login = %%(login)s |
| | | conn_factory = repoze.who.plugins.sql:make_psycopg_conn_factory |
| | | compare_fn = repoze.who.plugins.sql:default_password_compare |
| | | |
| | | [plugin:sqlproperties] |
| | | name = properties |
| | | use = repoze.who.plugins.sql:make_metadata_plugin |
| | | query = "SELECT firstname, lastname FROM users where userid = %(__userid)s;" |
| | | # Note the double %%: we have to escape it from the config parser in |
| | | # order to preserve it as a template for the psycopg2, whose 'paramstyle' |
| | | # is 'pyformat'. |
| | | query = SELECT firstname, lastname FROM users where userid = %%(__userid)s |
| | | filter = my.package:filter_propmd |
| | | conn_factory = repoze.who.plugins.sql:make_psycopg_conn_factory |
| | | |
| | |
| | | from urllib.parse import parse_qsl |
| | | |
| | | try: |
| | | from ConfigParser import ConfigParser |
| | | from ConfigParser import SafeConfigParser |
| | | except ImportError: #pragma NO COVER Python >= 3.0 |
| | | from configparser import ConfigParser |
| | | from configparser import SafeConfigParser |
| | | from configparser import ParsingError |
| | | else: #pragma NO COVER Python < 3.0 |
| | | from ConfigParser import ParsingError |
| | |
| | | from repoze.who.interfaces import IRequestClassifier |
| | | from repoze.who.middleware import PluggableAuthenticationMiddleware |
| | | from repoze.who._compat import StringIO |
| | | from repoze.who._compat import ConfigParser |
| | | from repoze.who._compat import SafeConfigParser |
| | | from repoze.who._compat import ParsingError |
| | | |
| | | def _resolve(name): |
| | |
| | | def parse(self, text): |
| | | if getattr(text, 'readline', None) is None: |
| | | text = StringIO(text) |
| | | cp = ConfigParser(defaults={'here': self.here}) |
| | | cp = SafeConfigParser(defaults={'here': self.here}) |
| | | try: |
| | | cp.read_file(text) |
| | | except AttributeError: #pragma NO COVER Python < 3.0 |
| | |
| | | self.failUnless(isinstance(foo, DummyPlugin)) |
| | | self.assertEqual(foo.iface, 'iface') |
| | | self.assertEqual(foo.name, 'name') |
| | | self.assertEqual(foo.template, '%(template)s') |
| | | self.assertEqual(foo.template_with_eq, |
| | | 'template_with_eq = %(template_with_eq)s') |
| | | |
| | | class DummyPlugin: |
| | | def __init__(self, **kw): |
| | |
| | | use = repoze.who.tests.test_config:DummyPlugin |
| | | name = name |
| | | iface = iface |
| | | template = %%(template)s |
| | | template_with_eq = template_with_eq = %%(template_with_eq)s |
| | | """ |
| | | |
| | | class TestConfigMiddleware(_Base): |