TG 2.2 request.response_ext

30 views
Skip to first unread message

ozwyzard

unread,
Dec 12, 2012, 3:48:09 AM12/12/12
to turbo...@googlegroups.com

TG 2.2

def foo(self, filename, *args, **kw):
    print 'filename=%s' % filename
    if tg.request.response_ext:
        print 'ext=%s' % tg.request.response_ext


Calling foo('File') results in:
     filename=File
    ext=None

Calling foo('File.html') results in:
     filename=File
    ext=.html

Calling foo('File.Some.html') results in:
     filename=File
    ext=.html

Calling foo('File.Some.More.html') results in:
     filename=File.Some
    ext=.html

The second to last part of the filename is missing...

[args = None in all cases]

Additionally, the response_ext is None in the case of a filename like 'File.Name.Is.Something'; i.e. it seems to care about valid extensions, but does still eats up part of the url (filename).

Should use request.environ['PATH_INFO'] to extract the filename instead? 

I have looked at https://groups.google.com/forum/#!searchin/turbogears/URL$20with$20dot/turbogears/2XPMY9ooCgk/OQ19EJvR3CQJ

Thanks!

Michael Pedersen

unread,
Jan 3, 2013, 12:01:20 AM1/3/13
to tg-trunk
Okay, this is interesting. Alessandro, have you looked into this yet? I figured I'd ask you first before I started.

I've tried this with several different URLs, and the results are not what I expected.

I've modified the example somewhat to not have the filename parameter. My def foo() looks like this:

    @expose()
    def foo(self, *args, **kw):
        if request.response_ext:
            print 'ext=%s' % request.response_ext

I then run it against several URLs, and get surprising results:

http://localhost:8080/foo.some.more.html <-- returns 404

What do you think? Do we have a problem here? BTW, this is against the latest code on the development branch.
--
Michael J. Pedersen
My Online Resume: http://www.icelus.org/ -- Google+ http://plus.ly/pedersen
Google Talk: m.ped...@icelus.org -- Twitter: pedersentg

ozwyzard

unread,
Jan 4, 2013, 2:40:33 AM1/4/13
to turbo...@googlegroups.com

This is my current fix:

http://pastie.org/private/ky43zj0rah6y8r4yjixnew

Hope it helps.

Michael Pedersen

unread,
Jan 5, 2013, 1:41:20 AM1/5/13
to tg-trunk
I'm going to hold off until Alessandro gets back. He might have already implemented a fix, and duplicating that effort would be ridiculous, especially with how much else I'm trying to get done right now.


--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To view this discussion on the web visit https://groups.google.com/d/msg/turbogears/-/1leH1wrHBXIJ.

To post to this group, send email to turbo...@googlegroups.com.
To unsubscribe from this group, send email to turbogears+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en.

ozwyzard

unread,
Jan 6, 2013, 12:37:33 AM1/6/13
to turbo...@googlegroups.com
Understood.  Not suggesting that it be implemented as posted.  Hoping that the workaround-fix would illustrate the bug (if any).
Reply all
Reply to author
Forward
0 new messages