Skip to content

Loading…

Accessing self.request from an iframe-htmlfile connection (IE8/9) #15

Closed
thapar opened this Issue · 16 comments

2 participants

@thapar

How can I access self.request in an iframe-htmlfile connection (IE8/9)? self.request is always None from an IE8/9 request.

single-file app: http://paste.ofcode.org/XzSpU5uT7bNsmZk3WJMdS9
with your chat.pt as the template file

@fafhrd91
Owner

well, i dont have access to IE, but i tested iframe-htmlfile transport in firefox. works as expected

@fafhrd91 fafhrd91 closed this
@fafhrd91 fafhrd91 reopened this
@thapar

Meaning, it's expected not to have access to self.request within the class EchoSession(Session)? Because no one else has been able to access self.request with iframe-htmlfile either.

@fafhrd91
Owner

it is expected to have access to request. you should be able to get request object for any transport.

i cant test IE at the moment, i will try to get win box with IE in a week or two.

@thapar

Even in Chrome and Firefox, with iframe-htmlfile, self.request is None. This is confirmed by other users as well. Because an iframe request is an independent request, perhaps it needs to be retrieved from elsewhere?

@fafhrd91
Owner

what OS do you use? what versions of chrome and firefox?

@thapar

Windows 7 x64

  • Chrome - Version 23.0.1271.26 beta-m
  • FF - 16.0.1
  • IE - 9

Ubuntu 11.04 x64

  • Chromium - Version 12.0.742.112 (90304)
  • FF - 5.0
@fafhrd91
Owner

and do you test on master?

@thapar

Yes

@fafhrd91
Owner

ok, i'll install ubuntu today and will try to reproduce

@thapar

I realize my single-file-app seems to have some issue since it isn't able to use websockets. But the issue exists in my main app and your example app as well (both of which can use websockets without an issue). This happens on both OS's (Windows + Ubuntu) and each browser I listed, where I use iframe-htmlfile as the transport means.

@thapar

Knock knock =)

@fafhrd91
Owner

chat example used sockjs-0.3.1 and it didnt work. chat example now uses sockjs 0.3.2
Firefox 16.0.1 + Ubuntu 12.04.1 works with sockjs 0.3.2

try again with latest change.

@thapar

Tried it with sockjs 0.3.2, but the same problem exists. If any iframe transport is used, self.request is None. If you pdb.set_trace() within on_open(self) and check self.request, you can see that it is in fact None.

@fafhrd91
Owner

here is what i get

-> self.manager.broadcast("Someone joined.")
(Pdb) self.request
<Request at 0xa8cdacc GET http://localhost:8080/__sockjs__/846/ai03l59f/htmlfile?c=_jp.atenqmo>
(Pdb)
@thapar

I created a fresh virtual environment and I now get the same output. Not sure what the issue was earlier. Continuing on this train though, authenticated_userid(self.request), as well as for sess in self.manager.active_sessions(): print sess both give this error:

2012-10-16 13:20:06,387 ERROR [pyramid_sockjs][Dummy-3] Exceptin in .on_open method.
Traceback (most recent call last):
  File "/home/raj/cleanenv/lib/python2.7/site-packages/pyramid_sockjs/session.py", line 90, in open
    self.on_open()
  File "/home/raj/Practice/git/newsite/newsite/views/chat.py", line 179, in on_open
    nick = authenticated_userid(self.request)
  File "/home/raj/cleanenv/lib/python2.7/site-packages/pyramid_sockjs/session.py", line 55, in __str__
    result = ['id=%r' % self.id]
TypeError: not all arguments converted during string formatting

Also:

(Pdb) self.request
<RequestWithUserAttribute at 0x4c15a90 GET http://babasociety.local:6543/__sockjs__/585/89_w5di1/websocket>
(Pdb) self.id
('Guest3796', u'89_w5di1')

Guest3796 should be the authenticated_userid(self.request).

Any idea?

@fafhrd91
Owner

thats bug, fixed in master

@fafhrd91 fafhrd91 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.