CallbackLookupError

30 views
Skip to first unread message

Pavel V. Kaygorodov

unread,
Apr 16, 2013, 1:44:14 PM4/16/13
to Nagare users
Hi!

I see strange error in my nagare-based web application.
After using the "back" button in browser, form submission causing the error:

URL: http://127.0.0.1:8080/
File '/usr/local/nagare/lib/python2.7/site-packages/WebError-0.10.3-py2.7.egg/weberror/evalexception.py', line 431 in respond
app_iter = self.application(environ, detect_start_response)
File '/usr/local/nagare/lib/python2.7/site-packages/nagare-0.4.1-py2.7.egg/nagare/wsgi.py', line 432 in __call__
response = self.on_exception(request, response)
File '/usr/local/nagare/lib/python2.7/site-packages/nagare-0.4.1-py2.7.egg/nagare/wsgi.py', line 425 in __call__
render = self.on_callback_lookuperror(request, response, xhr_request)
File '/usr/local/nagare/lib/python2.7/site-packages/nagare-0.4.1-py2.7.egg/nagare/wsgi.py', line 423 in __call__
render = self._phase1(request, response, callbacks)
File '/usr/local/nagare/lib/python2.7/site-packages/nagare-0.4.1-py2.7.egg/nagare/wsgi.py', line 329 in _phase1
return callbacks.process_response(request, response)
File '/usr/local/nagare/lib/python2.7/site-packages/nagare-0.4.1-py2.7.egg/nagare/callbacks.py', line 158 in process_response
(f, with_request, render) = self._search_by_callback_name(name)
File '/usr/local/nagare/lib/python2.7/site-packages/nagare-0.4.1-py2.7.egg/nagare/callbacks.py', line 120 in _search_by_callback_name
raise CallbackLookupError(name)
CallbackLookupError: 38582559

This error don't appear if I use "http://127.0.0.1:8080/?" URL, only with "http://127.0.0.1:8080" one.
Is it possible to fix this? Most of users will use short URLs, without trailing "/?".

With best regards,
Pavel

Alain Poirier

unread,
Apr 16, 2013, 2:29:35 PM4/16/13
to nagare...@googlegroups.com
Hi,
I need more infos about how this error appears:

- I see your application is registered under 'http://127.0.0.1:8080' instead of the classical 'http://127.0.0.1:8080/<name of the application>'. Did you add something like http://www.nagare.org/trac/browser/core/nagare/admin/admin_app.py#L118 in your code?

- What are the exact steps? 1. http://127.0.0.1:8080, 2. Form submission 3. "back" 4. Form submission again?

- Is the form submitted in synchrone or in Ajax?


I can't see any problem with this little test:

# ---------------------------------------------------------------

from nagare import presentation, component, wsgi

class MyApp(object):
def hello(self):
print 'Hello world!'

@presentation.render_for(MyApp)
def render(self, h, *args):
with h.form:
h << h.input(type='submit').action(self.hello)

return h.root

class WSGIApp(wsgi.WSGIApp):
def set_publisher(self, publisher):
super(WSGIApp, self).set_publisher(publisher)
publisher.register_application('myapp', '', self, self)

app = WSGIApp(lambda: component.Component(MyApp()))

# ---------------------------------------------------------------

How is your code structure different?


Best regards,
Alain

Pavel V. Kaygorodov

unread,
Apr 17, 2013, 6:49:27 AM4/17/13
to nagare...@googlegroups.com
Good day!

