Hi,

i try to cache the expensive ldap_search method
in the ADSeach Class.

What is the best way to do this?

I ´ve experimented with plone.memoize but the
result of the ldap_search method is a dict
in this is not hashable so it don´t work
with memoize.

Does anyone have a smart tipp for me??

Thx christian


----------------------------------------------------

class ADSearch(formbase.PageForm):
    implements(IADSearch)
    form_fields = form.FormFields(IADSearch)
    ### Templates
    template = pagetemplatefile.ZopeTwoPageTemplateFile( FORM_TEMPLATE )
result_template = pagetemplatefile.ZopeTwoPageTemplateFile( RESULT_TEMPLATE )
    ### Labels
    label = "Mitarbeitersuche"
    search_results = []


    @form.action("search")
    def action_results(self, action, data):
        data = dict([x for x in data.items() if x[1] != None])
        res = self.search_ldap(data)
        self.search_results = res
        self.get_column = COLUMN
        self.search_results_count = len(self.search_results)
        return self.template()

    def nextURL(self):
         return "http://www.google.de";

    @instance.memoize
    def search_ldap(self, data):
        context = self.context
        pas = getToolByName(context, 'acl_users')
        ldmplugin = getattr(pas,'drupaADS')
        luf = getattr(ldmplugin,'acl_users')
        ### Search
        return luf.searchUsers(**data)


_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to