durusmail: quixote-users: why pass request object to public functions / methods
why pass request object to public functions / methods
why pass request object to public functions / methods
2005-01-03
2005-01-03
2005-01-03
2005-01-03
2005-01-03
2005-01-03
2005-01-03
2005-01-03
2005-01-03
2005-01-03
2005-01-05
2005-01-03
2005-01-03
why pass request object to public functions / methods
Oleg Broytmann
2005-01-03
On Mon, Jan 03, 2005 at 01:23:28PM +0100, Thomas Guettler wrote:
> I like the request in the signature of a method, too. You see immediately
> if a method is called via web or if it is a internal method which can't be
> called from a webbrowser.

   Seems like another task for a decorator.

def published(func):
   def wrapper():
      request = get_request()
      func(request)
   return wrapper

@published
def myfunc(request):
   process(request)

(This is only a very rough draft, of course.)

Oleg.
--
     Oleg Broytmann            http://phd.pp.ru/            phd@phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

reply