----- Original Message ----- From: "Mihamina Rakotomandimby" <mihamina.rakotomandimby@etu.univ-orleans.fr> To: "Jonathan" <dev101@magma.ca> Sent: Monday, December 18, 2006 1:34 PM Subject: Python script, urllib2
Hi, I want to fetch at least the <head></head> part of an html static page from a python script (added through the ZMI). Here is the content of the python script:
import urllib2 t="http://www.asso-polyvalente.fr/" req=urllib2.Request(t) h=urllib2.urlopen(req) the_page=h.read() print the_page printed
Then I get a: "You are not allowed to access 'Request' in this context"
Ok. I remember in some ML I subscribe, I could allow some action/module by listing the allowed actions/modules somewhere. Unfortunately, I cant remember where/wht to do. Would you help me?
I would recommend using urllib in an external method, not a python script. If you want to use a python script to access the contents of a static page (static page created via the ZMI), why don't you do something like: staticPage = context.restrictedTraverse('/path/to/the/static/page/staticPage.html') The variable staticPage will then hold the contents of the static page and you can process it as you require. Jonathan ps. pls keep your posts on the list so that others can help and so that future generations can find/follow the thread!
On Mon, 2006-12-18 at 17:03 -0500, Jonathan wrote:
If you want to use a python script to access the contents of a static page (static page created via the ZMI), why don't you do something like: staticPage = context.restrictedTraverse('/path/to/the/static/page/staticPage.html')
No, it is really on a remote server. The retrieval part I mentionned is just part of the problem, I proceed with HTMLParser after retrieval. Ok, for the external method. I will drop a tutorial soon.
ps. pls keep your posts on the list so that others can help and so that future generations can find/follow the thread!
I _always_ keep my posts on the list. My MUA has a shortcut (Ctrl+l) to do so. And I do pay attention when checking the recipients of my messages.
Ok. I remember in some ML I subscribe, I could allow some action/module by listing the allowed actions/modules somewhere. Unfortunately, I cant remember where/wht to do. Take a look at: <ZOPE>/lib/python/Products/PythonScripts/README.txt
I _always_ keep my posts on the list. My MUA has a shortcut (Ctrl+l) to do so. And I do pay attention when checking the recipients of my messages. But I haven't seen your post before Jonathan posted it...
-- Maciej Wisniowski
participants (3)
-
Jonathan -
Maciej Wisniowski -
Mihamina Rakotomandimby