[Repoze-checkins] r940 - repoze.who/trunk/repoze/who
Tres Seaver
tseaver at palladion.com
Sat May 3 16:38:08 EDT 2008
Author: Tres Seaver <tseaver at palladion.com>
Date: Sat May 3 16:38:07 2008
New Revision: 940
Log:
Tweak factory setup after using in real paste server.
Modified:
repoze.who/trunk/repoze/who/config.py
repoze.who/trunk/repoze/who/tests.py
Modified: repoze.who/trunk/repoze/who/config.py
==============================================================================
--- repoze.who/trunk/repoze/who/config.py (original)
+++ repoze.who/trunk/repoze/who/config.py Sat May 3 16:38:07 2008
@@ -21,7 +21,8 @@
return type(obj) in (type(WhoConfig), type)
class WhoConfig:
- def __init__(self):
+ def __init__(self, here):
+ self.here = here
self.request_classifier = None
self.challenge_decider = None
self.plugins = {}
@@ -66,7 +67,7 @@
def parse(self, text):
if getattr(text, 'readline', None) is None:
text = StringIO(text)
- cp = ConfigParser()
+ cp = ConfigParser(defaults={'here': self.here})
cp.readfp(text)
for s_id in [x for x in cp.sections() if x.startswith('plugin:')]:
@@ -74,6 +75,7 @@
options = dict(cp.items(s_id))
if 'use' in options:
name = options.pop('use')
+ del options['here']
obj = self._makePlugin(name, IPlugin, **options)
self.plugins[plugin_id] = obj
@@ -119,8 +121,8 @@
)
-def make_middleware_with_config(app, config_file):
- parser = WhoConfig()
+def make_middleware_with_config(app, global_conf, config_file):
+ parser = WhoConfig(global_conf['here'])
parser.parse(open(config_file))
return PluggableAuthenticationMiddleware(
app,
Modified: repoze.who/trunk/repoze/who/tests.py
==============================================================================
--- repoze.who/trunk/repoze/who/tests.py (original)
+++ repoze.who/trunk/repoze/who/tests.py Sat May 3 16:38:07 2008
@@ -1821,8 +1821,8 @@
from repoze.who.config import WhoConfig
return WhoConfig
- def _makeOne(self, *args, **kw):
- return self._getTargetClass()(*args, **kw)
+ def _makeOne(self, here='/', *args, **kw):
+ return self._getTargetClass()(here, *args, **kw)
def _getDummyPluginClass(self, iface):
from zope.interface import classImplements
@@ -2151,7 +2151,6 @@
def _getTempfile(self, text):
import tempfile
tf = self.tempfile = tempfile.NamedTemporaryFile()
- text = text % {'here': os.getcwd()}
tf.write(text)
tf.flush()
return tf
@@ -2160,7 +2159,8 @@
app = DummyApp()
factory = self._getFactory()
tempfile = self._getTempfile(SAMPLE_CONFIG)
- middleware = factory(app, config_file=tempfile.name)
+ global_cohf = {'here': '/'}
+ middleware = factory(app, global_cohf, config_file=tempfile.name)
SAMPLE_CONFIG = """\
[plugin:form]
More information about the Repoze-checkins
mailing list