my patch would be litte simpler,
if response.flash would let have clickable links on it,
as now, if I try to hit the link (for login) (with chromium),
the flash just dissapears (as it is supposed to be in general)

On Aug 21, 12:45 am, mdipierro <[email protected]> wrote:
> I see the problem. Let me think about your solution.
>
> On Aug 20, 3:36 pm, Jurgis Pralgauskis <[email protected]>
> wrote:
>
>
>
> > hello, by default, if some function needs auth, w2p gives back some
> > text/html:
> > When I work with components ajax way, I don't want my content parts to
> > get mangled with it...
> > 1) if I am not logged in, it would flood my tiny content area with big
> > login page clone :)
> > 2) in my case, I want my current content (of target div) to stay in
> > place if I don't have permisions,  (and new  content should replace it
> > only if accessible).
>
> > so I made a small patch, You can test it 
> > hearhttps://web2py-gae-test.appspot.com/auth_for_web2py_components/defaul...
> > its default new app with several changes in
> > /controllers/default.py : user()
> > /views/web2py_ajax.html  : web2py_ajax_page()
>
> > is it a good way? or how would be better?
>
> > /controllers/default.py
>
> > def user():
> >     if request.ajax:
> >         result = auth()
> >         if not auth.user:
> >             return "ERROR" +"<br> You should %s first <br>\n" %
> > ( A('login',  _target="blank", _href=auth.settings.login_url).xml())
> >         if isinstance(result, str):
> >             response.flash = result
> >             return "ERROR"
> >         return result # no dict(form=result)
> >     else:
> >         return dict(form=auth())
>
> > /views/web2py_ajax.html
>
> >     'success': function(text) {
> >         if (text.startsWith( "ERROR" )) {
> >           jQuery('#'+target).prepend( text.substr( "ERROR".length ) );
> >         }
> >         else {
> >             jQuery('#'+target).html(text);
> >         }

Reply via email to