0

I have this view function search(request). The url suffix is /search. It takes a few POST parameters and shows search results accordingly.

I want to make a second function show_popular(request). It takes no post or get parameters. But it should emulate a call to the search function with some hard coded post parameters.

I want to achieve this without changing anything in any existing function and without changing setup. Is that possible?

EDIT: I know this can be achieved by refactoring the search into a separate function and have several view functions call this. But in this particular case, I am not interested in that. In my case the show_popular function is only temporary, and for irrelevant reasons I do not wish to re-factor.

Erik Ninn-Hansen
  • 565
  • 2
  • 7
  • 16
  • how do you define a popular element, is there something like a vote system or do you record views on a specific element? – cwoebker Jul 26 '11 at 10:12
  • In my case it is actually not about showing popular entries, but about showing erroneous entries. I was just trying to boil down the question. This view is only temporary, until we have weeded out those erroneous entries. But we want to display these erroneous entries the same way as we display normal search entries, because that is the most easily readable. I think the criteria for being erroneous are irrelevant here. – Erik Ninn-Hansen Jul 26 '11 at 13:05
  • alright cause otherwise i would just split the two things, but that makes sense, i was slightly confused ^^ – cwoebker Jul 26 '11 at 13:10

1 Answers1

5

Yes, but you don't want to do that. Refactor search() into a function that handles the request and a function that performs the search, and call the latter from show_popular().

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358