I'm not an expert in this, but I think the maybe-resolve functions only do lookups when the spec is a string, and pass non-strings through unchanged. As far as I know lambdas are regular functions, so I'd expect it to pass them through like view callable functions. Maybe another exception is occurring, and when Python tries to print the traceback, it can't find the lambda's source.
I generally use regular functions instead of lambdas, but I realize this is a stylistic choice and some think otherwise. A partial might work in your use case: config.add_view( functools.partial(_delete_multi, arg2_keyword=Doc2Resource) , ... On Wed, Mar 13, 2024 at 10:50 AM Laurent Daverio <ldave...@gmail.com> wrote: > > Hello list, > > it seems that Google is allowing me to post on here again. A couple of weeks > ago, I was banned, both from emailing the list, AND from posting on the web > group 💩 > > I am trying to create a series of routes based on lambda functions, something > like: > > ``` > config.add_route('doc1.delete_selection', '/doc1/-/delete_selection') > config.add_route('doc2.delete_selection', '/doc2/-/delete_selection') > config.add_view( > lambda request: _delete_multi(request, Doc1Resource), > route_name='doc1.delete_selection', request_method='POST', > renderer='json') > config.add_view( > lambda request: _delete_multi(request, Doc2Resource), > route_name='doc2.delete_selection', request_method='POST', > renderer='json') > ``` > > (I also have `archive_selection` and `unarchive_selection` routes) > > I'm under the impression that `config.add_view` can't take lambda functions > as arguments, as it tries to resolve their names ("maybe_dotted", > "maybe_resolve", etc.). All I can say it that the views seem to be calling > the wrong functions. This prevents me from using for loops and lambda for > generating the routes in a more concise way :/ > > Could anyone confirm if I'm correct? > > Many thanks, > > Laurent. > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pylons-discuss+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/pylons-discuss/CAB7cU6y56gx3fDEGsdx3qFJKTVPOM5yN1maohu8tEESRnY2ygQ%40mail.gmail.com. -- Mike Orr <sluggos...@gmail.com> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/CAH9f%3Duq3ENBFg13AfwbH%2BivU2yzP7zORkRAREJefS0Wg1MAJaQ%40mail.gmail.com.