Re: [pylons-discuss] Generating URL using request.resource_url

2020-04-22 Thread Steve Piercy
Further reading, from the sidebar in the Traversal chapter, "The Example View Callables Accept Only a Request; How Do I Access the Context Resource?": https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/traversal.html In view callables that accept only a request, the context res

Re: [pylons-discuss] Generating URL using request.resource_url

2020-04-22 Thread Bert JW Regeer
Pass the current context. It should have lineage and thus know how to get to where you are right now. request.resource_url(request.context, '@@create') Bert JW Regeer > On Apr 22, 2020, at 14:05, Sydo Luciani wrote: > > Back to my original post, fixed the problem with stripping leading slash

Re: [pylons-discuss] Re: Generating URL using request.resource_url

2020-04-22 Thread Sydo Luciani
Back to my original post, fixed the problem with stripping leading slash in request.path in jinja template: {% set stripped_path = request.path | replace("/", "", 1) %} And then passed stripped_path to request.resource_url: href="{{ request.resource_url(request.root, stripped_path, '@@create') }

Re: [pylons-discuss] Re: Generating URL using request.resource_url

2020-04-22 Thread Sydo Luciani
Application is using hybrid of traversal and URL dispatch. Here is the code: https://github.com/SystematicD/pyramid_wikiz/blob/master/__init__.py#L33 currently application working fine, but using session to save and passing around the coming_from_url or next_url is problematic in browsing applic

Re: [pylons-discuss] Re: Generating URL using request.resource_url

2020-04-22 Thread Steve Piercy
Are you using traversal or URL dispatch? It seems that you don't want to pass in a `resource` as the first argument to `resource_url`, so perhaps you want to use https://docs.pylonsproject.org/projects/pyramid/en/latest/api/request.html#pyramid.request.Request.route_url ? --steve On 4/22/2

[pylons-discuss] Re: Generating URL using request.resource_url

2020-04-22 Thread Sydo Luciani
root + path be the resource but passing request.url as resource throws error: href="{{ request.resource_url(request.url , '@@create') }}"> path = [loc.__name__ or '' for loc in lineage(resource)] AttributeError: 'str' object has no attribute '__name__' On Wednesday, 22 April 2020 04:11:00 UT

[pylons-discuss] Re: Generating URL using request.resource_url

2020-04-22 Thread Sydo Luciani
tried href="{{ request.resource_url(request.url , '@@create') }}"> but didn't work and got below error: path = [loc.__name__ or '' for loc in lineage(resource)] AttributeError: 'str' object has no attribute '__name__' Then tried href="{{ request.resource_url(request.root, request.path , '@@c

Re: [pylons-discuss] Generating URL using request.resource_url

2020-04-22 Thread Steve Piercy
See: https://docs.pylonsproject.org/projects/pyramid/en/latest/api/request.html#pyramid.request.Request.resource_url It's not clear what you want to be the resource (the first argument): root or root + path? Subsequent args are joined by `/`. The link to the docs above should give you plenty

[pylons-discuss] Generating URL using request.resource_url

2020-04-22 Thread Sydo Luciani
This code: href="{{ request.resource_url(request.root, request.path , '@@create') }}"> Generates below URL: https://domain_name.com:6543/%2FDir_1%2FDir_2/@@create After domain_name:port, there is a '/' and a '%2F' which represents another