> 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
settings.

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
> here.

in most cases, you want to create an event subscriber :

    
http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/api/events.html?highlight=events#pyramid.events


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.

    
http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/views.html#defining-a-view-callable-as-a-class

your code could look like this:

class _BaseView(object):
    def __init__(self,request):
        self.request = request
        # do your shared stuff here

class LoginView(_BaseView):
    def login_print(self):
        pass
    def login_submit(self):
        pass

class AccountView(_BaseView):
    def account_home(self):
        pass
    def account_password_change(self):
        pass




-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to