From e1ef08083740df3fc24e09505bd52630ba05c573 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Wed, 30 Mar 2011 10:20:40 -0400 Subject: Cache the value of get_ipa_config() in the request context. There are some operations that fetch the configuration multiple times. This will return a cached value instead of getting it from LDAP over and over. ticket 1023 --- ipaserver/plugins/ldap2.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ipaserver/plugins/ldap2.py') diff --git a/ipaserver/plugins/ldap2.py b/ipaserver/plugins/ldap2.py index 13950d9a0..a120efeb8 100644 --- a/ipaserver/plugins/ldap2.py +++ b/ipaserver/plugins/ldap2.py @@ -632,6 +632,12 @@ class ldap2(CrudBackend, Encoder): def get_ipa_config(self, attrs_list=None): """Returns the IPA configuration entry (dn, entry_attrs).""" cdn = "%s,%s" % (api.Object.config.get_dn(), api.env.basedn) + try: + config_entry = getattr(context, 'config_entry') + return (cdn, config_entry) + except AttributeError: + # Not in our context yet + pass try: (cdn, config_entry) = self.find_entries( None, attrs_list, base_dn=cdn, scope=self.SCOPE_BASE, @@ -642,6 +648,7 @@ class ldap2(CrudBackend, Encoder): for a in self.config_defaults: if a not in config_entry: config_entry[a] = self.config_defaults[a] + setattr(context, 'config_entry', config_entry) return (cdn, config_entry) def get_schema(self): -- cgit