How do you write decorators?

On Wed, Dec 18, 2013 at 8:44 PM, Cliff Kachinske <cjk...@gmail.com> wrote:

> My reading of the source code says you are pretty much stuck with the
> behavior you see. The first thing the decorator does is check if the
> request is ajax and returns the message you are receiving.
>
> You could:
> - check auth.is_logged_in in your controller and take whatever action you
> wish if not true
> - write your own decorator that checks auth.is_logged_in
>
>
>
> On Tuesday, December 17, 2013 1:23:23 AM UTC-5, software.ted wrote:
>>
>> I am trying to create an application using web2py backend that is fully
>> AJAX. I amusing the jQuery/Javascript to create a client. Now am a bit
>> stuck on the customising the behavior @auth.requires_login() decorator.
>>
>> I have a jQuery request to an action with a @auth.requires_login()
>> decorator:
>>
>> Client
>>
>> function(){
>>      $('#div').load('{{"default","getPrice"}}');
>> }
>>
>>
>> web2py control
>>
>> @auth.requires_login()
>> def getPrice():
>>     ...
>>     ...
>>     return locals()
>>
>> At the moment when i capture what is returned when not logged in is the
>> following text:
>>
>> <div class="not-authorized alert alert-block"><h4>NOT
>> AUTHORIZED</h4>Please <a data-w2p_disable_with="default"
>> href="">login</a> to view this content.</div>
>>
>> How can I return say forinstance true or false , logged in or logged
>> out...or redirect to an action that returns and invokes a jQuery login
>> window??
>>
>> Thanx in advance
>>
>>
>>
>>
>>
>> --
>> ............................................................
>> ...........................
>> Teddy Lubasi Nyambe
>> Opensource Zambia
>> Lusaka, ZAMBIA
>>
>> Cell: +260 97 7760473
>> website: http://www.opensource.org.zm
>>
>> ~/
>> Human Knowledge belongs to the world! - AntiTrust
>>
>> Man is a tool-using animal. Without tools he is nothing, with tools he is
>> all - Thomas Carlyle 1795-1881
>>
>> /~
>>
>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
.......................................................................................
Teddy Lubasi Nyambe
Opensource Zambia
Lusaka, ZAMBIA

Cell: +260 97 7760473
website: http://www.opensource.org.zm

~/
Human Knowledge belongs to the world! - AntiTrust

Man is a tool-using animal. Without tools he is nothing, with tools he is
all - Thomas Carlyle 1795-1881

/~

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to