Since you are modifying my_view to add the call to hijacker anyway, why
not do this?
def hijacker(request):
if I_feel_its_necessary:
return HttpResponse(some_json_content)
def my_view(request):
hret = hijacker(request)
if hret: return hret
... # Continue as normal
ret
On Mon, Mar 24, 2008 at 6:19 AM, Julien <[EMAIL PROTECTED]> wrote:
> I would like to do something like:
>
> def called(arg)
> if arg==True:
> !!magic!!caller.return 1
>
> def caller(arg)
> called(arg)
> return 2
>
"called" look like a precondition constrain[1], then It wil
Oh, I forgot to say. For while I thought I'd make hijacker a
decorator:
@hijacker
def my_view(request):
But that wouldn't work, since some views need to do some processing
before calling the hijacker. I think a decorator is systematically
called before the view itself so no prior processing
In fact, what I want is to hijack a view:
def hijacker(request):
if I_feel_its_necessary:
hijack_caller_view_and_return(some_json_content)
def my_view(request):
hijacker(request)
... # Continue as normal
return some_html_content
I have some long views which I'd like to m
I don't know how to do this in Python, if you even can. Inspect may be
just the dark scary corner to explore to find this capability if it
exists. But why would you want to do something like this? Even if
inspect could do this, it looks like called would have to have some very
specific know
> We seem to be turning into comp.lang.python here. :-(
Good point, I'll try my chance over there.
> Sounds like you want to use an exception and have caller catch an
> exception of a particular type and then return the value in the
> exception object.
In fact, I don't want 'called' to throw a
> This is more a Python issue than a Django one, but I thought the
> Python-aware people that you are might be able to help me :)
>
> I would like to do something like:
>
> def called(arg)
>if arg==True:
>!!magic!!caller.return 1
>
> def caller(arg)
>called(arg)
>return 2
>
> H
On Mon, 2008-03-24 at 03:19 -0700, Julien wrote:
> Hi all,
>
> This is more a Python issue than a Django one, but I thought the
> Python-aware people that you are might be able to help me :)
>
> I would like to do something like:
>
> def called(arg)
> if arg==True:
> !!magic!!calle
Hi all,
This is more a Python issue than a Django one, but I thought the
Python-aware people that you are might be able to help me :)
I would like to do something like:
def called(arg)
if arg==True:
!!magic!!caller.return 1
def caller(arg)
called(arg)
return 2
Here, the fa
9 matches
Mail list logo