> How would I access this config variable from my views? Some people have
> suggested using request.registry.settings, but I don't see it in that
> dictionary in my 1.3.3 version.
request.registry.settings is the place to find app configuration
I just looked at the pyramid ldap docs, and the 'config' variable
there is a Configurator() instance. I could be wrong, but I don't
think that is the pyramid config registry. it might save things into
it, but I believe it is another instance.
the pyramid ldap docs also note a few things:
- there's a pretty decent API, and the only thing you should really
need to access in your views is 'get_ldap_connector()'.
- you could probably explore the object returned by
get_ldap_connector() to find the variables you want, but the package
seems to be designed for a single setup : 'All three of these methods
should be called once (and, ideally, only once) during the startup
phase of your Pyramid application'
> Also, if I wanted to do something before each and every request, what is
> the best way? What about just after the request is sent handled? Pylons
> used to have a __before__ and __after__, I don't think those are working
in most cases, you want to create an event subscriber :
another alternative is to use a class-based approach to writing
views. this is the most pylons-esque approach, where you can use a
single base class that has an init function.
your code could look like this:
self.request = request
# do your shared stuff here