I have been playing around with existing Python scripts and have found that I need to determine the URL of the script itself. Actually what I need is the equivalent of the URLx construct for the http Request object that works with for the URL of the script. My experience with Python is limited so I am probably missing something obvious -- can anybody provide a clue as to where I should start?
Brian Sullivan writes:
I have been playing around with existing Python scripts and have found that I need to determine the URL of the script itself. Actually what I need is the equivalent of the URLx construct for the http Request object that works with for the URL of the script.
url= script.absolute_url() # to get the URL # much more work to get the URLx parts -- do you really need them?
My experience with Python is limited so I am probably missing something obvious -- can anybody provide a clue as to where I should start? Change this. Python is easy. To be learned in a few days...
Look into a Python book, the Python language reference, the Python library documentation... Dieter
I have been playing around with existing Python scripts and have found > that I need to determine the URL of the script itself. Actually what I > need is the equivalent of the URLx construct for the http Request object > that works with for the URL of the script.
url= script.absolute_url() # to get the URL
Unfortunately this does not work ( at least not in the situation I am using it) - it seems to return a url that is the url of http request with the name of the script tacked on: Like: http://mysite/test/name_of_script When the real location of the script is http://mysite/test/directory1/directory2/scripts/name_of_script Surely there is some reliable way of getting the second information!
string.join(script.PhysicalPath(), '/') will return what you want. Florent Brian Sullivan <brians@meetingbywire.com> wrote:
I have been playing around with existing Python scripts and have found > that I need to determine the URL of the script itself. Actually what I > need is the equivalent of the URLx construct for the http Request object > that works with for the URL of the script.
url= script.absolute_url() # to get the URL
Unfortunately this does not work ( at least not in the situation I am using it) - it seems to return a url that is the url of http request with the name of the script tacked on:
Like:
http://mysite/test/name_of_script
When the real location of the script is
Surely there is some reliable way of getting the second information!
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 79 10 http://nuxeo.com mailto:fg@nuxeo.com
participants (3)
-
Brian Sullivan -
Dieter Maurer -
Florent Guillaume