I have found source of the problem.
I have a main form (with text input and submit button) and a block, rendered via AsyncRenderer, containing other (also hidden) form, which is used to show dynamic hints, while user typing text (each type cause submitting of hidden form and reload of async block).
It seems, what after using of "back" button the async form submission always fails, because Nagare cannot find appropriate callbacks for the hidden form.
And, because the hidden form was inside of main form, submission of main form fails too.
Now I just moved hidden form outside of main form as a workaround.
However, the dynamic hint still not work after using of "back" button :(

Pavel.
> --
> You received this message because you are subscribed to the Google Groups "Nagare users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nagare-users...@googlegroups.com.
> To post to this group, send email to nagare...@googlegroups.com.
> Visit this group at http://groups.google.com/group/nagare-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Sylvain Prat

unread,
Apr 17, 2013, 8:24:07 AM4/17/13
to nagare...@googlegroups.com
Hello Pavel,

You can try to add this code into your WSGIApp object and see if it solves the problem :

class MyApp(wsgi.WSGIApp):
    ...
    def start_request(self, root, request, response):
        # Disable the browser's cache. The reason is that, when we render
        # asynchronous components, the current state is overwritten, but when
        # we hit the back button, the browser retrieves the HTML of the first
        # version of the state from its cache, and thus callbacks are broken
        # because the state has changed in-between.
        response.cache_expires(0)

        super(MyApp, self).start_request(root, request, response)


Sylvain


--
Sylvain PRAT
+33 06 78 71 51 21

Pavel V. Kaygorodov

unread,
Apr 17, 2013, 8:47:11 AM4/17/13
to nagare...@googlegroups.com
Hi!

You can try to add this code into your WSGIApp object and see if it solves the problem :

class MyApp(wsgi.WSGIApp):
    ...
    def start_request(self, root, request, response):
        # Disable the browser's cache. The reason is that, when we render
        # asynchronous components, the current state is overwritten, but when
        # we hit the back button, the browser retrieves the HTML of the first
        # version of the state from its cache, and thus callbacks are broken
        # because the state has changed in-between.
        response.cache_expires(0)

        super(MyApp, self).start_request(root, request, response)


In my programm I have no class derived from wsgi.WSGIApp.
In brief, my app.py code is following:

class Bdb3(object):
    def __init__(self):
        …..

@presentation.render_for(Bdb3)
def render(self, h, comp, *args):
    …….
    return h.root

# ---------------------------------------------------------------

app = Bdb3




Where is the place to put response.cache_expires() in my case?

Pavel.

Alain Poirier

unread,
Apr 17, 2013, 9:55:20 AM4/17/13
to nagare...@googlegroups.com

Le 17 avr. 2013 à 14:47, Pavel V. Kaygorodov <pa...@inasan.ru> a écrit :

> Hi!
>
>> You can try to add this code into your WSGIApp object and see if it solves the problem :
>>
>> class MyApp(wsgi.WSGIApp):
>> ...
>> def start_request(self, root, request, response):
>> # Disable the browser's cache. The reason is that, when we render
>> # asynchronous components, the current state is overwritten, but when
>> # we hit the back button, the browser retrieves the HTML of the first
>> # version of the state from its cache, and thus callbacks are broken
>> # because the state has changed in-between.
>> response.cache_expires(0)
>>
>> super(MyApp, self).start_request(root, request, response)
>>
>
> In my programm I have no class derived from wsgi.WSGIApp.
> In brief, my app.py code is following:
>
> class Bdb3(object):
> def __init__(self):
> …..
>
> @presentation.render_for(Bdb3)
> def render(self, h, comp, *args):
> …….
> return h.root
>
> # ---------------------------------------------------------------
>
> app = Bdb3
>
>
>
>
> Where is the place to put response.cache_expires() in my case?

To create the `WSGIApp` instance, change the final line `app = Bdb3` by:


from nagare import wsgi

class WSGIApp(wsgi.WSGIApp):
def start_request(self, root, request, response):
# Disable the browser's cache. The reason is that, when we render
# asynchronous components, the current state is overwritten, but when
# we hit the back button, the browser retrieves the HTML of the first
# version of the state from its cache, and thus callbacks are broken
# because the state has changed in-between.
response.cache_expires(0)

super(WSGIApp, self).start_request(root, request, response)

app = WSGIApp(lambda: component.Component(Bdb3()))
Reply all
Reply to author
Forward
0 new messages