Ombott handler error after upgrade

134 views
Skip to first unread message

Larry_W

unread,
Dec 27, 2021, 4:00:49 PM12/27/21
to py4web
I upgraded py4web today from a version that was several months old. Now I'm getting this error:
-------------------------------------
ombott.router.errors.RouteMethodError: Handler is already registred for `['GET', 'DELETE', 'HEAD', 'POST', 'PUT']`
-------------------------------------

I think this is related to @action decorators, but I'm not sure exactly what I need to change.

I have a lines like this for each of my page defs:
-------------------------------------
@action('outdoor_table', method=['POST', 'GET'])
@action('outdoor_table/<path:path>', method=['POST', 'GET'])
--------------------------------------

 Can somebody give me a suggestion on this?

Val K

unread,
Dec 28, 2021, 2:16:05 AM12/28/21
to py4web
Hi!
This error occurs when trying to overwrite already registered routes (or rather, registered method(s) of routes). If you really want to do that, add overwrite=True:

@action('some/route/to/overwrite',  method=[...],  overwrite=True)


вторник, 28 декабря 2021 г. в 00:00:49 UTC+3, Larry_W:

Val K

unread,
Dec 28, 2021, 2:18:45 AM12/28/21
to py4web
just in case  - this should work (it does not require overwrite=True) :
@action('outdoor_table', method=['POST', 'GET'])
@action('outdoor_table/<path:path>', method=['POST', 'GET'])

вторник, 28 декабря 2021 г. в 10:16:05 UTC+3, Val K:

Larry_W

unread,
Dec 29, 2021, 5:51:41 PM12/29/21
to py4web
I had a decorator like this

@unauthenticated("index", "index.html")

I thought that this was used to redirect unauthenticated users to a different page (although I can't find this documented). This seems to be the cause of the problems I was seeing. For some reason, it didn't cause a problem in the previous version of py4web, but did cause a problem in the updated version. I've removed this line and that seems to have fixed the problem. Is the syntax of this code correct?

Val K

unread,
Dec 29, 2021, 11:45:45 PM12/29/21
to py4web
Syntax is correct, but this decorator cannot be combined with @action/@action.uses

четверг, 30 декабря 2021 г. в 01:51:41 UTC+3, Larry_W:

Nico Zanferrari

unread,
Dec 30, 2021, 4:09:13 AM12/30/21
to py4web

--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/f7257b81-8180-463a-949a-f2e393d72ae9n%40googlegroups.com.

Larry_W

unread,
Dec 30, 2021, 10:24:12 AM12/30/21
to py4web
OK, I see that I was using @unauthenticated inappropriately. It's curious, though, that it didn't seem to break when used that way in the previous version of py4web, but did cause a problem with the latest source.  Maybe the switch to ombott changed the way it behaved.

Also, I don't see any documentation showing use of  @unauthenticated with parameters like this:  @unauthenticated("index", "index.html"). That would be a good thing to add. Is there a good way to redirect unauthenticated users without using @unauthenticated?

Val K

unread,
Dec 30, 2021, 7:43:39 PM12/30/21
to py4web

ombott does not allow to overwrite routes randomly (which is good I think), but  bottle does.


четверг, 30 декабря 2021 г. в 18:24:12 UTC+3, Larry_W:

Massimo DiPierro

unread,
Dec 30, 2021, 7:45:51 PM12/30/21
to Val K, py4web
Strongly agree. Ombott does it better


Reply all
Reply to author
Forward
0 new messages