urllib.urlopen inside a python-script? alternatives?
Hello, I'm trying to use facebook's single-sign-on mechanism with zope and querying account information for logged in facebook-users from within zope. For this I need to send url-requests from my zope-server to the facebook-servers and read the response. I tried to test the concept with a python-script: ############## import urllib cookie= request["fbs_" + "<the application id>"] args=dict(map(lambda x:x.split('='),cookie.split('&'))) url="https://graph.facebook.com/me?access_token="+args['access_token'] file = urllib.urlopen(url) resp=file.read() file.close() return args,url,resp ############## When running this an authentication-window pops up - and subsequently tells me: ----------- Error Type: Unauthorized Error Value: You are not allowed to access 'urlopen' in this context ----------- So the problem is with opening the external-url I suppose ... What's the Zope-way of doing this? - how can I tell it to get read information of another URL? thanks, stephan
urlopen is restricted python. You will need to create file system script (a product) (or external script) in order to use it. On Mon, Nov 15, 2010 at 8:43 AM, <stephan0h@gmx.net> wrote:
Hello,
I'm trying to use facebook's single-sign-on mechanism with zope and querying account information for logged in facebook-users from within zope.
For this I need to send url-requests from my zope-server to the facebook-servers and read the response. I tried to test the concept with a python-script:
############## import urllib
cookie= request["fbs_" + "<the application id>"]
args=dict(map(lambda x:x.split('='),cookie.split('&')))
url="https://graph.facebook.com/me?access_token="+args['access_token']
file = urllib.urlopen(url) resp=file.read() file.close()
return args,url,resp ##############
When running this an authentication-window pops up - and subsequently tells me:
----------- Error Type: Unauthorized Error Value: You are not allowed to access 'urlopen' in this context -----------
So the problem is with opening the external-url I suppose ...
What's the Zope-way of doing this? - how can I tell it to get read information of another URL?
thanks, stephan _______________________________________________ Zope maillist - Zope@zope.org https://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope-dev )
-- David Bear College of Public Programs at ASU 602-494-0424
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 David Bear wrote:
urlopen is restricted python. You will need to create file system script (a product) (or external script) in order to use it.
http://plone.org/documentation/faq/restricted-python-scripts - -aj -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQGUBAEBAgAGBQJM4VZmAAoJEADcfz7u4AZjg4oLwMSgyUgNePVcrbcO+r9bXiFY GvGSOxOP0UaNmuYrrDHZud9k7JfiIXxyySZ3Ee4ZL6OoIHA3i6F1XlPV/hrs/aqo RzHKYA908WUWWn//E6qpLEMAzFbvcbbhbhkeIpIUXAdyoWkblEVl6BnS9sfbo2Hr 52jbzfSEqLonXm71TtI1QWdKSh29bt8dsGa7oEqGTFh4VSP7GkPzUvB1rx0KewwS yRIqf76KS/wd0NLRfW6A9NHrsS7HaZmu6YuxunjMBaxoo7fjPa1mj0RJKGF6QCUh gqu8E7F3qB6kAKCtRQtWvfPPWCIU0kymnf2R0Mn5l/7qUh+k9Iy5bdjAtGecYqKt kvTjMVXhbBslSTmZJIr63Ei8Dp0cRREonX0fg5QN+HwU2QB3Su5AOuIohQ5cdoXG sexIuAnjjnA7qC65DiZZE2oOlWnpa2uIbV/jp05pMsuuRFg21qEDsQtTBjgYhwse 76uwydzpSTOdaMpqay3wCghMRZWXreg= =H0Z9 -----END PGP SIGNATURE-----
Thanks for the hint, this solved my problem. br, stephan Am 2010-11-15 16:48, schrieb Andreas Jung:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
David Bear wrote:
urlopen is restricted python. You will need to create file system script (a product) (or external script) in order to use it.
http://plone.org/documentation/faq/restricted-python-scripts
- -aj -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQGUBAEBAgAGBQJM4VZmAAoJEADcfz7u4AZjg4oLwMSgyUgNePVcrbcO+r9bXiFY GvGSOxOP0UaNmuYrrDHZud9k7JfiIXxyySZ3Ee4ZL6OoIHA3i6F1XlPV/hrs/aqo RzHKYA908WUWWn//E6qpLEMAzFbvcbbhbhkeIpIUXAdyoWkblEVl6BnS9sfbo2Hr 52jbzfSEqLonXm71TtI1QWdKSh29bt8dsGa7oEqGTFh4VSP7GkPzUvB1rx0KewwS yRIqf76KS/wd0NLRfW6A9NHrsS7HaZmu6YuxunjMBaxoo7fjPa1mj0RJKGF6QCUh gqu8E7F3qB6kAKCtRQtWvfPPWCIU0kymnf2R0Mn5l/7qUh+k9Iy5bdjAtGecYqKt kvTjMVXhbBslSTmZJIr63Ei8Dp0cRREonX0fg5QN+HwU2QB3Su5AOuIohQ5cdoXG sexIuAnjjnA7qC65DiZZE2oOlWnpa2uIbV/jp05pMsuuRFg21qEDsQtTBjgYhwse 76uwydzpSTOdaMpqay3wCghMRZWXreg= =H0Z9 -----END PGP SIGNATURE-----
participants (3)
-
Andreas Jung -
David Bear -
stephan0h@gmx.net