This works but doubles up on the number of functions needed. But by
calling cache.ram directly I'm able to define a lambda function that
uses the 'searchText' parameter. can anyone take this one step
further?
def search_user_contacts_cached(searchText):
from applications.init.modules.user import User
user = User(globals())
contacts = user.find_contacts(searchText)
return searchText, contacts
@service.jsonrpc
def search_user_contacts(searchText):
return cache.ram('search_contact=%s'%searchText,
lambda: search_user_contacts_cached(searchText),
60)
On Mar 1, 12:42 am, Carl <[email protected]> wrote:
> When I add @cache as below in my default.py
>
> @cache(request.env.path_info, 60, cache.ram)
> def search_user_contacts(searchText):
> from applications.init.modules.user import User
> user = User(globals())
> contacts = user.find_contacts(searchText)
> return searchText, contacts
>
> I get a runtime error: TypeError: <lambda>() takes no arguments (1
> given)
>
> In some way I'm failing to set-up this decorator to be smart enough to
> call the function with the 'searchText' parameter.
>
> Does anyone know where I've gone wrong?