# HG changeset patch # User Sverre Rabbelier # Date 1251881485 -7200 # Node ID ec2ed1571e3aa4449cc0c4e0f758677e8cba91ee # Parent 003a84e774e2976158d27b8f2fb83542239f13a6 Hook up prefetching in the view (helper) diff -r 003a84e774e2 -r ec2ed1571e3a app/soc/views/helper/lists.py --- a/app/soc/views/helper/lists.py Wed Sep 02 10:24:10 2009 +0200 +++ b/app/soc/views/helper/lists.py Wed Sep 02 10:51:25 2009 +0200 @@ -19,6 +19,7 @@ __authors__ = [ '"Chen Lunpeng" ', + '"Sverre Rabbelier" ', '"Pawel Solyga" ', ] @@ -136,7 +137,7 @@ def getListContent(request, params, filter=None, order=None, - idx=0, need_content=False): + idx=0, need_content=False, prefetch=None): """Returns a dict with fields used for rendering lists. TODO(dbentley): we need better terminology. List, in this context, can have @@ -151,6 +152,7 @@ order: the order which should be used for the list (in getForFields format) idx: the index of this list need_content: iff True will return None if there is no data + prefetch: the fields of the data that should be pre-fetched Returns: A dictionary with the following values set: @@ -182,7 +184,7 @@ # Fetch one more to see if there should be a 'next' link data = logic.getForFields(filter=filter, limit=limit+1, offset=offset, - order=order) + order=order, prefetch=prefetch) if need_content and not data: return None diff -r 003a84e774e2 -r ec2ed1571e3a app/soc/views/models/base.py --- a/app/soc/views/models/base.py Wed Sep 02 10:24:10 2009 +0200 +++ b/app/soc/views/models/base.py Wed Sep 02 10:51:25 2009 +0200 @@ -510,8 +510,8 @@ @decorators.merge_params @decorators.check_access - def list(self, request, access_type, - page_name=None, params=None, filter=None, order=None, **kwargs): + def list(self, request, access_type, page_name=None, params=None, + filter=None, order=None, prefetch=None, **kwargs): """Displays the list page for the entity type. Args: @@ -520,6 +520,7 @@ page_name: the page name displayed in templates as page and header title params: a dict with params for this View filter: a dict for the properties that the entities should have + prefetch: the fields of the data that should be pre-fetched Params usage: The params dictionary is passed as argument to getListContent in @@ -528,7 +529,8 @@ the _list method. See the docstring for _list on how it uses it. """ - content = helper.lists.getListContent(request, params, filter, order=order) + content = helper.lists.getListContent(request, params, filter, + order=order, prefetch=prefetch) contents = [content] return self._list(request, params, contents, page_name)