display results from external source in zpt
Hi, Apologies if this is easy to do, cannot find any help in the archives (but then again not sure what to search for) We currently run a script on an external server which returns results depending on the userid of the user, which is added to the link below once the user logs into zope. It works and displays what is needed, however i would like to display the results somehow within a page template rather than the user having to go elsewhere to see the results. <a href="" tal:define="uid python:member.getProperty('uid')" tal:attributes="href string:http://site.ac.uk/cgi-bin/tasks?uid=$uid&fmt=plain">view results</a> Basically we would like to run above somehow but all results are returned within the same page. Hope this makes sense and is this possible? thanks very much dean
--On 15. März 2006 09:14:42 +0000 Dean Hale <dean.hale@sunderland.ac.uk> wrote:
<a href="" tal:define="uid python:member.getProperty('uid')" tal:attributes="href string:http://site.ac.uk/cgi-bin/tasks?uid=$uid&fmt=plain">view results</a>
Look at Python's urllib module. -aj ----------------------------------------------------------------------- - Andreas Jung ZOPYX Ltd. & Co KG - - E-mail: info@zopyx.com Web: www.zopyx.com, www.zopyx.de - -----------------------------------------------------------------------
Hi Andreas, Thanks for this i'm trying to use an example below from urllib import * url = 'http://site.ac.uk/cgi-bin/evisiontasks?uid=xxx0xxx&fmt=plain' html = urlretrieve(url).read() however am receiving the error Error Value: "from urllib import *" is not allowed i have followed the readme in python/Products/PythonScripts and created a __init__.py file and it has created a __init__.pyc file once the server has restated. I'm assuming i need to add some extra details to the __init__.py file is this correct and if so have you any ideas what they would be from Products.PythonScripts.Utility import allow_module allow_module('urllib') Sorry if the answer is obvious. thanks dean On 15 Mar 2006, at 09:23, Andreas Jung wrote: --On 15. März 2006 09:14:42 +0000 Dean Hale <dean.hale@sunderland.ac.uk> wrote:
<a href="" tal:define="uid python:member.getProperty('uid')" tal:attributes="href string:http://site.ac.uk/cgi-bin/tasks?uid=$uid&fmt=plain">view results</a>
Look at Python's urllib module. -aj ----------------------------------------------------------------------- - Andreas Jung ZOPYX Ltd. & Co KG - - E-mail: info@zopyx.com Web: www.zopyx.com, www.zopyx.de - ----------------------------------------------------------------------- --------------- Dean Hale Web Development Manager Library Services University of Sunderland w: https://my.sunderland.ac.uk t: +44 (0) 191 515 2424 f: +44 (0) 191 515 2904
--On 15. März 2006 12:03:48 +0000 Dean Hale <dean.hale@sunderland.ac.uk> wrote:
Hi Andreas,
Thanks for this i'm trying to use an example below
from urllib import * url = 'http://site.ac.uk/cgi-bin/evisiontasks?uid=xxx0xxx&fmt=plain' html = urlretrieve(url).read()
however am receiving the error
Error Value: "from urllib import *" is not allowed
i have followed the readme in python/Products/PythonScripts and created a __init__.py file and it has created a __init__.pyc file once the server has restated.
I'm assuming i need to add some extra details to the __init__.py file is this correct and if so have you any ideas what they would be
allow_module() is not a solution for all and everything (consider it a hack). Either write your code as external method or look at TrustedExecutables. -aj ----------------------------------------------------------------------- - Andreas Jung ZOPYX Ltd. & Co KG - - E-mail: info@zopyx.com Web: www.zopyx.com, www.zopyx.de - -----------------------------------------------------------------------
Andreas Jung wrote:
allow_module() is not a solution for all and everything (consider it a hack).
Don't be rediculous. It's not a hack, it's the documented way of providing security assertions from existing code without having to patch it. That sounds a lot like what the component architecture is, and I don't think anyone's likely to call that a hack. However, those allow_* functions are rather confusing. The documentation could do with beefing up and the circumstances where they don't work should be raised as bugs... cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Dean Hale wrote:
I'm assuming i need to add some extra details to the __init__.py file is this correct and if so have you any ideas what they would be
from Products.PythonScripts.Utility import allow_module
allow_module('urllib')
I dunno if it'll help, but try enabling verbose security in your zope.conf. However, you may just need to fiddle. Try adding some allow_* statements for urlopen as well as anything else you import from urllin and see how you go. That said, it may be easier (and execute faster) if you just duck out and use an external method. Also, be aware that doing what you're doing, the performance of your website now depends on the performance of another website, and the network between your webserver and the other webserver. This may not be what you want. You should certainly look at introducing a socket timeout for those connections.... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Dean Hale wrote:
Hi,
Apologies if this is easy to do, cannot find any help in the archives (but then again not sure what to search for)
We currently run a script on an external server which returns results depending on the userid of the user, which is added to the link below once the user logs into zope.
It works and displays what is needed, however i would like to display the results somehow within a page template rather than the user having to go elsewhere to see the results.
<a href="" tal:define="uid python:member.getProperty('uid')" tal:attributes="href string:http://site.ac.uk/cgi-bin/tasks?uid=$uid&fmt=plain">view results</a>
Basically we would like to run above somehow but all results are returned within the same page.
This might be what the doctor ordered? http://www.mxm.dk/products/public/mxmProxyTool/ -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science Phone: +45 66 11 84 94 Mobile: +45 29 93 42 96
participants (4)
-
Andreas Jung -
Chris Withers -
Dean Hale -
Max M